summaryrefslogtreecommitdiff
path: root/libnautilus/nautilus-zoomable.c
blob: 88592c398b381a90b175b30a72fb8f5e28a7e34a (plain)
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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *  libnautilus: A library for nautilus view implementations.
 *
 *  Copyright (C) 2000 Eazel, 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: Maciej Stachowiak <mjs@eazel.com>
 *
 */

/* nautilus-zoomable.c */

#include <config.h>
#include "nautilus-zoomable.h"

#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <gtk/gtksignal.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-control.h>

NautilusZoomable *foo;

struct NautilusZoomableDetails {
	BonoboControl *control;
	
	double zoom_level;
	double min_zoom_level;
	double max_zoom_level;
	gboolean is_continuous;

	Nautilus_ZoomLevel *preferred_zoom_levels;
	int num_preferred_zoom_levels;
	
	Nautilus_ZoomableFrame zoomable_frame;
};

enum {
	SET_ZOOM_LEVEL,
	ZOOM_IN,
	ZOOM_OUT,
	ZOOM_TO_FIT,
	LAST_SIGNAL
};

enum {
	ARG_0,
	ARG_BONOBO_CONTROL,
	ARG_MIN_ZOOM_LEVEL,
	ARG_MAX_ZOOM_LEVEL,
	ARG_IS_CONTINUOUS,
	ARG_PREFERRED_ZOOM_LEVELS,
	ARG_NUM_PREFERRED_ZOOM_LEVELS,
};

static guint signals[LAST_SIGNAL];

typedef struct {
	POA_Nautilus_Zoomable servant;
	gpointer bonobo_object;
	
	NautilusZoomable *gtk_object;
} impl_POA_Nautilus_Zoomable;


void                 nautilus_zoomable_real_set_bonobo_control  (NautilusZoomable           *view,
								 BonoboControl              *bonobo_control);
