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
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
* e-shell-window-private.c
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "e-shell-window-private.h"
#include "e-util/gconf-bridge.h"
#ifdef NM_SUPPORT_GLIB
void e_shell_nm_glib_initialise (EShellWindow *window);
void e_shell_nm_glib_dispose (EShellWindow *window);
#elif NM_SUPPORT
void e_shell_dbus_initialise (EShellWindow *window);
void e_shell_dbus_dispose (EShellWindow *window);
#endif
static void
shell_window_menu_item_select_cb (EShellWindow *window,
GtkWidget *menu_item)
{
GtkAction *action;
GtkLabel *label;
gchar *tooltip;
action = g_object_get_data (G_OBJECT (menu_item), "action");
g_return_if_fail (GTK_IS_ACTION (action));
g_object_get (action, "tooltip", &tooltip, NULL);
if (tooltip == NULL)
return;
label = GTK_LABEL (window->priv->tooltip_label);
gtk_label_set_text (label, tooltip);
g_free (tooltip);
gtk_widget_show (window->priv->tooltip_label);
gtk_widget_hide (window->priv->status_notebook);
}
static void
shell_window_menu_item_deselect_cb (EShellWindow *window)
{
gtk_widget_hide (window->priv->tooltip_label);
gtk_widget_show (window->priv->status_notebook);
}
static void
shell_window_connect_proxy_cb (EShellWindow *window,
GtkAction *action,
GtkWidget *proxy)
{
if (!GTK_IS_MENU_ITEM (proxy))
return;
g_object_set_data_full (
G_OBJECT (proxy), "action", action,
(GDestroyNotify) g_object_unref);
g_signal_connect_swapped (
proxy, "select",
G_CALLBACK (shell_window_menu_item_select_cb), window);
g_signal_connect_swapped (
proxy, "deselect",
G_CALLBACK (shell_window_menu_item_deselect_cb), window);
}
static void
shell_window_online_button_clicked_cb (EOnlineButton *button,
EShellWindow *window)
{
if (e_online_button_get_online (button))
gtk_action_activate (ACTION (WORK_OFFLINE));
else
gtk_action_activate (ACTION (WORK_ONLINE));
}
void
e_shell_window_private_init (EShellWindow *window)
{
EShellWindowPrivate *priv = window->priv;
GConfBridge *bridge;
GtkWidget *container;
GtkWidget *widget;
GObject *object;
const gchar *key;
gint height;
priv->manager = gtk_ui_manager_new ();
priv->shell_actions = gtk_action_group_new ("shell");
priv->new_item_actions = gtk_action_group_new ("new-item");
priv->new_group_actions = gtk_action_group_new ("new-group");
priv->new_source_actions = gtk_action_group_new ("new-source");
priv->shell_view_actions = gtk_action_group_new ("shell-view");
priv->shell_views = g_ptr_array_new ();
/* XXX Load UI file. */
e_shell_window_actions_init (window);
gtk_window_add_accel_group (
GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (priv->manager));
g_signal_connect_swapped (
priv->manager, "connect-proxy",
G_CALLBACK (shell_window_connect_proxy_cb), window);
/* Construct window widgets. */
widget = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), widget);
container = widget;
widget = e_shell_window_get_managed_widget (window, "/main-menu");
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
priv->main_menu = g_object_ref (widget);
gtk_widget_show (widget);
widget = e_shell_window_get_managed_widget (window, "/main-toolbar");
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
priv->main_toolbar = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_hpaned_new ();
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
priv->content_pane = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
priv->status_area = g_object_ref (widget);
gtk_widget_show (widget);
/* Make the status area as large as the task bar. */
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &height);
gtk_widget_set_size_request (widget, -1, height * 2);
container = priv->content_pane;
widget = e_sidebar_new ();
gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
priv->sidebar = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, FALSE);
priv->content_notebook = g_object_ref (widget);
gtk_widget_show (widget);
container = priv->sidebar;
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_container_add (GTK_CONTAINER (container), widget);
priv->sidebar_notebook = g_object_ref (widget);
gtk_widget_show (widget);
container = priv->status_area;
widget = e_online_button_new ();
g_signal_connect (
widget, "clicked",
G_CALLBACK (shell_window_online_button_clicked_cb), window);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
priv->online_button = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
priv->tooltip_label = g_object_ref (widget);
gtk_widget_hide (widget);
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
priv->status_notebook = g_object_ref (widget);
gtk_widget_show (widget);
/* Bind GObject properties to GConf keys. */
bridge = gconf_bridge_get ();
key = "/apps/evolution/shell/view_defaults/window";
gconf_bridge_bind_window (
bridge, key, GTK_WINDOW (window), TRUE, FALSE);
object = G_OBJECT (priv->content_pane);
key = "/apps/evolution/shell/view_defaults/folder_bar/width";
gconf_bridge_bind_property_delayed (bridge, key, object, "position");
object = G_OBJECT (ACTION (SHOW_BUTTONS));
key = "/apps/evolution/shell/view-defaults/buttons_visible";
gconf_bridge_bind_property (bridge, key, object, "active");
object = G_OBJECT (ACTION (SHOW_SIDEBAR));
key = "/apps/evolution/shell/view-defaults/sidebar_visible";
gconf_bridge_bind_property (bridge, key, object, "active");
object = G_OBJECT (ACTION (SHOW_STATUSBAR));
key = "/apps/evolution/shell/view_defaults/statusbar_visible";
gconf_bridge_bind_property (bridge, key, object, "active");
object = G_OBJECT (ACTION (SHOW_TOOLBAR));
key = "/apps/evolution/shell/view_defaults/toolbar_visible";
gconf_bridge_bind_property (bridge, key, object, "active");
/* NetworkManager integration. */
#ifdef NM_SUPPORT_GLIB
e_shell_nm_glib_initialise (window);
#elif NM_SUPPORT
e_shell_dbus_initialise (window);
#endif
/* Initialize shell views */
e_shell_window_create_shell_view_actions (window);
}
void
e_shell_window_private_dispose (EShellWindow *window)
{
EShellWindowPrivate *priv = window->priv;
DISPOSE (priv->manager);
DISPOSE (priv->shell_actions);
DISPOSE (priv->new_item_actions);
DISPOSE (priv->new_group_actions);
DISPOSE (priv->new_source_actions);
DISPOSE (priv->shell_view_actions);
DISPOSE (priv->main_menu);
DISPOSE (priv->main_toolbar);
DISPOSE (priv->content_pane);
DISPOSE (priv->content_notebook);
DISPOSE (priv->sidebar);
DISPOSE (priv->sidebar_notebook);
DISPOSE (priv->status_area);
DISPOSE (priv->online_button);
DISPOSE (priv->tooltip_label);
DISPOSE (priv->status_notebook);
#ifdef NM_SUPPORT_GLIB
e_shell_nm_glib_dispose (E_SHELL_WINDOW (object));
#elif NM_SUPPORT
e_shell_dbus_dispose (E_SHELL_WINDOW (object));
#endif
}
void
e_shell_window_private_finalize (EShellWindow *window)
{
EShellWindowPrivate *priv = window->priv;
g_ptr_array_foreach (priv->shell_views, (GFunc) g_object_unref, NULL);
g_ptr_array_free (priv->shell_views, TRUE);
}
|