summaryrefslogtreecommitdiff
path: root/components/adapter/nautilus-zoomable-proxy.c
blob: a57aeb02edda3f14a856986936191e2fcab60cd3 (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 *  Copyright (C) 2000 Eazel, Inc.
 *                2000 SuSE GmbH.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Authors: Maciej Stachowiak <mjs@eazel.com>
 *           Martin Baulig <baulig@suse.de>
 *
 */

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

#undef ZOOMABLE_DEBUG

static BonoboObjectClass		*nautilus_zoomable_proxy_parent_class;

struct _NautilusZoomableProxyPrivate {
	Bonobo_Zoomable remote_zoomable;
};

static inline NautilusZoomableProxy *
nautilus_zoomable_proxy_from_servant (PortableServer_Servant servant)
{
	g_assert (NAUTILUS_IS_ZOOMABLE_PROXY (bonobo_object_from_servant (servant)));

	return NAUTILUS_ZOOMABLE_PROXY (bonobo_object_from_servant (servant));
}

static CORBA_float
impl_Nautilus_ZoomableProxy__get_level (PortableServer_Servant  servant,
					CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_level (proxy->priv->remote_zoomable, ev);
}

static CORBA_float
impl_Nautilus_ZoomableProxy__get_minLevel (PortableServer_Servant  servant,
					   CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_minLevel (proxy->priv->remote_zoomable, ev);
}

static CORBA_float
impl_Nautilus_ZoomableProxy__get_maxLevel (PortableServer_Servant  servant,
					   CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_maxLevel (proxy->priv->remote_zoomable, ev);
}

static CORBA_boolean
impl_Nautilus_ZoomableProxy__get_hasMinLevel (PortableServer_Servant  servant,
					      CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_hasMinLevel (proxy->priv->remote_zoomable, ev);
}

static CORBA_boolean
impl_Nautilus_ZoomableProxy__get_hasMaxLevel (PortableServer_Servant  servant,
					      CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_hasMaxLevel (proxy->priv->remote_zoomable, ev);
}

static CORBA_boolean
impl_Nautilus_ZoomableProxy__get_isContinuous (PortableServer_Servant  servant,
					       CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_isContinuous (proxy->priv->remote_zoomable, ev);
}

static Bonobo_ZoomLevelList *
impl_Nautilus_ZoomableProxy__get_preferredLevels (PortableServer_Servant  servant,
						  CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_preferredLevels (proxy->priv->remote_zoomable, ev);
}

static Bonobo_ZoomLevelNameList *
impl_Nautilus_ZoomableProxy__get_preferredLevelNames (PortableServer_Servant  servant,
						      CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	return Bonobo_Zoomable__get_preferredLevelNames (proxy->priv->remote_zoomable, ev);
}

static void 
impl_Nautilus_ZoomableProxy_setLevel (PortableServer_Servant  servant,
				      const CORBA_float       zoom_level,
				      CORBA_Environment      *ev)
{
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	Bonobo_Zoomable_setLevel (proxy->priv->remote_zoomable, zoom_level, ev);
}

static void
impl_Nautilus_ZoomableProxy_zoomIn (PortableServer_Servant  servant,
				    CORBA_Environment      *ev)
{	
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	Bonobo_Zoomable_zoomIn (proxy->priv->remote_zoomable, ev);
}

static void
impl_Nautilus_ZoomableProxy_zoomOut (PortableServer_Servant  servant,
				     CORBA_Environment      *ev)
{	
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	Bonobo_Zoomable_zoomOut (proxy->priv->remote_zoomable, ev);
}

static void
impl_Nautilus_ZoomableProxy_zoomFit (PortableServer_Servant  servant,
				     CORBA_Environment      *ev)
{	
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	Bonobo_Zoomable_zoomFit (proxy->priv->remote_zoomable, ev);
}

static void
impl_Nautilus_ZoomableProxy_zoomDefault (PortableServer_Servant  servant,
					 CORBA_Environment      *ev)
{	
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	Bonobo_Zoomable_zoomDefault (proxy->priv->remote_zoomable, ev);
}

static void
impl_Nautilus_ZoomableProxy_setFrame (PortableServer_Servant  servant,
				      Bonobo_ZoomableFrame    zoomable_frame,
				      CORBA_Environment      *ev)
{	
	NautilusZoomableProxy *proxy;

	proxy = nautilus_zoomable_proxy_from_servant (servant);
	Bonobo_Zoomable_setFrame (proxy->priv->remote_zoomable, zoomable_frame, ev);

	Bonobo_ZoomableFrame_onParametersChanged (zoomable_frame, ev);
}


static void
nautilus_zoomable_proxy_init_epv (POA_Bonobo_Zoomable__epv *epv)
{
	epv->_get_level = impl_Nautilus_ZoomableProxy__get_level;
	epv->_get_minLevel = impl_Nautilus_ZoomableProxy__get_minLevel;
	epv->_get_maxLevel = impl_Nautilus_ZoomableProxy__get_maxLevel;
	epv->_get_hasMinLevel = impl_Nautilus_ZoomableProxy__get_hasMinLevel;
	epv->_get_hasMaxLevel = impl_Nautilus_ZoomableProxy__get_hasMaxLevel;
	epv->_get_isContinuous = impl_Nautilus_ZoomableProxy__get_isContinuous;
	epv->_get_preferredLevels = impl_Nautilus_ZoomableProxy__get_preferredLevels;
	epv->_get_preferredLevelNames = impl_Nautilus_ZoomableProxy__get_preferredLevelNames;

	epv->zoomIn      = impl_Nautilus_ZoomableProxy_zoomIn;
	epv->zoomOut     = impl_Nautilus_ZoomableProxy_zoomOut;
	epv->zoomFit     = impl_Nautilus_ZoomableProxy_zoomFit;
	epv->zoomDefault = impl_Nautilus_ZoomableProxy_zoomDefault;

	epv->setLevel = impl_Nautilus_ZoomableProxy_setLevel;
	epv->setFrame = impl_Nautilus_ZoomableProxy_setFrame;
}

static void
nautilus_zoomable_proxy_destroy (BonoboObject *object)
{
	NautilusZoomableProxy *proxy;

	g_return_if_fail (object != NULL);
	g_return_if_fail (NAUTILUS_IS_ZOOMABLE_PROXY (object));

	proxy = NAUTILUS_ZOOMABLE_PROXY (object);

	if (proxy->priv->remote_zoomable != CORBA_OBJECT_NIL)
		bonobo_object_release_unref (proxy->priv->remote_zoomable, NULL);
	proxy->priv->remote_zoomable = CORBA_OBJECT_NIL;

	BONOBO_OBJECT_CLASS (nautilus_zoomable_proxy_parent_class)->destroy (BONOBO_OBJECT (object));
}

static void
nautilus_zoomable_proxy_finalize (GObject *object)
{
	NautilusZoomableProxy *proxy;

	g_return_if_fail (object != NULL);
	g_return_if_fail (NAUTILUS_IS_ZOOMABLE_PROXY (object));

	proxy = NAUTILUS_ZOOMABLE_PROXY (object);

	g_free (proxy->priv);
	proxy->priv = NULL;

	G_OBJECT_CLASS (nautilus_zoomable_proxy_parent_class)->finalize (object);
}

static void
nautilus_zoomable_proxy_class_init (NautilusZoomableProxyClass *klass)
{
	GObjectClass *object_class;
	BonoboObjectClass *bonobo_object_class;

	object_class = (GObjectClass *) klass;
	bonobo_object_class = (BonoboObjectClass *)klass;
	
	nautilus_zoomable_proxy_parent_class = 
		g_type_class_peek_parent (klass);
	
	bonobo_object_class->destroy = nautilus_zoomable_proxy_destroy;
	object_class->finalize = nautilus_zoomable_proxy_finalize;

	nautilus_zoomable_proxy_init_epv (&klass->epv);
}

static void
nautilus_zoomable_proxy_init (NautilusZoomableProxy *proxy)
{
	proxy->priv = g_new0 (NautilusZoomableProxyPrivate, 1);
}

/**
 * nautilus_zoomable_proxy_get_type:
 *
 * Returns: the GType for a NautilusZoomableProxy object.
 */
GType
nautilus_zoomable_proxy_get_type (void)
{
	static GType type = 0;

	if (!type) {
		GTypeInfo info = {
			sizeof (NautilusZoomableProxyClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) nautilus_zoomable_proxy_class_init,
			NULL, /* class_finalize */
			NULL, /* class_data */
			sizeof (NautilusZoomableProxy),
			0, /* n_preallocs */
			(GInstanceInitFunc) nautilus_zoomable_proxy_init
		};

		type = bonobo_type_unique 
			(BONOBO_TYPE_OBJECT,
			 POA_Bonobo_Zoomable__init, NULL, 
			 G_STRUCT_OFFSET (NautilusZoomableProxyClass, epv),
			 &info, "NautilusZoomableProxy");
	}

	return type;
}

BonoboObject *
nautilus_zoomable_proxy_get (Bonobo_Zoomable remote_zoomable)
{
	NautilusZoomableProxy *proxy;

	g_return_val_if_fail (remote_zoomable != CORBA_OBJECT_NIL, NULL);

	proxy = g_object_new (nautilus_zoomable_proxy_get_type (), NULL);

	proxy->priv->remote_zoomable = bonobo_object_dup_ref (remote_zoomable, NULL);

	return BONOBO_OBJECT (proxy);
}