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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
/*
* libnautilus: A library for nautilus clients.
*
* Copyright (C) 1999, 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Elliot Lee <sopwith@redhat.com>
*
*/
/* ntl-view-client.c: Implementation for object that represents a nautilus view implementation. */
#include <gtk/gtk.h>
#include "libnautilus.h"
typedef struct {
POA_Nautilus_View servant;
gpointer gnome_object;
NautilusViewClient *view;
} impl_POA_Nautilus_View;
static void
impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant,
CORBA_char * config_path,
CORBA_Environment * ev);
static void
impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant,
CORBA_char * config_path,
CORBA_Environment * ev);
static void
impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant,
Nautilus_NavigationInfo * navinfo,
CORBA_Environment * ev);
static void
impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant,
CORBA_Environment * ev);
static void
impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant,
Nautilus_SelectionInfo * selinfo,
CORBA_Environment * ev);
static void
impl_Nautilus_View_stop_location_change(impl_POA_Nautilus_View * servant,
CORBA_Environment * ev);
POA_Nautilus_View__epv libnautilus_Nautilus_View_epv =
{
NULL, /* _private */
(gpointer) & impl_Nautilus_View_save_state,
(gpointer) & impl_Nautilus_View_load_state,
(gpointer) & impl_Nautilus_View_notify_location_change,
(gpointer) & impl_Nautilus_View_show_properties,
(gpointer) & impl_Nautilus_View_notify_selection_change,
(gpointer) & impl_Nautilus_View_stop_location_change
};
static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL };
static POA_Nautilus_View__vepv impl_Nautilus_View_vepv =
{
&base_epv,
NULL,
&libnautilus_Nautilus_View_epv
};
static void
impl_Nautilus_View_save_state(impl_POA_Nautilus_View * servant,
CORBA_char * config_path,
CORBA_Environment * ev)
{
gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "save_state", config_path);
}
static void
impl_Nautilus_View_load_state(impl_POA_Nautilus_View * servant,
CORBA_char * config_path,
CORBA_Environment * ev)
{
gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "load_state", config_path);
}
static void
impl_Nautilus_View_notify_location_change(impl_POA_Nautilus_View * servant,
Nautilus_NavigationInfo * navinfo,
CORBA_Environment * ev)
{
gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_location_change", navinfo);
}
static void
impl_Nautilus_View_show_properties(impl_POA_Nautilus_View * servant,
CORBA_Environment * ev)
{
gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "show_properties");
}
static void
impl_Nautilus_View_notify_selection_change(impl_POA_Nautilus_View * servant,
Nautilus_SelectionInfo * selinfo,
CORBA_Environment * ev)
{
gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "notify_selection_change", selinfo);
}
static void
impl_Nautilus_View_stop_location_change(impl_POA_Nautilus_View * servant,
CORBA_Environment * ev)
{
gtk_signal_emit_by_name(GTK_OBJECT(servant->view), "stop_location_change");
}
static void
impl_Nautilus_View__destroy(GnomeObject *obj, impl_POA_Nautilus_View *servant)
{
PortableServer_ObjectId *objid;
CORBA_Environment ev;
void (*servant_destroy_func)(PortableServer_Servant servant, CORBA_Environment *ev);
CORBA_exception_init(&ev);
servant_destroy_func = NAUTILUS_VIEW_CLIENT_CLASS(GTK_OBJECT(servant->view)->klass)->servant_destroy_func;
objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev);
PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev);
CORBA_free(objid);
obj->servant = NULL;
servant_destroy_func((PortableServer_Servant) servant, &ev);
g_free(servant);
CORBA_exception_free(&ev);
}
static GnomeObject *
impl_Nautilus_View__create(NautilusViewClient *view, CORBA_Environment * ev)
{
GnomeObject *retval;
impl_POA_Nautilus_View *newservant;
void (*servant_init_func)(PortableServer_Servant servant, CORBA_Environment *ev);
NautilusViewClientClass *view_class = NAUTILUS_VIEW_CLIENT_CLASS(GTK_OBJECT(view)->klass);
servant_init_func = view_class->servant_init_func;
newservant = g_new0(impl_POA_Nautilus_View, 1);
newservant->servant.vepv = view_class->vepv;
if(!newservant->servant.vepv->GNOME_Unknown_epv)
newservant->servant.vepv->GNOME_Unknown_epv = gnome_object_get_epv();
servant_init_func((PortableServer_Servant) newservant, ev);
newservant->view = view;
retval = gnome_object_new_from_servant(newservant);
gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_View__destroy), newservant);
return retval;
}
static void nautilus_view_client_init (NautilusViewClient *view);
static void nautilus_view_client_destroy (NautilusViewClient *view);
static void nautilus_view_client_class_init (NautilusViewClientClass *klass);
static void nautilus_view_client_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_view_client_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_view_client_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void nautilus_view_client_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
GtkType
nautilus_view_client_get_type (void)
{
static GtkType view_client_type = 0;
if (!view_client_type)
{
const GtkTypeInfo view_client_info =
{
"NautilusViewClient",
sizeof (NautilusViewClient),
sizeof (NautilusViewClientClass),
(GtkClassInitFunc) nautilus_view_client_class_init,
(GtkObjectInitFunc) nautilus_view_client_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
view_client_type = gtk_type_unique (gtk_bin_get_type(), &view_client_info);
}
return view_client_type;
}
#if 0
typedef void (*GtkSignal_NONE__BOXED_OBJECT_BOXED) (GtkObject * object,
gpointer arg1,
GtkObject *arg2,
gpointer arg3,
gpointer user_data);
static void
gtk_marshal_NONE__BOXED_OBJECT_BOXED (GtkObject * object,
GtkSignalFunc func,
gpointer func_data,
GtkArg * args)
{
GtkSignal_NONE__BOXED_OBJECT_BOXED rfunc;
rfunc = (GtkSignal_NONE__BOXED_OBJECT_BOXED) func;
(*rfunc) (object,
GTK_VALUE_BOXED (args[0]),
GTK_VALUE_OBJECT (args[1]),
GTK_VALUE_BOXED (args[2]),
func_data);
}
#endif
static void
nautilus_view_client_class_init (NautilusViewClientClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
int i;
object_class = (GtkObjectClass*) klass;
object_class->destroy = (void (*)(GtkObject*))nautilus_view_client_destroy;
object_class->set_arg = nautilus_view_client_set_arg;
object_class->get_arg = nautilus_view_client_get_arg;
widget_class = (GtkWidgetClass*) klass;
widget_class->size_request = nautilus_view_client_size_request;
widget_class->size_allocate = nautilus_view_client_size_allocate;
klass->notify_location_change = NULL;
klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type));
klass->servant_init_func = POA_Nautilus_View__init;
klass->servant_destroy_func = POA_Nautilus_View__fini;
klass->vepv = &impl_Nautilus_View_vepv;
i = 0;
klass->view_client_signals[i++] = gtk_signal_new("notify_location_change",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_location_change),
gtk_marshal_NONE__BOXED,
GTK_TYPE_NONE, 1, GTK_TYPE_BOXED);
klass->view_client_signals[i++] = gtk_signal_new("load_state",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusViewClientClass, load_state),
gtk_marshal_NONE__STRING,
GTK_TYPE_NONE, 1, GTK_TYPE_STRING);
klass->view_client_signals[i++] = gtk_signal_new("save_state",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusViewClientClass, save_state),
gtk_marshal_NONE__STRING,
GTK_TYPE_NONE, 1, GTK_TYPE_STRING);
klass->view_client_signals[i++] = gtk_signal_new("show_properties",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusViewClientClass, show_properties),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
klass->view_client_signals[i++] = gtk_signal_new("notify_selection_change",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusViewClientClass, notify_selection_change),
gtk_marshal_NONE__BOXED,
GTK_TYPE_NONE, 1, GTK_TYPE_BOXED);
klass->view_client_signals[i++] = gtk_signal_new("stop_location_change",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusViewClientClass, stop_location_change),
gtk_marshal_NONE__BOXED,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, klass->view_client_signals, i);
}
static void
nautilus_view_client_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
}
static void
nautilus_view_client_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
}
static void
nautilus_view_client_init (NautilusViewClient *view)
{
CORBA_Environment ev;
GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW);
view->control = GNOME_OBJECT(gnome_control_new(GTK_WIDGET(view)));
CORBA_exception_init(&ev);
view->view_client = impl_Nautilus_View__create(view, &ev);
gnome_object_add_interface(view->control, view->view_client);
CORBA_exception_free(&ev);
}
static void
nautilus_view_client_destroy (NautilusViewClient *view)
{
NautilusViewClientClass *klass = NAUTILUS_VIEW_CLIENT_CLASS(GTK_OBJECT(view)->klass);
gnome_object_destroy(view->view_client);
gnome_object_destroy(view->control);
if(((GtkObjectClass *)klass->parent_class)->destroy)
((GtkObjectClass *)klass->parent_class)->destroy((GtkObject *)view);
}
void
nautilus_view_client_request_location_change(NautilusViewClient *view,
Nautilus_NavigationRequestInfo *loc)
{
CORBA_Environment ev;
g_return_if_fail (view != NULL);
g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view));
CORBA_exception_init(&ev);
if(CORBA_Object_is_nil(view->view_frame, &ev))
view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)),
"IDL:Nautilus/ViewFrame:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
view->view_frame = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(view->view_frame, &ev))
return;
Nautilus_ViewFrame_request_location_change(view->view_frame, loc, &ev);
if(ev._major != CORBA_NO_EXCEPTION)
{
CORBA_Object_release(view->view_frame, &ev);
view->view_frame = CORBA_OBJECT_NIL;
}
CORBA_exception_free(&ev);
}
void
nautilus_view_client_request_selection_change (NautilusViewClient *view,
Nautilus_SelectionRequestInfo *loc)
{
CORBA_Environment ev;
g_return_if_fail (view != NULL);
g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view));
CORBA_exception_init(&ev);
if(CORBA_Object_is_nil(view->view_frame, &ev))
view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)),
"IDL:Nautilus/ViewFrame:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
view->view_frame = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(view->view_frame, &ev))
return;
Nautilus_ViewFrame_request_selection_change(view->view_frame, loc, &ev);
if(ev._major != CORBA_NO_EXCEPTION)
{
CORBA_Object_release(view->view_frame, &ev);
view->view_frame = CORBA_OBJECT_NIL;
}
CORBA_exception_free(&ev);
}
void
nautilus_view_client_request_status_change (NautilusViewClient *view,
Nautilus_StatusRequestInfo *loc)
{
CORBA_Environment ev;
g_return_if_fail (view != NULL);
g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view));
CORBA_exception_init(&ev);
if(CORBA_Object_is_nil(view->view_frame, &ev))
view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)),
"IDL:Nautilus/ViewFrame:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
view->view_frame = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(view->view_frame, &ev))
return;
Nautilus_ViewFrame_request_status_change(view->view_frame, loc, &ev);
if(ev._major != CORBA_NO_EXCEPTION)
{
CORBA_Object_release(view->view_frame, &ev);
view->view_frame = CORBA_OBJECT_NIL;
}
CORBA_exception_free(&ev);
}
void
nautilus_view_client_request_progress_change(NautilusViewClient *view,
Nautilus_ProgressRequestInfo *loc)
{
CORBA_Environment ev;
g_return_if_fail (view != NULL);
g_return_if_fail (NAUTILUS_IS_VIEW_CLIENT (view));
CORBA_exception_init(&ev);
if(CORBA_Object_is_nil(view->view_frame, &ev))
view->view_frame = GNOME_Unknown_query_interface(gnome_control_get_control_frame(GNOME_CONTROL(view->control)),
"IDL:Nautilus/ViewFrame:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
view->view_frame = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(view->view_frame, &ev))
return;
Nautilus_ViewFrame_request_progress_change(view->view_frame, loc, &ev);
if(ev._major != CORBA_NO_EXCEPTION)
{
CORBA_Object_release(view->view_frame, &ev);
view->view_frame = CORBA_OBJECT_NIL;
}
CORBA_exception_free(&ev);
}
static void
nautilus_view_client_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkBin *bin;
bin = GTK_BIN (widget);
requisition->width = 0;
requisition->height = 0;
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
GtkRequisition child_requisition;
gtk_widget_size_request (bin->child, &child_requisition);
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
}
static void
nautilus_view_client_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkBin *bin;
GtkAllocation child_allocation;
widget->allocation = child_allocation = *allocation;
bin = GTK_BIN (widget);
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
gtk_widget_size_allocate (bin->child, &child_allocation);
}
GnomeObject *
nautilus_view_client_get_gnome_object (NautilusViewClient *view)
{
return view->control;
}
|