1 /* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView.
2 * Copyright (C) 2003 Luca Padovani <lpadovan@cs.unibo.it>
3 * Pouria Masoudi <pmasoudi@cs.unibo.it>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * For more information, please visit the project's home page
20 * http://helm.cs.unibo.it/gtkmathview-bonobo
21 * or send an email to <lpadovan@cs.unibo.it>
27 #include <gtkmathview.h>
32 static GObjectClass* view_parent_class;
35 view_object_finalize(GObject* object)
37 View* view = VIEW(object);
39 view_parent_class->finalize(object);
44 impl_view_freeze(PortableServer_Servant servant,
45 CORBA_Environment *ev)
47 View* view = VIEW (bonobo_object (servant));
48 gtk_math_view_freeze(view->control_data->math_view);
53 impl_view_thaw(PortableServer_Servant servant,
54 CORBA_Environment *ev)
56 View* view = VIEW (bonobo_object (servant));
57 gtk_math_view_thaw(view->control_data->math_view);
62 impl_view_load(PortableServer_Servant servant,
63 const CORBA_char *uri,
64 CORBA_Environment *ev)
66 View* view = VIEW (bonobo_object (servant));
67 return gtk_math_view_load_uri(view->control_data->math_view, uri);
71 impl_view_unload(PortableServer_Servant servant,
72 CORBA_Environment *ev)
74 View* view = VIEW (bonobo_object (servant));
75 gtk_math_view_unload(view->control_data->math_view);
79 impl_view_setIdAttribute (PortableServer_Servant servant,
81 const CORBA_char *name,
82 CORBA_Environment *ev)
84 View* view = VIEW (bonobo_object (servant));
85 gtk_math_view_control_data_set_id_attribute(view->control_data, ns, name);
89 impl_view_getIdAttribute (PortableServer_Servant servant,
92 CORBA_Environment *ev)
94 View* view = VIEW (bonobo_object (servant));
95 if (view->control_data->id_ns_uri != NULL)
96 *ns = CORBA_string_dup(view->control_data->id_ns_uri->str);
100 if (view->control_data->id_name != NULL)
101 *name = CORBA_string_dup(view->control_data->id_name);
107 impl_view_select(PortableServer_Servant servant,
108 const CORBA_char *id,
109 CORBA_Environment *ev)
111 View* view = VIEW (bonobo_object (servant));
112 GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view);
115 GdomeException exc = 0;
116 GdomeElement* el = find_element_by_id(root,
117 view->control_data->id_ns_uri,
118 view->control_data->id_name,
122 gtk_math_view_select(view->control_data->math_view, el);
123 gdome_el_unref(el, &exc);
126 gdome_el_unref(root, &exc);
132 impl_view_unselect(PortableServer_Servant servant,
133 const CORBA_char *id,
134 CORBA_Environment *ev)
136 View* view = VIEW (bonobo_object (servant));
137 GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view);
140 GdomeException exc = 0;
141 GdomeElement* el = find_element_by_id(root,
142 view->control_data->id_ns_uri,
143 view->control_data->id_name,
147 gtk_math_view_unselect(view->control_data->math_view, el);
148 gdome_el_unref(el, &exc);
151 gdome_el_unref(root, &exc);
157 impl_view_isSelected(PortableServer_Servant servant,
158 const CORBA_char *id,
159 CORBA_Environment *ev)
161 View* view = VIEW (bonobo_object (servant));
162 GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view);
163 CORBA_boolean res = CORBA_FALSE;
166 GdomeException exc = 0;
167 GdomeElement* el = find_element_by_id(root,
168 view->control_data->id_ns_uri,
169 view->control_data->id_name,
173 res = gtk_math_view_is_selected(view->control_data->math_view, el) ? CORBA_TRUE : CORBA_FALSE;
174 gdome_el_unref(el, &exc);
177 gdome_el_unref(root, &exc);
184 impl_view_elementCoords(PortableServer_Servant servant,
185 const CORBA_char *id,
186 CORBA_short *x, CORBA_short *y,
187 CORBA_Environment *ev)
189 View* view = VIEW (bonobo_object (servant));
190 GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view);
191 CORBA_boolean res = CORBA_FALSE;
194 GdomeException exc = 0;
195 GdomeElement* el = find_element_by_id(root,
196 view->control_data->id_ns_uri,
197 view->control_data->id_name,
203 res = gtk_math_view_get_element_coords(view->control_data->math_view, el, &xx, &yy) ? CORBA_TRUE : CORBA_FALSE;
204 gdome_el_unref(el, &exc);
209 gdome_el_unref(root, &exc);
216 impl_view_elementBoundingBox(PortableServer_Servant servant,
217 const CORBA_char *id,
218 CORBA_short *width, CORBA_short *height, CORBA_short *depth,
219 CORBA_Environment *ev)
221 View* view = VIEW (bonobo_object (servant));
222 GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view);
223 CORBA_boolean res = CORBA_FALSE;
226 GdomeException exc = 0;
227 GdomeElement* el = find_element_by_id(root,
228 view->control_data->id_ns_uri,
229 view->control_data->id_name,
236 res = gtk_math_view_get_element_bounding_box(view->control_data->math_view, el, &w, &h, &d) ? CORBA_TRUE : CORBA_FALSE;
237 gdome_el_unref(el, &exc);
243 gdome_el_unref(root, &exc);
250 impl_view_getSize(PortableServer_Servant servant,
251 CORBA_short *width, CORBA_short *height,
252 CORBA_Environment *ev)
254 View* view = VIEW (bonobo_object (servant));
255 *width = gtk_math_view_get_width(view->control_data->math_view);
256 *height = gtk_math_view_get_height(view->control_data->math_view);
260 impl_view_getTop(PortableServer_Servant servant,
261 CORBA_short *x, CORBA_short *y,
262 CORBA_Environment *ev)
264 View* view = VIEW (bonobo_object (servant));
267 gtk_math_view_get_top(view->control_data->math_view, &xx, &yy);
273 impl_view_setTop (PortableServer_Servant servant,
274 CORBA_short x, CORBA_short y,
275 CORBA_Environment *ev)
277 View* view = VIEW (bonobo_object (servant));
278 gtk_math_view_set_top(view->control_data->math_view, x, y);
282 impl_view_setDefaultFontSize(PortableServer_Servant servant,
284 CORBA_Environment *ev)
286 View* view = VIEW (bonobo_object (servant));
287 gtk_math_view_set_font_size(view->control_data->math_view, size);
291 impl_view_getDefaultFontSize(PortableServer_Servant servant,
292 CORBA_Environment *ev)
294 View* view = VIEW (bonobo_object (servant));
295 return gtk_math_view_get_font_size(view->control_data->math_view);
299 impl_view_setVerbosity(PortableServer_Servant servant,
300 const CORBA_short level,
301 CORBA_Environment *ev)
303 View* view = VIEW (bonobo_object (servant));
304 gtk_math_view_set_log_verbosity(view->control_data->math_view, level);
308 impl_view_getVerbosity(PortableServer_Servant servant,
309 CORBA_Environment *ev)
311 View* view = VIEW (bonobo_object (servant));
312 return gtk_math_view_get_log_verbosity(view->control_data->math_view);
316 view_class_init(ViewClass* klass)
318 GObjectClass* object_class = (GObjectClass *) klass;
319 POA_GNOME_GtkMathView_View__epv* epv = &klass->epv;
321 view_parent_class = g_type_class_peek_parent (klass);
322 object_class->finalize = view_object_finalize;
324 epv->freeze = impl_view_freeze;
325 epv->thaw = impl_view_thaw;
326 epv->load = impl_view_load;
327 epv->unload = impl_view_unload;
328 epv->setIdAttribute = impl_view_setIdAttribute;
329 epv->getIdAttribute = impl_view_getIdAttribute;
330 epv->select = impl_view_select;
331 epv->unselect = impl_view_unselect;
332 epv->isSelected = impl_view_isSelected;
333 epv->elementCoords = impl_view_elementCoords;
334 epv->elementBoundingBox = impl_view_elementBoundingBox;
335 epv->getSize = impl_view_getSize;
336 epv->getTop = impl_view_getTop;
337 epv->setTop = impl_view_setTop;
338 epv->setDefaultFontSize = impl_view_setDefaultFontSize;
339 epv->getDefaultFontSize = impl_view_getDefaultFontSize;
340 epv->setVerbosity = impl_view_setVerbosity;
341 epv->getVerbosity = impl_view_getVerbosity;
345 view_init(View* view)
347 /* do some initialization */
351 view_new(GtkMathViewControlData* control_data)
354 g_return_val_if_fail(control_data != NULL, NULL);
355 view = g_object_new(VIEW_TYPE, NULL);
356 view->control_data = control_data;
360 BONOBO_TYPE_FUNC_FULL (View, GNOME_GtkMathView_View, BONOBO_TYPE_OBJECT, view)