1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-summary.c
*
* Authors: Iain Holmes <iain@ximian.com>
*
* Copyright (C) 2000 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* published by the Free Software Foundation; either version 2 of the
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gtk/gtkframe.h>
#include <gal/util/e-util.h>
#include <gal/widgets/e-font.h>
#include <gal/e-text/e-text.h>
#include <libgnomeui/gnome-canvas.h>
#include <libgnomeui/gnome-canvas-widget.h>
#include "e-summary-subwindow.h"
#include "e-summary-titlebar.h"
#define PARENT_TYPE (gnome_canvas_group_get_type ())
#define TITLEBAR_BORDER_WIDTH 2
static void e_summary_subwindow_destroy (GtkObject *object);
static void e_summary_subwindow_class_init (GtkObjectClass *object_class);
static void e_summary_subwindow_init (GtkObject *object);
static GnomeCanvasGroupClass *parent_class;
struct _ESummarySubwindowPrivate {
GnomeCanvasItem *titlebar;
GnomeCanvasItem *contents;
GtkWidget *container;
char *title;
};
enum {
ARG_0,
ARG_X,
ARG_Y,
ARG_WIDTH,
ARG_HEIGHT,
ARG_STATE
};
enum {
CLOSE_CLICKED,
SHADE_CLICKED,
EDIT_CLICKED,
LAST_SIGNAL
};
static guint32 e_summary_subwindow_signals[LAST_SIGNAL] = { 0 };
static void
e_summary_subwindow_destroy (GtkObject *object)
{
ESummarySubwindow *subwindow = E_SUMMARY_SUBWINDOW (object);
ESummarySubwindowPrivate *priv;
priv = subwindow->private;
if (priv == NULL)
return;
if (priv->container) {
gtk_widget_destroy (priv->container);
priv->container = NULL;
}
if (priv->title) {
g_free (priv->title);
priv->title = NULL;
}
g_free (subwindow->private);
subwindow->private = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
e_summary_subwindow_realize (GnomeCanvasItem *item)
{
if (GNOME_CANVAS_ITEM_CLASS (parent_class)->realize)
(* GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) (item);
}
static void
e_summary_subwindow_unrealize (GnomeCanvasItem *item)
{
if (GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize)
(* GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) (item);
}
static void
e_summary_subwindow_class_init (GtkObjectClass *object_class)
{
GnomeCanvasItemClass *item_class;
item_class = (GnomeCanvasItemClass *) object_class;
object_class->destroy = e_summary_subwindow_destroy;
item_class->realize = e_summary_subwindow_realize;
item_class->unrealize = e_summary_subwindow_unrealize;
parent_class = gtk_type_class (PARENT_TYPE);
}
static void
e_summary_subwindow_init (GtkObject *object)
{
ESummarySubwindow *subwindow = E_SUMMARY_SUBWINDOW (object);
ESummarySubwindowPrivate *priv;
subwindow->private = g_new0 (ESummarySubwindowPrivate, 1);
priv = subwindow->private;
priv->title = NULL;
}
E_MAKE_TYPE (e_summary_subwindow, "ESummarySubwindow", ESummarySubwindow,
e_summary_subwindow_class_init, e_summary_subwindow_init,
PARENT_TYPE);
static void
container_size_allocate (GtkWidget *widget,
GtkAllocation *allocation,
ESummarySubwindow *subwindow)
{
ESummarySubwindowPrivate *priv;
g_return_if_fail (subwindow != NULL);
g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow));
priv = subwindow->private;
gnome_canvas_item_set (priv->titlebar,
"width", (double) allocation->width - 1,
NULL);
}
static void
edit_cb (GnomeCanvasItem *item,
ESummarySubwindow *subwindow)
{
g_print ("EDIT!\n");
}
static void
shade_cb (GnomeCanvasItem *item,
ESummarySubwindow *subwindow)
{
g_print ("SHADE!\n");
}
static void
close_cb (GnomeCanvasItem *item,
ESummarySubwindow *subwindow)
{
g_print ("CLOSE!\n");
gtk_object_destroy (GTK_OBJECT (subwindow));
}
void
e_summary_subwindow_construct (GnomeCanvasItem *item)
{
GnomeCanvasGroup *group;
ESummarySubwindow *subwindow;
ESummarySubwindowPrivate *priv;
EFont *font;
int titlebar_height;
g_return_if_fail (item != NULL);
g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (item));
subwindow = E_SUMMARY_SUBWINDOW (item);
priv = subwindow->private;
group = GNOME_CANVAS_GROUP (item);
font = e_font_from_gdk_font ( ((GtkWidget *) item->canvas)->style->font);
titlebar_height = 18 + 2 * TITLEBAR_BORDER_WIDTH; /* FIXME: Not hardcoded */
priv->titlebar = gnome_canvas_item_new (group,
e_summary_titlebar_get_type (),
"text", "Titlebar",
"width", 100.0,
NULL);
gtk_signal_connect (GTK_OBJECT (priv->titlebar), "edit",
GTK_SIGNAL_FUNC (edit_cb), subwindow);
gtk_signal_connect (GTK_OBJECT (priv->titlebar), "shade",
GTK_SIGNAL_FUNC (shade_cb), subwindow);
gtk_signal_connect (GTK_OBJECT (priv->titlebar), "close",
GTK_SIGNAL_FUNC (close_cb), subwindow);
priv->container = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (priv->container), GTK_SHADOW_ETCHED_IN);
gtk_widget_show (priv->container);
priv->contents = gnome_canvas_item_new (group,
gnome_canvas_widget_get_type (),
"x", (double) 0,
"y", (double) titlebar_height + 1,
"widget", priv->container,
NULL);
gtk_signal_connect (GTK_OBJECT (priv->container), "size_allocate",
GTK_SIGNAL_FUNC (container_size_allocate), subwindow);
}
GnomeCanvasItem *
e_summary_subwindow_new (GnomeCanvasGroup *parent,
double x,
double y)
{
GnomeCanvasItem *item;
item = gnome_canvas_item_new (parent, e_summary_subwindow_get_type (),
"x", x,
"y", y,
NULL);
e_summary_subwindow_construct (item);
return item;
}
/* These functions mimic the GtkContainer methods */
void
e_summary_subwindow_add (ESummarySubwindow *subwindow,
GtkWidget *widget)
{
ESummarySubwindowPrivate *priv;
g_return_if_fail (subwindow != NULL);
g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow));
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
priv = subwindow->private;
gtk_container_add (GTK_CONTAINER (priv->container), widget);
}
void
e_summary_subwindow_remove (ESummarySubwindow *subwindow,
GtkWidget *widget)
{
ESummarySubwindowPrivate *priv;
g_return_if_fail (subwindow != NULL);
g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow));
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
priv = subwindow->private;
gtk_container_remove (GTK_CONTAINER (priv->container), widget);
}
void
e_summary_subwindow_set_title (ESummarySubwindow *subwindow,
const char *title)
{
ESummarySubwindowPrivate *priv;
g_return_if_fail (subwindow != NULL);
g_return_if_fail (IS_E_SUMMARY_SUBWINDOW (subwindow));
g_return_if_fail (title != NULL);
priv = subwindow->private;
if (priv->title)
g_free (priv->title);
priv->title = g_strdup (title);
}
|