source: trunk/third/bonobo/bonobo/bonobo-view.c @ 16754

Revision 16754, 7.8 KB checked in by ghudson, 23 years ago (diff)
Merge with bonobo 1.0.14; remove ATHTOOLROOT support.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/**
3 * bonobo-view.c: a view object of an embeddable
4 *
5 * Authors:
6 *   Miguel de Icaza (miguel@kernel.org)
7 *   Nat Friedman    (nat@nat.org)
8 *
9 * Copyright 1999 Helix Code, Inc.
10 */
11#include <config.h>
12#include <gtk/gtksignal.h>
13#include <gtk/gtkmarshal.h>
14#include <gtk/gtkplug.h>
15#include <bonobo/bonobo-exception.h>
16#include <bonobo/bonobo-main.h>
17#include <bonobo/bonobo-view.h>
18#include <gdk/gdkprivate.h>
19
20#define PARENT_TYPE bonobo_control_get_type ()
21
22/* Parent object class in GTK hierarchy */
23static BonoboControlClass *bonobo_view_parent_class;
24
25enum {
26        VIEW_UNDO_LAST_OPERATION,
27        SET_ZOOM_FACTOR,
28        LAST_SIGNAL
29};
30
31static guint view_signals [LAST_SIGNAL];
32
33typedef void (*GnomeSignal_NONE__DOUBLE) (GtkObject *object, double arg1, gpointer user_data);
34
35struct _BonoboViewPrivate {
36        int placeholder;
37};
38
39static void
40impl_Bonobo_View_setZoomFactor (PortableServer_Servant servant,
41                                const CORBA_double zoom,
42                                CORBA_Environment *ev)
43{
44        BonoboView *view = BONOBO_VIEW (bonobo_object_from_servant (servant));
45
46        gtk_signal_emit (GTK_OBJECT (view),
47                         view_signals [SET_ZOOM_FACTOR], zoom);
48}
49
50#if 0
51/**
52 * bonobo_view_activate:
53 * @view:
54 * @activate:
55 *
56 *   A basic default handler so we can at least
57 * get focus in a development component; 95% of these
58 * will override this to merge menus for them.
59 **/
60static void
61bonobo_view_activate (BonoboView *view, gboolean activate, gpointer user_data)
62{
63        bonobo_view_activate_notify (view, activate);
64}
65#endif
66
67/**
68 * bonobo_view_construct:
69 * @view: The BonoboView object to be initialized.
70 * @corba_view: The CORBA Bonobo_View interface for the new BonoboView object.
71 * @widget: A GtkWidget contains the view and * will be passed to the container
72 * process's ViewFrame object.
73 *
74 * @item_creator might be NULL for widget-based views.
75 *
76 * Returns: the intialized BonoboView object.
77 */
78BonoboView *
79bonobo_view_construct (BonoboView *view, GtkWidget *widget)
80{
81        g_return_val_if_fail (BONOBO_IS_VIEW (view), NULL);
82        g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
83       
84        bonobo_control_construct (BONOBO_CONTROL (view), widget);
85
86/*      gtk_signal_connect (GTK_OBJECT (view), "view_activate",
87                            GTK_SIGNAL_FUNC (bonobo_view_activate),
88                            NULL);*/
89        return view;
90}
91
92/**
93 * bonobo_view_new:
94 * @widget: a GTK widget that contains the view and will be passed to the
95 * container process.
96 *
97 * This function creates a new BonoboView object for @widget
98 *
99 * Returns: a BonoboView object that implements the Bonobo::View CORBA
100 * service that will transfer the @widget to the container process.
101 */
102BonoboView *
103bonobo_view_new (GtkWidget *widget)
104{
105        BonoboView *view;
106       
107        g_return_val_if_fail (widget != NULL, NULL);
108        g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
109
110        view = gtk_type_new (bonobo_view_get_type ());
111       
112        return bonobo_view_construct (view, widget);
113}
114
115static void
116bonobo_view_destroy (GtkObject *object)
117{
118        BonoboView *view;
119
120        g_return_if_fail (object != NULL);
121        g_return_if_fail (BONOBO_IS_VIEW (object));
122       
123        view = BONOBO_VIEW (object);
124
125        g_free (view->priv);
126       
127        bonobo_object_unref (BONOBO_OBJECT (view->embeddable));
128
129        GTK_OBJECT_CLASS (bonobo_view_parent_class)->destroy (object);
130}
131
132static void
133gnome_marshal_NONE__DOUBLE (GtkObject * object,
134                            GtkSignalFunc func,
135                            gpointer func_data,
136                            GtkArg * args)
137{
138        GnomeSignal_NONE__DOUBLE rfunc;
139        rfunc = (GnomeSignal_NONE__DOUBLE) func;
140        (*rfunc) (object,
141                  GTK_VALUE_DOUBLE (args[0]),
142                  func_data);
143}
144
145static void
146bonobo_view_class_init (BonoboViewClass *klass)
147{
148        GtkObjectClass *object_class = (GtkObjectClass *) klass;
149        POA_Bonobo_View__epv *epv = &klass->epv;
150
151        bonobo_view_parent_class = gtk_type_class (PARENT_TYPE);
152
153        view_signals [SET_ZOOM_FACTOR] =
154                gtk_signal_new ("set_zoom_factor",
155                                GTK_RUN_LAST,
156                                object_class->type,
157                                GTK_SIGNAL_OFFSET (BonoboViewClass, set_zoom_factor),
158                                gnome_marshal_NONE__DOUBLE,
159                                GTK_TYPE_NONE, 1,
160                                GTK_TYPE_DOUBLE);
161
162        gtk_object_class_add_signals (object_class, view_signals, LAST_SIGNAL);
163
164        object_class->destroy = bonobo_view_destroy;
165
166        epv->setZoomFactor = impl_Bonobo_View_setZoomFactor;
167}
168
169static void
170bonobo_view_init (BonoboView *view)
171{
172        view->priv = g_new0 (BonoboViewPrivate, 1);
173}
174
175BONOBO_X_TYPE_FUNC_FULL (BonoboView,
176                           Bonobo_View,
177                           PARENT_TYPE,
178                           bonobo_view)
179
180/**
181 * bonobo_view_set_embeddable:
182 * @view: A BonoboView object.
183 * @embeddable: The BonoboEmbeddable object for which @view is a view.
184 *
185 * This function associates @view with the specified GnomeEmbeddabe
186 * object, @embeddable.
187 */
188void
189bonobo_view_set_embeddable (BonoboView *view, BonoboEmbeddable *embeddable)
190{
191        g_return_if_fail (view != NULL);
192        g_return_if_fail (BONOBO_IS_VIEW (view));
193        g_return_if_fail (embeddable != NULL);
194        g_return_if_fail (BONOBO_IS_EMBEDDABLE (embeddable));
195
196        if (view->embeddable != NULL)
197                bonobo_object_unref (BONOBO_OBJECT (view->embeddable));
198
199        view->embeddable = embeddable;
200        bonobo_object_ref (BONOBO_OBJECT (view->embeddable));
201}
202
203/**
204 * bonobo_view_get_embeddable:
205 * @view: A BonoboView object.
206 *
207 * Returns: The BonoboEmbeddable object for which @view is a BonoboView.
208 */
209BonoboEmbeddable *
210bonobo_view_get_embeddable (BonoboView *view)
211{
212        g_return_val_if_fail (view != NULL, NULL);
213        g_return_val_if_fail (BONOBO_IS_VIEW (view), NULL);
214
215        return view->embeddable;
216}
217
218/**
219 * bonobo_view_set_view_frame:
220 * @view: A BonoboView object.
221 * @view_frame: A CORBA interface for the ViewFrame which contains this View.
222 *
223 * Sets the ViewFrame for @view to @view_frame.
224 */
225void
226bonobo_view_set_view_frame (BonoboView *view, Bonobo_ViewFrame view_frame)
227{
228        g_return_if_fail (view != NULL);
229        g_return_if_fail (BONOBO_IS_VIEW (view));
230       
231        bonobo_control_set_control_frame (BONOBO_CONTROL (view), (Bonobo_ControlFrame) view_frame);
232
233        view->view_frame = view_frame;
234}
235
236/**
237 * bonobo_view_get_view_frame:
238 * @view: A BonoboView object whose Bonobo_ViewFrame CORBA interface is
239 * being retrieved.
240 *
241 * Returns: The Bonobo_ViewFrame CORBA object associated with @view, this is
242 * a CORBA_object_duplicated object.  You need to CORBA_free it when you are
243 * done with it.
244 */
245Bonobo_ViewFrame
246bonobo_view_get_view_frame (BonoboView *view)
247
248{
249        g_return_val_if_fail (view != NULL, CORBA_OBJECT_NIL);
250        g_return_val_if_fail (BONOBO_IS_VIEW (view), CORBA_OBJECT_NIL);
251       
252        return view->view_frame;
253}
254
255/**
256 * bonobo_view_get_ui_component:
257 * @view: A BonoboView object for which a BonoboUIComponent has been created and set.
258 *
259 * Returns: The BonoboUIComponent which was associated with @view when it was created.
260 */
261BonoboUIComponent *
262bonobo_view_get_ui_component (BonoboView *view)
263{
264        g_return_val_if_fail (view != NULL, NULL);
265        g_return_val_if_fail (BONOBO_IS_VIEW (view), NULL);
266
267        return bonobo_control_get_ui_component (BONOBO_CONTROL (view));
268}
269
270/**
271 * bonobo_view_get_remote_ui_container
272 * @view: A BonoboView object which is bound to a remote BonoboViewFrame.
273 *
274 * Returns: The Bonobo_UIContainer CORBA server for the remote BonoboViewFrame.
275 */
276Bonobo_UIContainer
277bonobo_view_get_remote_ui_container (BonoboView *view)
278{
279        g_return_val_if_fail (view != NULL, CORBA_OBJECT_NIL);
280        g_return_val_if_fail (BONOBO_IS_VIEW (view), CORBA_OBJECT_NIL);
281
282        return bonobo_control_get_remote_ui_container (BONOBO_CONTROL (view));
283}
284
285/**
286 * bonobo_view_activate_notify:
287 * @view: A BonoboView object which is bound to a remote BonoboViewFrame..
288 * @activate: %TRUE if the view is activated, %FALSE otherwise.
289 *
290 * This function notifies @view's remote ViewFrame that the activation
291 * state of @view has changed.
292 */
293void
294bonobo_view_activate_notify (BonoboView *view, gboolean activated)
295{
296        g_return_if_fail (view != NULL);
297        g_return_if_fail (BONOBO_IS_VIEW (view));
298
299        bonobo_control_activate_notify (BONOBO_CONTROL (view), activated);
300}
Note: See TracBrowser for help on using the repository browser.