static CORBA_float  impl_Nautilus_Zoomable__get_zoom_level     (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static void          impl_Nautilus_Zoomable__set_zoom_level     (PortableServer_Servant      servant,
								 const CORBA_float           zoom_level,
								 CORBA_Environment          *ev);
static CORBA_float  impl_Nautilus_Zoomable__get_min_zoom_level (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static CORBA_float  impl_Nautilus_Zoomable__get_max_zoom_level (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static CORBA_boolean impl_Nautilus_Zoomable__get_is_continuous (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static Nautilus_ZoomLevelList* impl_Nautilus_Zoomable__get_preferred_zoom_level_list
							        (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static void          impl_Nautilus_Zoomable_zoom_in             (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static void          impl_Nautilus_Zoomable_zoom_out            (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);
static void          impl_Nautilus_Zoomable_zoom_to_fit         (PortableServer_Servant      servant,
								 CORBA_Environment          *ev);

POA_Nautilus_Zoomable__epv libnautilus_Nautilus_Zoomable_epv =
{
	NULL,			/* _private */
	&impl_Nautilus_Zoomable__get_zoom_level,
	&impl_Nautilus_Zoomable__set_zoom_level,
	&impl_Nautilus_Zoomable__get_min_zoom_level,
	&impl_Nautilus_Zoomable__get_max_zoom_level,
	&impl_Nautilus_Zoomable__get_is_continuous,
	&impl_Nautilus_Zoomable__get_preferred_zoom_level_list,
	&impl_Nautilus_Zoomable_zoom_in,
	&impl_Nautilus_Zoomable_zoom_out,
	&impl_Nautilus_Zoomable_zoom_to_fit
};

/* static PortableServer_ServantBase__epv base_epv; */
static POA_Nautilus_Zoomable__vepv impl_Nautilus_Zoomable_vepv =
{
/*	&base_epv, */
	NULL,
	NULL,
	&libnautilus_Nautilus_Zoomable_epv
};


GList *
nautilus_g_list_from_ZoomLevelList (const Nautilus_ZoomLevelList *zoom_level_list)
{
	GList *list;
	int i;
	double *zoom_level_ptr;

	list = NULL;
	for (i = 0; i < zoom_level_list->_length; ++i) {
		zoom_level_ptr = g_new (double, 1);
		*zoom_level_ptr = zoom_level_list->_buffer[i];
		list = g_list_prepend (list, zoom_level_ptr);
	}
	return g_list_reverse (list);
}

static Nautilus_ZoomLevel *
nautilus_ZoomLevelListBuffer_from_zoom_levels (const double *zoom_levels, int num_levels)
{
	int i;
	Nautilus_ZoomLevel *buffer;

	buffer = CORBA_sequence_Nautilus_ZoomLevel_allocbuf (num_levels);
	
	for (i = 0; i < num_levels; ++i) {
		buffer[i] = zoom_levels[i];
	}

	return buffer;
}

static CORBA_float
impl_Nautilus_Zoomable__get_zoom_level (PortableServer_Servant      servant,
					CORBA_Environment          *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	return zoomable->gtk_object->details->zoom_level;
}

static void 
impl_Nautilus_Zoomable__set_zoom_level (PortableServer_Servant      servant,
					const CORBA_float          zoom_level,
					CORBA_Environment          *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	gtk_signal_emit (GTK_OBJECT (zoomable->gtk_object), signals[SET_ZOOM_LEVEL], zoom_level);
	
}

static CORBA_float
impl_Nautilus_Zoomable__get_min_zoom_level (PortableServer_Servant      servant,
					    CORBA_Environment      *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	return zoomable->gtk_object->details->min_zoom_level;
}

static CORBA_float
impl_Nautilus_Zoomable__get_max_zoom_level (PortableServer_Servant      servant,
					    CORBA_Environment      *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	return zoomable->gtk_object->details->max_zoom_level;
}

static CORBA_boolean
impl_Nautilus_Zoomable__get_is_continuous (PortableServer_Servant      servant,
					   CORBA_Environment      *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	return zoomable->gtk_object->details->is_continuous;
}

static Nautilus_ZoomLevelList *
impl_Nautilus_Zoomable__get_preferred_zoom_level_list (PortableServer_Servant      servant,
					    		  CORBA_Environment      *ev)
{
	Nautilus_ZoomLevelList *list;
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	list = Nautilus_ZoomLevelList__alloc ();
	list->_maximum = zoomable->gtk_object->details->num_preferred_zoom_levels;
	list->_length = zoomable->gtk_object->details->num_preferred_zoom_levels;
	list->_buffer = zoomable->gtk_object->details->preferred_zoom_levels;
	
	/*  set_release defaults to FALSE - CORBA_sequence_set_release (list, FALSE) */ 

	return list;
}

static void
impl_Nautilus_Zoomable_zoom_in (PortableServer_Servant      servant,
				CORBA_Environment          *ev)
{	
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	gtk_signal_emit (GTK_OBJECT (zoomable->gtk_object), signals[ZOOM_IN]);
}

static void
impl_Nautilus_Zoomable_zoom_out (PortableServer_Servant      servant,
				 CORBA_Environment *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	gtk_signal_emit (GTK_OBJECT (zoomable->gtk_object), signals[ZOOM_OUT]);
}

static void
impl_Nautilus_Zoomable_zoom_to_fit (PortableServer_Servant      servant,
				    CORBA_Environment *ev)
{
	impl_POA_Nautilus_Zoomable *zoomable;

	zoomable = (impl_POA_Nautilus_Zoomable *)servant;

	gtk_signal_emit (GTK_OBJECT (zoomable->gtk_object), signals[ZOOM_TO_FIT]);
}

static void
impl_Nautilus_Zoomable__destroy (BonoboObject *obj,
				 PortableServer_Servant      servant)
{
	PortableServer_ObjectId *objid;
	CORBA_Environment ev;
	
	CORBA_exception_init(&ev);
	
	objid = PortableServer_POA_servant_to_id (bonobo_poa (), servant, &ev);
	PortableServer_POA_deactivate_object (bonobo_poa (), objid, &ev);
	CORBA_free (objid);
	obj->servant = NULL;
	
	POA_Nautilus_Zoomable__fini (servant, &ev);
	g_free (servant);
	CORBA_exception_free(&ev);
}

static Nautilus_Zoomable
impl_Nautilus_Zoomable__create (NautilusZoomable *zoomable, CORBA_Environment * ev)
{
	Nautilus_Zoomable retval;
	impl_POA_Nautilus_Zoomable *servant;
	
	NautilusZoomableClass *zoomable_class = NAUTILUS_ZOOMABLE_CLASS (GTK_OBJECT(zoomable)->klass);
	
	servant = g_new0 (impl_POA_Nautilus_Zoomable, 1);
	servant->servant.vepv = zoomable_class->vepv;
	if (!servant->servant.vepv->Bonobo_Unknown_epv)
		servant->servant.vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
	POA_Nautilus_Zoomable__init ((PortableServer_Servant) servant, ev);
	
	servant->gtk_object = zoomable;
	
	retval = bonobo_object_activate_servant (BONOBO_OBJECT (zoomable), servant);
	
	gtk_signal_connect (GTK_OBJECT (zoomable), "destroy", impl_Nautilus_Zoomable__destroy, servant);
	
	return retval;
}

static void nautilus_zoomable_initialize_class (NautilusZoomableClass *klass);
static void nautilus_zoomable_initialize       (NautilusZoomable      *zoomable);
static void nautilus_zoomable_destroy          (NautilusZoomable      *view);
static void nautilus_zoomable_set_arg          (GtkObject             *object,
						GtkArg                *arg,
						guint                  arg_id);
static void nautilus_zoomable_get_arg          (GtkObject             *object,
						GtkArg                *arg,
						guint                  arg_id);

NAUTILUS_DEFINE_CLASS_BOILERPLATE(NautilusZoomable, nautilus_zoomable, BONOBO_OBJECT_TYPE)

/* This would go into nautilus-gtk-extensions.c, but we don't want the dependency. */
static void
marshal_NONE__DOUBLE (GtkObject *object,
		      GtkSignalFunc func,
		      gpointer func_data,
		      GtkArg *args)
{
	(* (void (*)(GtkObject *, double, gpointer)) func)
		(object,
		 GTK_VALUE_DOUBLE (args[0]),
		 func_data);
}

static void
nautilus_zoomable_initialize_class (NautilusZoomableClass *klass)
{
	GtkObjectClass *object_class;
	
	object_class = (GtkObjectClass*) klass;
	object_class->destroy = (void (*)(GtkObject*))nautilus_zoomable_destroy;
	object_class->set_arg = nautilus_zoomable_set_arg;
	object_class->get_arg = nautilus_zoomable_get_arg;
	
	parent_class = gtk_type_class (gtk_type_parent (object_class->type));
	
	klass->vepv = &impl_Nautilus_Zoomable_vepv;
	
	signals[SET_ZOOM_LEVEL] =
		gtk_signal_new ("set_zoom_level",
				GTK_RUN_LAST,
				object_class->type,
				GTK_SIGNAL_OFFSET (NautilusZoomableClass, set_zoom_level),
				marshal_NONE__DOUBLE,
				GTK_TYPE_NONE, 1, GTK_TYPE_DOUBLE);
	signals[ZOOM_IN] = 
		gtk_signal_new ("zoom_in",
				GTK_RUN_LAST,
				object_class->type,
				GTK_SIGNAL_OFFSET (NautilusZoomableClass, zoom_in),
				gtk_marshal_NONE__NONE,
				GTK_TYPE_NONE, 0);
	signals[ZOOM_OUT] = 
		gtk_signal_new ("zoom_out",
				GTK_RUN_LAST,
				object_class->type,
				GTK_SIGNAL_OFFSET (NautilusZoomableClass, zoom_out),
				gtk_marshal_NONE__NONE,
				GTK_TYPE_NONE, 0);
	signals[ZOOM_TO_FIT] = 
		gtk_signal_new ("zoom_to_fit",
				GTK_RUN_LAST,
				object_class->type,
				GTK_SIGNAL_OFFSET (NautilusZoomableClass, zoom_to_fit),
				gtk_marshal_NONE__NONE,
				GTK_TYPE_NONE, 0);

	gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
	
	gtk_object_add_arg_type ("NautilusZoomable::bonobo_control",
				 GTK_TYPE_OBJECT,
				 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT | GTK_ARG_CONSTRUCT_ONLY,
				 ARG_BONOBO_CONTROL);
	gtk_object_add_arg_type ("NautilusZoomable::min_zoom_level",
				 GTK_TYPE_DOUBLE,
				 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT | GTK_ARG_CONSTRUCT_ONLY,
				 ARG_MIN_ZOOM_LEVEL);
	gtk_object_add_arg_type ("NautilusZoomable::max_zoom_level",
				 GTK_TYPE_DOUBLE,
				 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT | GTK_ARG_CONSTRUCT_ONLY,
				 ARG_MAX_ZOOM_LEVEL);
	gtk_object_add_arg_type ("NautilusZoomable::is_continuous",
				 GTK_TYPE_BOOL,
				 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT | GTK_ARG_CONSTRUCT_ONLY,
				 ARG_IS_CONTINUOUS);
	gtk_object_add_arg_type ("NautilusZoomable::preferred_zoom_levels",
				 GTK_TYPE_POINTER,
				 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT | GTK_ARG_CONSTRUCT_ONLY,
				 ARG_PREFERRED_ZOOM_LEVELS);
	gtk_object_add_arg_type ("NautilusZoomable::num_preferred_zoom_levels",
				 GTK_TYPE_INT,
				 GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT | GTK_ARG_CONSTRUCT_ONLY,
				 ARG_NUM_PREFERRED_ZOOM_LEVELS);
}

static void
nautilus_zoomable_set_arg (GtkObject      *object,
			   GtkArg         *arg,
			   guint	   arg_id)
{
	NautilusZoomable *zoomable;
	
	zoomable = NAUTILUS_ZOOMABLE (object);
	
	switch(arg_id) {
	case ARG_BONOBO_CONTROL:
		nautilus_zoomable_real_set_bonobo_control
			(zoomable,
			 BONOBO_CONTROL (GTK_VALUE_OBJECT (*arg)));
		break;
	case ARG_MIN_ZOOM_LEVEL:
		zoomable->details->min_zoom_level = GTK_VALUE_DOUBLE (*arg);
		break;
	case ARG_MAX_ZOOM_LEVEL:
		zoomable->details->max_zoom_level = GTK_VALUE_DOUBLE (*arg);
		break;
	case ARG_IS_CONTINUOUS:
		zoomable->details->is_continuous = GTK_VALUE_BOOL (*arg);
		break;
	case ARG_PREFERRED_ZOOM_LEVELS:
		zoomable->details->preferred_zoom_levels = GTK_VALUE_POINTER (*arg);
		break;
	case ARG_NUM_PREFERRED_ZOOM_LEVELS:
		zoomable->details->num_preferred_zoom_levels = GTK_VALUE_INT (*arg);
		break;
	}
}

static void
nautilus_zoomable_get_arg (GtkObject      *object,
			   GtkArg         *arg,
			   guint	     arg_id)
{
	NautilusZoomable *view;
	
	view = NAUTILUS_ZOOMABLE (object);
	
	switch(arg_id) {
	case ARG_BONOBO_CONTROL:
		GTK_VALUE_OBJECT (*arg) = GTK_OBJECT (nautilus_zoomable_get_bonobo_control (NAUTILUS_ZOOMABLE (object)));
		break;
	case ARG_MIN_ZOOM_LEVEL:
		GTK_VALUE_DOUBLE (*arg) = NAUTILUS_ZOOMABLE (object)->details->min_zoom_level;
		break;
	case ARG_MAX_ZOOM_LEVEL:
		GTK_VALUE_DOUBLE (*arg) = NAUTILUS_ZOOMABLE (object)->details->max_zoom_level;
		break;
	case ARG_IS_CONTINUOUS:
		GTK_VALUE_BOOL (*arg) = NAUTILUS_ZOOMABLE (object)->details->is_continuous;
		break;
	case ARG_PREFERRED_ZOOM_LEVELS:
		GTK_VALUE_POINTER (*arg) = NAUTILUS_ZOOMABLE (object)->details->preferred_zoom_levels;
		break;
	case ARG_NUM_PREFERRED_ZOOM_LEVELS:
		GTK_VALUE_INT (*arg) = NAUTILUS_ZOOMABLE (object)->details->num_preferred_zoom_levels;
		break;
	}
}

static void
nautilus_zoomable_initialize (NautilusZoomable *zoomable)
{
	CORBA_Environment ev;
	CORBA_exception_init(&ev);
	
	zoomable->details = g_new0 (NautilusZoomableDetails, 1);
	
	bonobo_object_construct (BONOBO_OBJECT (zoomable), impl_Nautilus_Zoomable__create (zoomable, &ev));
	
	CORBA_exception_free(&ev);
}

NautilusZoomable *
nautilus_zoomable_new (GtkWidget *widget, 
		       double min_zoom_level, 
		       double max_zoom_level, 
		       gboolean is_continuous,
		       double *preferred_zoom_levels,
		       int num_preferred_zoom_levels)

{
	return nautilus_zoomable_new_from_bonobo_control
		(bonobo_control_new (widget),
		 min_zoom_level, 
		 max_zoom_level,
		 is_continuous,
		 preferred_zoom_levels,
		 num_preferred_zoom_levels);
}

NautilusZoomable *
nautilus_zoomable_new_from_bonobo_control (BonoboControl *bonobo_control,
					   double min_zoom_level, 
					   double max_zoom_level, 
					   gboolean is_continuous,
					   double *preferred_zoom_levels,
					   int	num_preferred_zoom_levels)
{
	NautilusZoomable *zoomable;
	
	zoomable = NAUTILUS_ZOOMABLE (gtk_object_new (NAUTILUS_TYPE_ZOOMABLE,
						      "bonobo_control", bonobo_control,
						      "min_zoom_level", min_zoom_level,
						      "max_zoom_level", max_zoom_level,
						      "is_continuous",  is_continuous,
						      "preferred_zoom_levels", nautilus_ZoomLevelListBuffer_from_zoom_levels (preferred_zoom_levels, num_preferred_zoom_levels),
						      "num_preferred_zoom_levels", num_preferred_zoom_levels,
						      NULL));
	
	return zoomable;
}

static void
nautilus_zoomable_destroy (NautilusZoomable *view)
{
	CORBA_free (view->details->preferred_zoom_levels);
	g_free (view->details);
	
	NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, GTK_OBJECT (view));
}

static gboolean
nautilus_zoomable_ensure_zoomable_frame (NautilusZoomable *view)
{
	CORBA_Environment ev;
	
	g_assert (NAUTILUS_IS_ZOOMABLE (view));
	
	CORBA_exception_init (&ev);
	
	if (CORBA_Object_is_nil (view->details->zoomable_frame, &ev)) {
		view->details->zoomable_frame = Bonobo_Unknown_query_interface 
			(bonobo_control_get_control_frame 
			 (BONOBO_CONTROL (nautilus_zoomable_get_bonobo_control (view))),
			 "IDL:Nautilus/ZoomableFrame:1.0", &ev);
		if (ev._major != CORBA_NO_EXCEPTION) {
			view->details->zoomable_frame = CORBA_OBJECT_NIL;
		}
		if (CORBA_Object_is_nil (view->details->zoomable_frame, &ev)) {
			view->details->zoomable_frame = CORBA_OBJECT_NIL;
		}

		/* Don't keep a ref to the frame, because that would be circular. */
		if (view->details->zoomable_frame != CORBA_OBJECT_NIL) {
			Bonobo_Unknown_unref (view->details->zoomable_frame, &ev);
		}
	}
	
	CORBA_exception_free (&ev);

	return view->details->zoomable_frame != CORBA_OBJECT_NIL;
}

void
nautilus_zoomable_set_zoom_level (NautilusZoomable *view,
				  double zoom_level)
{
	CORBA_Environment ev;
	
	g_return_if_fail (NAUTILUS_IS_ZOOMABLE (view));
	
	CORBA_exception_init (&ev);
	
	view->details->zoom_level = zoom_level;
	
	if (nautilus_zoomable_ensure_zoomable_frame (view)) {
		Nautilus_ZoomableFrame_report_zoom_level_changed (view->details->zoomable_frame, zoom_level, &ev);
		if (ev._major != CORBA_NO_EXCEPTION) {
			CORBA_Object_release (view->details->zoomable_frame, &ev);
			view->details->zoomable_frame = CORBA_OBJECT_NIL;
		}
	}
	
	CORBA_exception_free (&ev);
}

BonoboControl *
nautilus_zoomable_get_bonobo_control (NautilusZoomable *view)
{
	return view->details->control;
}

void
nautilus_zoomable_real_set_bonobo_control (NautilusZoomable *view,
					   BonoboControl *bonobo_control)
{
	view->details->control = bonobo_control;
	bonobo_object_add_interface (BONOBO_OBJECT (view), BONOBO_OBJECT (view->details->control));
}