X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fview.c;h=068558d25077b59e957a5158beec93cd78a900ef;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=9f7451f400ba5b0ae3f5f338f8abc54d4a425f4a;hpb=4d6c4a7262efde3ffa94e3d62307b517b6d83924;p=helm.git diff --git a/helm/gtkmathview-bonobo/src/view.c b/helm/gtkmathview-bonobo/src/view.c index 9f7451f40..068558d25 100644 --- a/helm/gtkmathview-bonobo/src/view.c +++ b/helm/gtkmathview-bonobo/src/view.c @@ -1,6 +1,32 @@ +/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. + * Copyright (C) 2003 Luca Padovani + * Pouria Masoudi + * + * 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.1 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/gtkmathview-bonobo + * or send an email to + */ #include +#define HAVE_GMETADOM +#include + +#include "aux.h" #include "view.h" static GObjectClass* view_parent_class; @@ -32,14 +58,13 @@ impl_view_thaw(PortableServer_Servant servant, return; } -static void +static CORBA_boolean impl_view_load(PortableServer_Servant servant, const CORBA_char *uri, CORBA_Environment *ev) { View* view = VIEW (bonobo_object (servant)); - gtk_math_view_load_uri(view->control_data->math_view, uri); - return; + return gtk_math_view_load_uri(view->control_data->math_view, uri); } static void @@ -48,123 +73,226 @@ impl_view_unload(PortableServer_Servant servant, { View* view = VIEW (bonobo_object (servant)); gtk_math_view_unload(view->control_data->math_view); - return; } static void impl_view_setIdAttribute (PortableServer_Servant servant, - const CORBA_char *ns, - const CORBA_char *name, - CORBA_Environment *ev) + const CORBA_char *ns, + const CORBA_char *name, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_control_data_set_id_attribute(view->control_data, ns, name); } - static void impl_view_getIdAttribute (PortableServer_Servant servant, - CORBA_char *ns, - CORBA_char *name, - CORBA_Environment *ev) + CORBA_string *ns, + CORBA_string *name, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + if (view->control_data->id_ns_uri != NULL) + *ns = CORBA_string_dup(view->control_data->id_ns_uri->str); + else + *ns = NULL; + + if (view->control_data->id_name != NULL) + *name = CORBA_string_dup(view->control_data->id_name); + else + *name = NULL; } static void impl_view_select(PortableServer_Servant servant, - //in element_id elem, - CORBA_Environment *ev) + const CORBA_char *id, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gtk_math_view_select(view->control_data->math_view, el); + gdome_el_unref(el, &exc); + g_assert(exc == 0); + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } } static void impl_view_unselect(PortableServer_Servant servant, - //in element_id elem, - CORBA_Environment *ev) + const CORBA_char *id, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gtk_math_view_unselect(view->control_data->math_view, el); + gdome_el_unref(el, &exc); + g_assert(exc == 0); + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } } static CORBA_boolean impl_view_isSelected(PortableServer_Servant servant, - //in element_id elem, - CORBA_Environment *ev) + const CORBA_char *id, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + CORBA_boolean res = CORBA_FALSE; + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + res = gtk_math_view_is_selected(view->control_data->math_view, el) ? CORBA_TRUE : CORBA_FALSE; + gdome_el_unref(el, &exc); + g_assert(exc == 0); + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } + return res; } -static CORBA_boolean -impl_view_elementBoundingBox(PortableServer_Servant servant, - //in element_id elem, - CORBA_short *x,CORBA_short *y, - CORBA_short *width,CORBA_short *height, - CORBA_short *depth, - CORBA_Environment *ev) +static CORBA_boolean +impl_view_elementCoords(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_short *x, CORBA_short *y, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + CORBA_boolean res = CORBA_FALSE; + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gint xx; + gint yy; + res = gtk_math_view_get_element_coords(view->control_data->math_view, el, &xx, &yy) ? CORBA_TRUE : CORBA_FALSE; + gdome_el_unref(el, &exc); + g_assert(exc == 0); + *x = xx; + *y = yy; + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } + return res; } -static void -impl_view_getBoundingBox(PortableServer_Servant servant, - CORBA_short *width, - CORBA_short *height, - CORBA_short *depth, - CORBA_Environment *ev) +static CORBA_boolean +impl_view_elementBoundingBox(PortableServer_Servant servant, + const CORBA_char *id, + CORBA_short *width, CORBA_short *height, CORBA_short *depth, + CORBA_Environment *ev) { - return; + View* view = VIEW (bonobo_object (servant)); + GdomeElement* root = gtk_math_view_get_root_element(view->control_data->math_view); + CORBA_boolean res = CORBA_FALSE; + if (root != NULL) + { + GdomeException exc = 0; + GdomeElement* el = find_element_by_id(root, + view->control_data->id_ns_uri, + view->control_data->id_name, + id); + if (el != NULL) + { + gint w; + gint h; + gint d; + res = gtk_math_view_get_element_bounding_box(view->control_data->math_view, el, &w, &h, &d) ? CORBA_TRUE : CORBA_FALSE; + gdome_el_unref(el, &exc); + g_assert(exc == 0); + *width = w; + *height = h; + *depth = d; + } + gdome_el_unref(root, &exc); + g_assert(exc == 0); + } + return res; } static void impl_view_getSize(PortableServer_Servant servant, - CORBA_short *width,CORBA_short *height, - CORBA_short *totalWidth,CORBA_short *totalHeight, + CORBA_short *width, CORBA_short *height, CORBA_Environment *ev) { - //View* view = VIEW (bonobo_object (servant)); - //gtk_math_view_get_top(view->control_data->math_view,x,y); - - return; + View* view = VIEW (bonobo_object (servant)); + *width = gtk_math_view_get_width(view->control_data->math_view); + *height = gtk_math_view_get_height(view->control_data->math_view); } static void impl_view_getTop(PortableServer_Servant servant, - CORBA_short *x,CORBA_short *y, + CORBA_short *x, CORBA_short *y, CORBA_Environment *ev) { - View* view = VIEW (bonobo_object (servant)); - gtk_math_view_get_top(view->control_data->math_view,x,y); - return; + View* view = VIEW (bonobo_object (servant)); + gint xx; + gint yy; + gtk_math_view_get_top(view->control_data->math_view, &xx, &yy); + *x = xx; + *y = yy; } static void impl_view_setTop (PortableServer_Servant servant, - const CORBA_short x,const CORBA_short y, + CORBA_short x, CORBA_short y, CORBA_Environment *ev) { - View* view = VIEW (bonobo_object (servant)); - gtk_math_view_set_top(view->control_data->math_view,x,y); - return; + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_set_top(view->control_data->math_view, x, y); } static void impl_view_setDefaultFontSize(PortableServer_Servant servant, - const CORBA_short size, + CORBA_short size, CORBA_Environment *ev) { - View* view = VIEW (bonobo_object (servant)); - gtk_math_view_set_font_size(view->control_data->math_view,size); - return; + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_set_font_size(view->control_data->math_view, size); } static short impl_view_getDefaultFontSize(PortableServer_Servant servant, CORBA_Environment *ev) { - short int ris; - View* view = VIEW (bonobo_object (servant)); - ris = gtk_math_view_get_font_size(view->control_data->math_view); - return ris; + View* view = VIEW (bonobo_object (servant)); + return gtk_math_view_get_font_size(view->control_data->math_view); } static void @@ -172,19 +300,16 @@ impl_view_setVerbosity(PortableServer_Servant servant, const CORBA_short level, CORBA_Environment *ev) { - View* view = VIEW (bonobo_object (servant)); - gtk_math_view_set_log_verbosity(view->control_data->math_view,level); - return; + View* view = VIEW (bonobo_object (servant)); + gtk_math_view_set_log_verbosity(view->control_data->math_view, level); } static short impl_view_getVerbosity(PortableServer_Servant servant, CORBA_Environment *ev) { - short int ris; - View* view = VIEW (bonobo_object (servant)); - ris = gtk_math_view_get_log_verbosity(view->control_data->math_view); - return ris; + View* view = VIEW (bonobo_object (servant)); + return gtk_math_view_get_log_verbosity(view->control_data->math_view); } static void @@ -205,8 +330,8 @@ view_class_init(ViewClass* klass) epv->select = impl_view_select; epv->unselect = impl_view_unselect; epv->isSelected = impl_view_isSelected; + epv->elementCoords = impl_view_elementCoords; epv->elementBoundingBox = impl_view_elementBoundingBox; - epv->getBoundingBox = impl_view_getBoundingBox; epv->getSize = impl_view_getSize; epv->getTop = impl_view_getTop; epv->setTop = impl_view_setTop; @@ -214,8 +339,6 @@ view_class_init(ViewClass* klass) epv->getDefaultFontSize = impl_view_getDefaultFontSize; epv->setVerbosity = impl_view_setVerbosity; epv->getVerbosity = impl_view_getVerbosity; - - return; } static void @@ -224,8 +347,6 @@ view_init(View* view) /* do some initialization */ } -BONOBO_TYPE_FUNC_FULL (View, GNOME_GtkMathView_View, BONOBO_TYPE_OBJECT, view) - View* view_new(GtkMathViewControlData* control_data) { @@ -235,3 +356,6 @@ view_new(GtkMathViewControlData* control_data) view->control_data = control_data; return view; } + +BONOBO_TYPE_FUNC_FULL (View, GNOME_GtkMathView_View, BONOBO_TYPE_OBJECT, view) +