1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
---|
2 | /* evolution-shell-view.c |
---|
3 | * |
---|
4 | * Copyright (C) 2000 Ximian, Inc. |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or |
---|
7 | * modify it under the terms of version 2 of the GNU General Public |
---|
8 | * License as published by the Free Software Foundation. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | * General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public |
---|
16 | * License along with this program; if not, write to the |
---|
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
18 | * Boston, MA 02111-1307, USA. |
---|
19 | * |
---|
20 | * Author: Ettore Perazzoli |
---|
21 | */ |
---|
22 | |
---|
23 | #ifdef HAVE_CONFIG_H |
---|
24 | #include <config.h> |
---|
25 | #endif |
---|
26 | |
---|
27 | #include <gtk/gtksignal.h> |
---|
28 | |
---|
29 | #include <gal/util/e-util.h> |
---|
30 | |
---|
31 | #include "evolution-shell-view.h" |
---|
32 | |
---|
33 | |
---|
34 | #define PARENT_TYPE bonobo_object_get_type () |
---|
35 | static BonoboObjectClass *parent_class = NULL; |
---|
36 | |
---|
37 | struct _EvolutionShellViewPrivate { |
---|
38 | int dummy; |
---|
39 | }; |
---|
40 | |
---|
41 | enum { |
---|
42 | SET_MESSAGE, |
---|
43 | UNSET_MESSAGE, |
---|
44 | CHANGE_VIEW, |
---|
45 | SET_TITLE, |
---|
46 | SET_FOLDER_BAR_LABEL, |
---|
47 | SHOW_SETTINGS, |
---|
48 | LAST_SIGNAL |
---|
49 | }; |
---|
50 | static int signals[LAST_SIGNAL] = { 0 }; |
---|
51 | |
---|
52 | |
---|
53 | /* CORBA interface implementation. */ |
---|
54 | |
---|
55 | static POA_GNOME_Evolution_ShellView__vepv ShellView_vepv; |
---|
56 | |
---|
57 | static POA_GNOME_Evolution_ShellView * |
---|
58 | create_servant (void) |
---|
59 | { |
---|
60 | POA_GNOME_Evolution_ShellView *servant; |
---|
61 | CORBA_Environment ev; |
---|
62 | |
---|
63 | servant = (POA_GNOME_Evolution_ShellView *) g_new0 (BonoboObjectServant, 1); |
---|
64 | servant->vepv = &ShellView_vepv; |
---|
65 | CORBA_exception_init (&ev); |
---|
66 | |
---|
67 | POA_GNOME_Evolution_ShellView__init ((PortableServer_Servant) servant, &ev); |
---|
68 | if (ev._major != CORBA_NO_EXCEPTION) { |
---|
69 | g_free (servant); |
---|
70 | CORBA_exception_free (&ev); |
---|
71 | return NULL; |
---|
72 | } |
---|
73 | |
---|
74 | CORBA_exception_free (&ev); |
---|
75 | |
---|
76 | return servant; |
---|
77 | } |
---|
78 | |
---|
79 | static void |
---|
80 | impl_ShellView_set_message (PortableServer_Servant servant, |
---|
81 | const CORBA_char *message, |
---|
82 | const CORBA_boolean busy, |
---|
83 | CORBA_Environment *ev) |
---|
84 | { |
---|
85 | BonoboObject *bonobo_object; |
---|
86 | |
---|
87 | bonobo_object = bonobo_object_from_servant (servant); |
---|
88 | gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[SET_MESSAGE], message, busy); |
---|
89 | } |
---|
90 | |
---|
91 | static void |
---|
92 | impl_ShellView_unset_message (PortableServer_Servant servant, |
---|
93 | CORBA_Environment *ev) |
---|
94 | { |
---|
95 | BonoboObject *bonobo_object; |
---|
96 | |
---|
97 | bonobo_object = bonobo_object_from_servant (servant); |
---|
98 | gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[UNSET_MESSAGE]); |
---|
99 | } |
---|
100 | |
---|
101 | static void |
---|
102 | impl_ShellView_change_current_view (PortableServer_Servant servant, |
---|
103 | const CORBA_char *uri, |
---|
104 | CORBA_Environment *ev) |
---|
105 | { |
---|
106 | BonoboObject *bonobo_object; |
---|
107 | |
---|
108 | bonobo_object = bonobo_object_from_servant (servant); |
---|
109 | gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[CHANGE_VIEW], |
---|
110 | uri); |
---|
111 | } |
---|
112 | |
---|
113 | static void |
---|
114 | impl_ShellView_set_title (PortableServer_Servant servant, |
---|
115 | const CORBA_char *title, |
---|
116 | CORBA_Environment *ev) |
---|
117 | { |
---|
118 | BonoboObject *bonobo_object; |
---|
119 | |
---|
120 | bonobo_object = bonobo_object_from_servant (servant); |
---|
121 | gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[SET_TITLE], |
---|
122 | title); |
---|
123 | } |
---|
124 | |
---|
125 | static void |
---|
126 | impl_ShellView_set_folder_bar_label (PortableServer_Servant servant, |
---|
127 | const CORBA_char *text, |
---|
128 | CORBA_Environment *ev) |
---|
129 | { |
---|
130 | BonoboObject *bonobo_object; |
---|
131 | |
---|
132 | bonobo_object = bonobo_object_from_servant (servant); |
---|
133 | gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[SET_FOLDER_BAR_LABEL], |
---|
134 | text); |
---|
135 | } |
---|
136 | |
---|
137 | static void |
---|
138 | impl_ShellView_show_settings (PortableServer_Servant servant, |
---|
139 | CORBA_Environment *ev) |
---|
140 | { |
---|
141 | BonoboObject *bonobo_object; |
---|
142 | |
---|
143 | bonobo_object = bonobo_object_from_servant (servant); |
---|
144 | gtk_signal_emit (GTK_OBJECT (bonobo_object), signals[SHOW_SETTINGS]); |
---|
145 | } |
---|
146 | |
---|
147 | |
---|
148 | /* GtkObject methods. */ |
---|
149 | static void |
---|
150 | destroy (GtkObject *object) |
---|
151 | { |
---|
152 | EvolutionShellView *shell_view; |
---|
153 | EvolutionShellViewPrivate *priv; |
---|
154 | |
---|
155 | shell_view = EVOLUTION_SHELL_VIEW (object); |
---|
156 | priv = shell_view->priv; |
---|
157 | |
---|
158 | g_free (priv); |
---|
159 | |
---|
160 | (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); |
---|
161 | } |
---|
162 | |
---|
163 | |
---|
164 | static void |
---|
165 | corba_class_init (void) |
---|
166 | { |
---|
167 | POA_GNOME_Evolution_ShellView__vepv *vepv; |
---|
168 | POA_GNOME_Evolution_ShellView__epv *epv; |
---|
169 | PortableServer_ServantBase__epv *base_epv; |
---|
170 | |
---|
171 | base_epv = g_new0 (PortableServer_ServantBase__epv, 1); |
---|
172 | base_epv->_private = NULL; |
---|
173 | base_epv->finalize = NULL; |
---|
174 | base_epv->default_POA = NULL; |
---|
175 | |
---|
176 | epv = g_new0 (POA_GNOME_Evolution_ShellView__epv, 1); |
---|
177 | epv->setMessage = impl_ShellView_set_message; |
---|
178 | epv->unsetMessage = impl_ShellView_unset_message; |
---|
179 | epv->changeCurrentView = impl_ShellView_change_current_view; |
---|
180 | epv->setTitle = impl_ShellView_set_title; |
---|
181 | epv->setFolderBarLabel = impl_ShellView_set_folder_bar_label; |
---|
182 | epv->showSettings = impl_ShellView_show_settings; |
---|
183 | |
---|
184 | vepv = &ShellView_vepv; |
---|
185 | vepv->_base_epv = base_epv; |
---|
186 | vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); |
---|
187 | vepv->GNOME_Evolution_ShellView_epv = epv; |
---|
188 | } |
---|
189 | |
---|
190 | static void |
---|
191 | class_init (EvolutionShellViewClass *klass) |
---|
192 | { |
---|
193 | GtkObjectClass *object_class; |
---|
194 | |
---|
195 | object_class = GTK_OBJECT_CLASS (klass); |
---|
196 | object_class->destroy = destroy; |
---|
197 | |
---|
198 | signals[SET_MESSAGE] |
---|
199 | = gtk_signal_new ("set_message", |
---|
200 | GTK_RUN_FIRST, |
---|
201 | object_class->type, |
---|
202 | GTK_SIGNAL_OFFSET (EvolutionShellViewClass, set_message), |
---|
203 | gtk_marshal_NONE__POINTER_INT, |
---|
204 | GTK_TYPE_NONE, 2, |
---|
205 | GTK_TYPE_STRING, |
---|
206 | GTK_TYPE_BOOL); |
---|
207 | |
---|
208 | signals[UNSET_MESSAGE] |
---|
209 | = gtk_signal_new ("unset_message", |
---|
210 | GTK_RUN_FIRST, |
---|
211 | object_class->type, |
---|
212 | GTK_SIGNAL_OFFSET (EvolutionShellViewClass, unset_message), |
---|
213 | gtk_marshal_NONE__NONE, |
---|
214 | GTK_TYPE_NONE, 0); |
---|
215 | |
---|
216 | signals[CHANGE_VIEW] |
---|
217 | = gtk_signal_new ("change_current_view", |
---|
218 | GTK_RUN_FIRST, |
---|
219 | object_class->type, |
---|
220 | GTK_SIGNAL_OFFSET (EvolutionShellViewClass, change_current_view), |
---|
221 | gtk_marshal_NONE__POINTER, |
---|
222 | GTK_TYPE_NONE, 1, |
---|
223 | GTK_TYPE_STRING); |
---|
224 | |
---|
225 | signals[SET_TITLE] |
---|
226 | = gtk_signal_new ("set_title", |
---|
227 | GTK_RUN_FIRST, |
---|
228 | object_class->type, |
---|
229 | GTK_SIGNAL_OFFSET (EvolutionShellViewClass, set_title), |
---|
230 | gtk_marshal_NONE__POINTER, |
---|
231 | GTK_TYPE_NONE, 1, |
---|
232 | GTK_TYPE_STRING); |
---|
233 | |
---|
234 | signals[SET_FOLDER_BAR_LABEL] |
---|
235 | = gtk_signal_new ("set_folder_bar_label", |
---|
236 | GTK_RUN_FIRST, |
---|
237 | object_class->type, |
---|
238 | GTK_SIGNAL_OFFSET (EvolutionShellViewClass, set_folder_bar_label), |
---|
239 | gtk_marshal_NONE__POINTER, |
---|
240 | GTK_TYPE_NONE, 1, |
---|
241 | GTK_TYPE_STRING); |
---|
242 | |
---|
243 | signals[SHOW_SETTINGS] |
---|
244 | = gtk_signal_new ("show_settings", |
---|
245 | GTK_RUN_FIRST, |
---|
246 | object_class->type, |
---|
247 | GTK_SIGNAL_OFFSET (EvolutionShellViewClass, show_settings), |
---|
248 | gtk_marshal_NONE__NONE, |
---|
249 | GTK_TYPE_NONE, 0); |
---|
250 | |
---|
251 | gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); |
---|
252 | |
---|
253 | parent_class = gtk_type_class (bonobo_object_get_type ()); |
---|
254 | |
---|
255 | corba_class_init (); |
---|
256 | } |
---|
257 | |
---|
258 | static void |
---|
259 | init (EvolutionShellView *shell_view) |
---|
260 | { |
---|
261 | EvolutionShellViewPrivate *priv; |
---|
262 | |
---|
263 | priv = g_new (EvolutionShellViewPrivate, 1); |
---|
264 | priv->dummy = 0; |
---|
265 | |
---|
266 | shell_view->priv = priv; |
---|
267 | } |
---|
268 | |
---|
269 | |
---|
270 | /** |
---|
271 | * evolution_shell_view_construct: |
---|
272 | * @shell_view: |
---|
273 | * @corba_object: |
---|
274 | * |
---|
275 | * Construct @shell_view with the specified @corba_object. |
---|
276 | **/ |
---|
277 | void |
---|
278 | evolution_shell_view_construct (EvolutionShellView *shell_view, |
---|
279 | GNOME_Evolution_ShellView corba_object) |
---|
280 | { |
---|
281 | g_return_if_fail (shell_view != NULL); |
---|
282 | g_return_if_fail (EVOLUTION_IS_SHELL_VIEW (shell_view)); |
---|
283 | |
---|
284 | bonobo_object_construct (BONOBO_OBJECT (shell_view), corba_object); |
---|
285 | } |
---|
286 | |
---|
287 | /** |
---|
288 | * evolution_shell_view_new: |
---|
289 | * |
---|
290 | * Create a new EvolutionShellView object. |
---|
291 | * |
---|
292 | * Return value: The new EvolutionShellView object. |
---|
293 | **/ |
---|
294 | EvolutionShellView * |
---|
295 | evolution_shell_view_new (void) |
---|
296 | { |
---|
297 | POA_GNOME_Evolution_ShellView *servant; |
---|
298 | GNOME_Evolution_ShellView corba_object; |
---|
299 | EvolutionShellView *new; |
---|
300 | |
---|
301 | servant = create_servant (); |
---|
302 | if (servant == NULL) |
---|
303 | return NULL; |
---|
304 | |
---|
305 | new = gtk_type_new (evolution_shell_view_get_type ()); |
---|
306 | |
---|
307 | corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new), servant); |
---|
308 | |
---|
309 | evolution_shell_view_construct (new, corba_object); |
---|
310 | |
---|
311 | return new; |
---|
312 | } |
---|
313 | |
---|
314 | |
---|
315 | E_MAKE_TYPE (evolution_shell_view, "EvolutionShellView", EvolutionShellView, class_init, init, PARENT_TYPE) |
---|