From 2a9857d047063f36dfd15b0e07902bde1dd3d466 Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Sat, 13 Sep 2003 15:20:22 +0000 Subject: [PATCH] * some code cleanup * added LICENCE to all source files --- helm/gtkmathview-bonobo/LICENSE | 23 ++ helm/gtkmathview-bonobo/src/Makefile.am | 6 +- helm/gtkmathview-bonobo/src/aux.cc | 47 ++-- helm/gtkmathview-bonobo/src/aux.h | 26 ++- helm/gtkmathview-bonobo/src/control-data.c | 69 ++++-- helm/gtkmathview-bonobo/src/control-data.h | 28 ++- helm/gtkmathview-bonobo/src/control-factory.c | 206 ++++++++-------- helm/gtkmathview-bonobo/src/control-factory.h | 35 +-- helm/gtkmathview-bonobo/src/handlers.c | 25 ++ helm/gtkmathview-bonobo/src/handlers.h | 22 ++ helm/gtkmathview-bonobo/src/persist-file.c | 126 +++++----- helm/gtkmathview-bonobo/src/persist-file.h | 56 +++-- helm/gtkmathview-bonobo/src/persist-stream.c | 219 ++++++++++-------- helm/gtkmathview-bonobo/src/persist-stream.h | 51 ++-- helm/gtkmathview-bonobo/src/view.c | 27 ++- helm/gtkmathview-bonobo/src/view.h | 22 ++ helm/gtkmathview-bonobo/test/main.c | 107 +-------- helm/gtkmathview-bonobo/test/test.mml | 2 +- 18 files changed, 635 insertions(+), 462 deletions(-) create mode 100644 helm/gtkmathview-bonobo/LICENSE diff --git a/helm/gtkmathview-bonobo/LICENSE b/helm/gtkmathview-bonobo/LICENSE new file mode 100644 index 000000000..d9bf0fad0 --- /dev/null +++ b/helm/gtkmathview-bonobo/LICENSE @@ -0,0 +1,23 @@ +/* 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 + */ + diff --git a/helm/gtkmathview-bonobo/src/Makefile.am b/helm/gtkmathview-bonobo/src/Makefile.am index e856b6f53..35c011e75 100644 --- a/helm/gtkmathview-bonobo/src/Makefile.am +++ b/helm/gtkmathview-bonobo/src/Makefile.am @@ -3,8 +3,6 @@ location = $(libdir)/libgtkmathview-bonobo.so serverdir = $(libdir)/bonobo/servers server_in_files = GNOME_GtkMathView.server.in.in -CLEANFILES = $(server_in_files:.server.in.in=.server) - IDL = $(top_srcdir)/idl/GtkMathView.idl IDL_GENERATED_C = \ @@ -17,6 +15,10 @@ IDL_GENERATED_H = \ IDL_GENERATED = $(IDL_GENERATED_C) $(IDL_GENERATED_H) +CLEANFILES = \ + $(server_in_files:.server.in.in=.server) \ + $(IDL_GENERATED) + lib_LTLIBRARIES = libgtkmathview-bonobo.la libgtkmathview_bonobo_la_LIBADD = \ diff --git a/helm/gtkmathview-bonobo/src/aux.cc b/helm/gtkmathview-bonobo/src/aux.cc index 6ab6f63d4..b6d22c099 100644 --- a/helm/gtkmathview-bonobo/src/aux.cc +++ b/helm/gtkmathview-bonobo/src/aux.cc @@ -1,24 +1,25 @@ -// Copyright (C) 2000-2002, Luca Padovani . -// -// This file is part of GtkMathView, a Gtk widget for MathML. -// -// GtkMathView is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// GtkMathView 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GtkMathView; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// For details, see the GtkMathView World-Wide-Web page, -// http://www.cs.unibo.it/helm/mml-widget, or send a mail to -// +/* 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 @@ -212,7 +213,7 @@ find_common_ancestor(GdomeElement* first, GdomeElement* last) } extern "C" GdomeElement* -find_self_or_ancestor(GdomeElement* elem, const char* uri, const char* name) +find_self_or_ancestor(GdomeElement* elem, const gchar* uri, const gchar* name) { DOM::Element el(elem); @@ -291,7 +292,7 @@ find_hyperlink(GdomeElement* elem) extern "C" GdomeElement* find_element_by_id(GdomeElement* root, GdomeDOMString* ns_uri, GdomeDOMString* name, - const char* id) + const gchar* id) { DOM::Element el = findElementById(DOM::Element(root), DOM::GdomeString(ns_uri), DOM::GdomeString(name), diff --git a/helm/gtkmathview-bonobo/src/aux.h b/helm/gtkmathview-bonobo/src/aux.h index 50abcd409..e7cedd2cd 100644 --- a/helm/gtkmathview-bonobo/src/aux.h +++ b/helm/gtkmathview-bonobo/src/aux.h @@ -1,3 +1,25 @@ +/* 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 + */ #ifndef __aux_h__ #define __aux_h__ @@ -9,10 +31,12 @@ extern "C" { #endif void action_toggle(GdomeElement*); + GdomeElement* find_common_ancestor(GdomeElement*, GdomeElement*); + GdomeElement* find_self_or_ancestor(GdomeElement*, const gchar*, const gchar*); GdomeElement* find_element_with_id(GdomeElement*, GdomeDOMString*, GdomeDOMString*); GdomeDOMString* find_hyperlink(GdomeElement*); GdomeElement* find_element_by_id(GdomeElement*, GdomeDOMString*, GdomeDOMString*, - const char*); + const gchar*); #ifdef __cplusplus } diff --git a/helm/gtkmathview-bonobo/src/control-data.c b/helm/gtkmathview-bonobo/src/control-data.c index b96e99338..8668a3867 100644 --- a/helm/gtkmathview-bonobo/src/control-data.c +++ b/helm/gtkmathview-bonobo/src/control-data.c @@ -1,3 +1,29 @@ +/* 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 + +#include #include "control-data.h" @@ -8,8 +34,8 @@ gtk_math_view_control_data_new(GtkMathView *math_view) cd->math_view = math_view; cd->first_selected = NULL; cd->root_selected = NULL; - cd->id_ns_uri = NULL; - cd->id_name = NULL; + cd->id_ns_uri = gdome_str_mkref("http://www.cs.unibo.it/helm"); + cd->id_name = gdome_str_mkref("xref"); return cd; } @@ -44,21 +70,32 @@ gtk_math_view_control_data_destroy(GtkMathViewControlData* cd) g_free(cd); } +gchar* +gtk_math_view_control_data_get_id_ns_uri(GtkMathViewControlData* cd) +{ + g_return_val_if_fail(cd != NULL, NULL); + return (cd->id_ns_uri != NULL) ? g_strdup(cd->id_ns_uri->str) : NULL; +} + void -gtk_math_view_control_data_set_id_attribute(GtkMathViewControlData* cd, - const char* ns_uri, const char* name) +gtk_math_view_control_data_set_id_ns_uri(GtkMathViewControlData* cd, const gchar* ns_uri) { g_return_if_fail(cd != NULL); - if (cd->id_ns_uri != NULL) - { - gdome_str_unref(cd->id_ns_uri); - cd->id_ns_uri = NULL; - } - if (cd->id_name != NULL) - { - gdome_str_unref(cd->id_name); - cd->id_name = NULL; - } - if (ns_uri) cd->id_ns_uri = gdome_str_mkref(ns_uri); - if (name) cd->id_name = gdome_str_mkref(name); + if (cd->id_ns_uri != NULL) gdome_str_unref(cd->id_ns_uri); + cd->id_ns_uri = (ns_uri != NULL) ? gdome_str_mkref_dup(ns_uri) : NULL; +} + +gchar* +gtk_math_view_control_data_get_id_name(GtkMathViewControlData* cd) +{ + g_return_val_if_fail(cd != NULL, NULL); + return (cd->id_name != NULL) ? g_strdup(cd->id_name->str) : NULL; +} + +void +gtk_math_view_control_data_set_id_name(GtkMathViewControlData* cd, const gchar* name) +{ + g_return_if_fail(cd != NULL); + if (cd->id_name != NULL) gdome_str_unref(cd->id_name); + cd->id_name = (name != NULL) ? gdome_str_mkref_dup(name) : NULL; } diff --git a/helm/gtkmathview-bonobo/src/control-data.h b/helm/gtkmathview-bonobo/src/control-data.h index 089ed688f..8f81c12a8 100644 --- a/helm/gtkmathview-bonobo/src/control-data.h +++ b/helm/gtkmathview-bonobo/src/control-data.h @@ -1,3 +1,25 @@ +/* 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 + */ #ifndef __control_data_h__ #define __control_data_h__ @@ -16,7 +38,9 @@ typedef struct _GtkMathViewControlData GtkMathViewControlData* gtk_math_view_control_data_new(GtkMathView*); void gtk_math_view_control_data_destroy(GtkMathViewControlData*); -void gtk_math_view_control_data_set_id_attribute(GtkMathViewControlData*, - const char*, const char*); +gchar* gtk_math_view_control_data_get_id_ns_uri(GtkMathViewControlData*); +void gtk_math_view_control_data_set_id_ns_uri(GtkMathViewControlData*, const gchar*); +gchar* gtk_math_view_control_data_get_id_name(GtkMathViewControlData*); +void gtk_math_view_control_data_set_id_name(GtkMathViewControlData*, const gchar*); #endif // __control_data_h__ diff --git a/helm/gtkmathview-bonobo/src/control-factory.c b/helm/gtkmathview-bonobo/src/control-factory.c index c5fe90150..847d9f4f6 100644 --- a/helm/gtkmathview-bonobo/src/control-factory.c +++ b/helm/gtkmathview-bonobo/src/control-factory.c @@ -1,10 +1,37 @@ +/* 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 #include #include #include + #include "control-factory.h" -#include "handlers.h" #include "control-data.h" +#include "persist-file.h" +#include "persist-stream.h" +#include "handlers.h" #include "view.h" enum @@ -14,10 +41,9 @@ enum MATH_VIEW_TOP_X, MATH_VIEW_TOP_Y, MATH_VIEW_FONT_SIZE, - MATH_VIEW_ANTI_ALIASING, - MATH_VIEW_TRANSPARENCY, MATH_VIEW_VERBOSITY, - MATH_VIEW_FONT_MANAGER + MATH_VIEW_ID_NS_URI, + MATH_VIEW_ID_NAME } math_args; static void @@ -27,80 +53,54 @@ get_prop(BonoboPropertyBag* bag, CORBA_Environment *ev, gpointer user_data) { - GtkMathView *math_view; - - g_return_if_fail(GTK_IS_MATH_VIEW(user_data)); - - math_view = GTK_MATH_VIEW(user_data); + GtkMathViewControlData* control_data = user_data; + g_assert(control_data != NULL); switch (arg_id) { case MATH_VIEW_WIDTH: - { - gint i = gtk_math_view_get_width(math_view); - g_assert(arg->_type == BONOBO_ARG_INT); - BONOBO_ARG_SET_INT(arg,i); - } + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_width(control_data->math_view)); break; case MATH_VIEW_HEIGHT: - { - guint i = gtk_math_view_get_height(math_view); - g_assert(arg->_type == BONOBO_ARG_INT); - BONOBO_ARG_SET_INT(arg,i); - } + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_height(control_data->math_view)); break; case MATH_VIEW_TOP_X: { - guint new_top_y,new_top_x; - g_assert(arg->_type == BONOBO_ARG_INT); - gtk_math_view_get_top(math_view,&new_top_x, &new_top_y); - BONOBO_ARG_SET_INT(arg,new_top_x); + guint top_x; + gtk_math_view_get_top(control_data->math_view, &top_x, NULL); + BONOBO_ARG_SET_INT(arg, top_x); } break; case MATH_VIEW_TOP_Y: { - guint new_top_y,new_top_x; - g_assert(arg->_type == BONOBO_ARG_INT); - gtk_math_view_get_top(math_view,&new_top_x,&new_top_y); - BONOBO_ARG_SET_INT(arg,new_top_y); + guint top_y; + gtk_math_view_get_top(control_data->math_view, NULL, &top_y); + BONOBO_ARG_SET_INT(arg, top_y); } break; case MATH_VIEW_FONT_SIZE: - { - guint i = gtk_math_view_get_font_size(math_view); - g_assert(arg->_type == BONOBO_ARG_INT); - BONOBO_ARG_SET_INT(arg,i); - } - break; - case MATH_VIEW_ANTI_ALIASING: - { - gboolean i = gtk_math_view_get_anti_aliasing(math_view); - g_assert(arg->_type == BONOBO_ARG_BOOLEAN); - BONOBO_ARG_SET_BOOLEAN(arg,i); - } - break; - case MATH_VIEW_TRANSPARENCY: - { - gboolean i = gtk_math_view_get_transparency(math_view); - g_assert(arg->_type == BONOBO_ARG_BOOLEAN); - BONOBO_ARG_SET_BOOLEAN(arg,i); - } + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_font_size(control_data->math_view)); break; case MATH_VIEW_VERBOSITY: + BONOBO_ARG_SET_INT(arg, gtk_math_view_get_log_verbosity(control_data->math_view)); + break; + case MATH_VIEW_ID_NS_URI: { - gint i = gtk_math_view_get_log_verbosity(math_view); - g_assert(arg->_type == BONOBO_ARG_INT); - BONOBO_ARG_SET_INT(arg,i); + gchar* id_ns_uri = gtk_math_view_control_data_get_id_ns_uri(control_data); + BONOBO_ARG_SET_STRING(arg, id_ns_uri); + g_free(id_ns_uri); } break; - case MATH_VIEW_FONT_MANAGER: + case MATH_VIEW_ID_NAME: { - gint i = (gint) gtk_math_view_get_font_manager_type(math_view); - BONOBO_ARG_SET_INT(arg,i); + gchar* id_name = gtk_math_view_control_data_get_id_name(control_data); + BONOBO_ARG_SET_STRING(arg, id_name); + g_free(id_name); } break; default: - g_assert(FALSE); + bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound); + break; } } @@ -111,63 +111,36 @@ set_prop(BonoboPropertyBag* bag, CORBA_Environment* ev, gpointer user_data) { - GtkMathView *math_view; - - g_return_if_fail(GTK_IS_MATH_VIEW(user_data)); - - math_view = GTK_MATH_VIEW(user_data); + GtkMathViewControlData *control_data = user_data; + g_assert(control_data != NULL); switch (arg_id) { case MATH_VIEW_TOP_X: { guint old_top_y; - g_assert(arg->_type == BONOBO_ARG_INT); - gtk_math_view_get_top(math_view, NULL, &old_top_y); - gtk_math_view_set_top(math_view, BONOBO_ARG_GET_INT(arg), old_top_y); + gtk_math_view_get_top(control_data->math_view, NULL, &old_top_y); + gtk_math_view_set_top(control_data->math_view, BONOBO_ARG_GET_INT(arg), old_top_y); } break; case MATH_VIEW_TOP_Y: { guint old_top_x; - g_assert(arg->_type == BONOBO_ARG_INT); - gtk_math_view_get_top(math_view, &old_top_x, NULL); - gtk_math_view_set_top(math_view, BONOBO_ARG_GET_INT(arg), old_top_x); + gtk_math_view_get_top(control_data->math_view, &old_top_x, NULL); + gtk_math_view_set_top(control_data->math_view, BONOBO_ARG_GET_INT(arg), old_top_x); } break; case MATH_VIEW_FONT_SIZE: - { - guint i = gtk_math_view_get_font_size(math_view); - g_assert(arg->_type == BONOBO_ARG_INT); - BONOBO_ARG_SET_INT(arg,i); - } - break; - case MATH_VIEW_ANTI_ALIASING: - { - gboolean i = gtk_math_view_get_anti_aliasing(math_view); - g_assert(arg->_type == BONOBO_ARG_BOOLEAN); - BONOBO_ARG_SET_BOOLEAN(arg,i); - } - break; - case MATH_VIEW_TRANSPARENCY: - { - gboolean i = gtk_math_view_get_transparency(math_view); - g_assert(arg->_type == BONOBO_ARG_BOOLEAN); - BONOBO_ARG_SET_BOOLEAN(arg,i); - } + gtk_math_view_set_font_size(control_data->math_view, BONOBO_ARG_GET_INT(arg)); break; case MATH_VIEW_VERBOSITY: - { - gint i = gtk_math_view_get_log_verbosity(math_view); - g_assert(arg->_type == BONOBO_ARG_INT); - BONOBO_ARG_SET_INT(arg,i); - } + gtk_math_view_set_log_verbosity(control_data->math_view, BONOBO_ARG_GET_INT(arg)); break; - case MATH_VIEW_FONT_MANAGER: - { - gint i = (gint) gtk_math_view_get_font_manager_type(math_view); - BONOBO_ARG_SET_INT(arg,i); - } + case MATH_VIEW_ID_NS_URI: + gtk_math_view_control_data_set_id_ns_uri(control_data, BONOBO_ARG_GET_STRING(arg)); + break; + case MATH_VIEW_ID_NAME: + gtk_math_view_control_data_set_id_name(control_data, BONOBO_ARG_GET_STRING(arg)); break; default: bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound); @@ -212,36 +185,41 @@ gtk_math_view_control_init(BonoboControl *control, GtkWidget *scrolled_window) persist_stream = gtk_math_view_persist_stream_new(GTK_MATH_VIEW(math_view)); bonobo_object_add_interface(BONOBO_OBJECT(control), persist_stream); - prop_bag = bonobo_property_bag_new(get_prop, set_prop, math_view); + prop_bag = bonobo_property_bag_new(get_prop, set_prop, control_data); bonobo_control_set_properties(control, BONOBO_OBJREF(prop_bag), NULL); - bonobo_property_bag_add(prop_bag,"width", + bonobo_property_bag_add(prop_bag, "width", MATH_VIEW_WIDTH, BONOBO_ARG_INT, - NULL,"width",0); - bonobo_property_bag_add(prop_bag,"height", + NULL, + "Width of the view", 0); + bonobo_property_bag_add(prop_bag, "height", MATH_VIEW_HEIGHT, BONOBO_ARG_INT, - NULL,"height",0); - bonobo_property_bag_add(prop_bag,"top_x", + NULL, + "Height of the view", 0); + bonobo_property_bag_add(prop_bag, "top-x", MATH_VIEW_TOP_X, BONOBO_ARG_INT, - NULL,"top_x",0); - bonobo_property_bag_add(prop_bag,"top_y", + NULL, + "X coordinate of the top-left corner", 0); + bonobo_property_bag_add(prop_bag, "top-y", MATH_VIEW_TOP_Y, BONOBO_ARG_INT, - NULL,"top_y",0); - bonobo_property_bag_add(prop_bag,"font_size", + NULL, + "Y coordinate of the top-left corner", 0); + bonobo_property_bag_add(prop_bag, "font-size", MATH_VIEW_FONT_SIZE, BONOBO_ARG_INT, - NULL,"font_size",0); - bonobo_property_bag_add(prop_bag,"anti_aliasing", - MATH_VIEW_ANTI_ALIASING, BONOBO_ARG_BOOLEAN, - NULL,"anti_aliasing",0); - bonobo_property_bag_add(prop_bag,"transparency", - MATH_VIEW_TRANSPARENCY, BONOBO_ARG_BOOLEAN, - NULL,"transparency",0); + NULL, + "Default font size", 0); bonobo_property_bag_add(prop_bag,"verbosity", MATH_VIEW_VERBOSITY, BONOBO_ARG_INT, - NULL,"verbosity",0); - bonobo_property_bag_add(prop_bag,"font_manager", - MATH_VIEW_FONT_MANAGER, BONOBO_ARG_INT, - NULL,"font_manager",0); + NULL, + "Verbosity level", 0); + bonobo_property_bag_add(prop_bag, "id-ns-uri", + MATH_VIEW_ID_NS_URI, BONOBO_ARG_STRING, + NULL, + "Namespace URI of ID attribute", 0); + bonobo_property_bag_add(prop_bag, "id-name", + MATH_VIEW_ID_NAME, BONOBO_ARG_STRING, + NULL, + "Name of ID attribute", 0); bonobo_object_unref(BONOBO_OBJECT(prop_bag)); diff --git a/helm/gtkmathview-bonobo/src/control-factory.h b/helm/gtkmathview-bonobo/src/control-factory.h index e91e8a7a5..0d2e5a24d 100644 --- a/helm/gtkmathview-bonobo/src/control-factory.h +++ b/helm/gtkmathview-bonobo/src/control-factory.h @@ -1,21 +1,24 @@ -/* - * gtk_math_view_bonobo.c - * This file is part of gedit - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, +/* 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 General Public License for more details. + * 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 * - * You should have received a copy of the GNU General Public License - * along with this program; 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 */ #ifndef __control_factory_h__ diff --git a/helm/gtkmathview-bonobo/src/handlers.c b/helm/gtkmathview-bonobo/src/handlers.c index e7e100aa2..85479ed1b 100644 --- a/helm/gtkmathview-bonobo/src/handlers.c +++ b/helm/gtkmathview-bonobo/src/handlers.c @@ -1,4 +1,29 @@ +/* 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 + +#include "aux.h" #include "handlers.h" static void diff --git a/helm/gtkmathview-bonobo/src/handlers.h b/helm/gtkmathview-bonobo/src/handlers.h index 81b1eb70b..529a13d7b 100644 --- a/helm/gtkmathview-bonobo/src/handlers.h +++ b/helm/gtkmathview-bonobo/src/handlers.h @@ -1,3 +1,25 @@ +/* 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 + */ #ifndef __handlers_h__ #define __handlers_h__ diff --git a/helm/gtkmathview-bonobo/src/persist-file.c b/helm/gtkmathview-bonobo/src/persist-file.c index 9f2da1bee..1d3fd36c6 100644 --- a/helm/gtkmathview-bonobo/src/persist-file.c +++ b/helm/gtkmathview-bonobo/src/persist-file.c @@ -1,27 +1,54 @@ +/* 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 + #include #include #include + #include "persist-file.h" #include "control-factory.h" static BonoboObjectClass *gtk_math_view_persist_file_parent_class; static void load_implementation(PortableServer_Servant servant,const gchar *path, - CORBA_Environment *ev); + CORBA_Environment *ev); static void save_implementation(PortableServer_Servant servant,const gchar *path, - CORBA_Environment *ev); + CORBA_Environment *ev); static void finalize(GObject *object) { - GtkMathViewPersistFile *file = GTK_MATH_VIEW_PERSIST_FILE(object); + GtkMathViewPersistFile *file = GTK_MATH_VIEW_PERSIST_FILE(object); - if(file->math_view){ - g_object_unref(file->math_view); - file->math_view = NULL; - } + if (file->math_view) + { + g_object_unref(file->math_view); + file->math_view = NULL; + } - G_OBJECT_CLASS(gtk_math_view_persist_file_parent_class)->finalize (object); + G_OBJECT_CLASS(gtk_math_view_persist_file_parent_class)->finalize (object); } static Bonobo_Persist_ContentTypeList * @@ -30,53 +57,49 @@ get_content_types(BonoboPersist *persist,CORBA_Environment *ev) return bonobo_persist_generate_content_types(3, "application/mathml+xml", "text/mathml", "text/plain"); } - static void gtk_math_view_persist_file_class_init(GtkMathViewPersistFileClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); - BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass); - POA_Bonobo_PersistFile__epv *epv = &klass->epv; + GObjectClass *object_class = G_OBJECT_CLASS(klass); + BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass); + POA_Bonobo_PersistFile__epv *epv = &klass->epv; -#ifdef DEBUG - printf("persist file class init\n"); -#endif - gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass); + gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass); - epv->load = load_implementation; - epv->save = save_implementation; + epv->load = load_implementation; + epv->save = save_implementation; - object_class->finalize = finalize; - persist_class->get_content_types = get_content_types; + object_class->finalize = finalize; + persist_class->get_content_types = get_content_types; } GType gtk_math_view_persist_file_get_type(void) { - static GType type = 0; -#ifdef DEBUG - printf("persist file get type\n"); -#endif - if(!type){ - GTypeInfo info = { - sizeof(GtkMathViewPersistFileClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_math_view_persist_file_class_init, - NULL, /* class finalize */ - NULL, /* class_data */ - sizeof(GtkMathViewPersistFile), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL - }; - - type = bonobo_type_unique( - BONOBO_TYPE_PERSIST, + static GType type = 0; + + if (!type) + { + GTypeInfo info = + { + sizeof(GtkMathViewPersistFileClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_math_view_persist_file_class_init, + NULL, /* class finalize */ + NULL, /* class_data */ + sizeof(GtkMathViewPersistFile), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL + }; + + type = bonobo_type_unique(BONOBO_TYPE_PERSIST, POA_Bonobo_PersistFile__init,POA_Bonobo_PersistFile__fini, G_STRUCT_OFFSET(GtkMathViewPersistFileClass, epv), &info,"GtkMathViewPresistFile"); - } - return type; + } + + return type; } BonoboObject * @@ -84,17 +107,12 @@ gtk_math_view_persist_file_new(GtkMathView *math_view) { BonoboObject *file; - printf("persist file new\n"); file = g_object_new(gtk_math_view_persist_file_get_type(),NULL); bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID); g_object_ref(math_view); GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view; -#ifdef DEBUG - printf("gtk_math_view_persist_file_new passed\n"); -#endif - return file; } @@ -105,16 +123,11 @@ load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Envir GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant)); //fd = open(path, O_RDONLY); - printf("passing from here LOAD\n"); - result = gtk_math_view_load_uri(file->math_view,path); if(!result) - { - printf("exception here!\n"); - CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); - } + CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); + bonobo_object_unref(BONOBO_OBJECT(file)); - return ; } static void @@ -122,8 +135,7 @@ save_implementation(PortableServer_Servant servant, const gchar *path, CORBA_Environment *ev) { - bonobo_exception_set(ev,"save_exception"); - bonobo_exception_add_handler_str("save_exception", - "Save option is not valid"); - return; + bonobo_exception_set(ev,"save_exception"); + bonobo_exception_add_handler_str("save_exception", + "Save option is not valid"); } diff --git a/helm/gtkmathview-bonobo/src/persist-file.h b/helm/gtkmathview-bonobo/src/persist-file.h index 0ed7bcbf9..6f70e76ef 100644 --- a/helm/gtkmathview-bonobo/src/persist-file.h +++ b/helm/gtkmathview-bonobo/src/persist-file.h @@ -1,3 +1,26 @@ +/* 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 + */ + #ifndef __GTK_MATH_VIEW_PERSIST_FILE_H__ #define __GTK_MATH_VIEW_PERSIST_FILE_H__ @@ -10,29 +33,28 @@ struct _GtkMathViewPersistFile; typedef struct _GtkMathViewPersistFile GtkMathViewPersistFile; typedef struct _GtkMathViewPersistFilePrivate GtkMathViewPersistFilePrivate; -#define GTK_MATH_VIEW_TYPE_PERSIST_FILE (gtk_math_view_persist_file_get_type()) - -#define GTK_MATH_VIEW_PERSIST_FILE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GTK_MATH_VIEW_TYPE_PERSIST_FILE, \ +#define GTK_MATH_VIEW_TYPE_PERSIST_FILE (gtk_math_view_persist_file_get_type()) +#define GTK_MATH_VIEW_PERSIST_FILE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GTK_MATH_VIEW_TYPE_PERSIST_FILE, \ GtkMathViewPersistFile)) - -#define GTK_MATH_VIEW_IS_PERSIST_FILE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object),\ - GTK_MATH_VIEW_TYPE_PERSIST_FILE)) -#define GTK_MATH_VIEW_IS_PERSIST_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ +#define GTK_MATH_VIEW_IS_PERSIST_FILE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object),\ + GTK_MATH_VIEW_TYPE_PERSIST_FILE)) +#define GTK_MATH_VIEW_IS_PERSIST_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ GTK_MATH_VIEW_TYPE_PERSIST_FILE)) -struct _GtkMathViewPersistFile{ - BonoboPersist parent; - GtkMathView *math_view; +struct _GtkMathViewPersistFile +{ + BonoboPersist parent; + GtkMathView *math_view; }; -typedef struct { - BonoboPersistClass parent_class; - - POA_Bonobo_PersistFile__epv epv; -}GtkMathViewPersistFileClass; +typedef struct +{ + BonoboPersistClass parent_class; + POA_Bonobo_PersistFile__epv epv; +} GtkMathViewPersistFileClass; -GType gtk_math_view_persist_file_get_type(void); -BonoboObject *gtk_math_view_persist_file_new(GtkMathView *math_view); +GType gtk_math_view_persist_file_get_type(void); +BonoboObject *gtk_math_view_persist_file_new(GtkMathView *); G_END_DECLS diff --git a/helm/gtkmathview-bonobo/src/persist-stream.c b/helm/gtkmathview-bonobo/src/persist-stream.c index f971b721b..bef7d90cb 100644 --- a/helm/gtkmathview-bonobo/src/persist-stream.c +++ b/helm/gtkmathview-bonobo/src/persist-stream.c @@ -1,10 +1,35 @@ +/* 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 + #include #include -#include + #include "persist-stream.h" #include "control-factory.h" -#define DEBUG +#define DEBUG0 static BonoboObjectClass *gtk_math_view_persist_stream_parent_class; @@ -20,14 +45,15 @@ static void save_implementation(PortableServer_Servant servant, static void finalize(GObject *object) { - GtkMathViewPersistStream *stream = GTK_MATH_VIEW_PERSIST_STREAM(object); + GtkMathViewPersistStream *stream = GTK_MATH_VIEW_PERSIST_STREAM(object); - if(stream->math_view){ - g_object_unref(stream->math_view); - stream->math_view = NULL; + if (stream->math_view != NULL) + { + g_object_unref(stream->math_view); + stream->math_view = NULL; } - G_OBJECT_CLASS(gtk_math_view_persist_stream_parent_class)->finalize(object); + G_OBJECT_CLASS(gtk_math_view_persist_stream_parent_class)->finalize(object); } static Bonobo_Persist_ContentTypeList * @@ -39,87 +65,92 @@ get_content_types(BonoboPersist *persist,CORBA_Environment *ev) static void gtk_math_view_persist_stream_class_init(GtkMathViewPersistStreamClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); - BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass); - POA_Bonobo_PersistStream__epv *epv = &klass->epv; + GObjectClass *object_class = G_OBJECT_CLASS(klass); + BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass); + POA_Bonobo_PersistStream__epv *epv = &klass->epv; #ifdef DEBUG - printf("persist stream class init\n"); + printf("persist stream class init\n"); #endif - gtk_math_view_persist_stream_parent_class = g_type_class_peek_parent(klass); + gtk_math_view_persist_stream_parent_class = g_type_class_peek_parent(klass); - epv->load = load_implementation; - epv->save = save_implementation; + epv->load = load_implementation; + epv->save = save_implementation; - object_class->finalize = finalize; - persist_class->get_content_types = get_content_types; + object_class->finalize = finalize; + persist_class->get_content_types = get_content_types; } GType gtk_math_view_persist_stream_get_type(void) { - static GType type = 0; + static GType type = 0; #ifdef DEBUG - printf("persist stream get type\n"); + printf("persist stream get type\n"); #endif - if(!type){ - GTypeInfo info={ - sizeof(GtkMathViewPersistStreamClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_math_view_persist_stream_class_init, - NULL, /*class finalize */ - NULL, /*class data */ - sizeof(GtkMathViewPersistStream), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL - }; - - type = bonobo_type_unique( - BONOBO_TYPE_PERSIST, - POA_Bonobo_PersistStream__init,POA_Bonobo_PersistStream__fini, - G_STRUCT_OFFSET(GtkMathViewPersistStreamClass,epv), - &info,"GtkMathViewPersistStream"); + if (!type) + { + GTypeInfo info = + { + sizeof(GtkMathViewPersistStreamClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_math_view_persist_stream_class_init, + NULL, /*class finalize */ + NULL, /*class data */ + sizeof(GtkMathViewPersistStream), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL + }; + + type = bonobo_type_unique(BONOBO_TYPE_PERSIST, + POA_Bonobo_PersistStream__init,POA_Bonobo_PersistStream__fini, + G_STRUCT_OFFSET(GtkMathViewPersistStreamClass,epv), + &info,"GtkMathViewPersistStream"); } - return type; + + return type; } BonoboObject * gtk_math_view_persist_stream_new(GtkMathView *math_view) { - BonoboObject *stream; + BonoboObject *stream; #ifdef DEBUG - printf("persist stream new\n"); + printf("persist stream new\n"); #endif - stream = g_object_new(gtk_math_view_persist_stream_get_type(),NULL); - bonobo_persist_construct(BONOBO_PERSIST(stream),CONTROL_FACTORY_ID); + stream = g_object_new(gtk_math_view_persist_stream_get_type(),NULL); + bonobo_persist_construct(BONOBO_PERSIST(stream),CONTROL_FACTORY_ID); - g_object_ref(math_view); - GTK_MATH_VIEW_PERSIST_STREAM(stream)->math_view = math_view; + g_object_ref(math_view); + GTK_MATH_VIEW_PERSIST_STREAM(stream)->math_view = math_view; - return stream; + return stream; } static FILE* create_tmp_file(GtkMathViewPersistStream *persist) { - FILE *tmpfile; - int fd; + FILE *tmpfile; + int fd; - persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/gmvXXXXXX", NULL); - if((fd = mkstemp(persist->tmp_path_name)) < 0) { - g_free(persist->tmp_path_name), - persist->tmp_path_name = NULL; - return NULL; + persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/gmvXXXXXX", NULL); + if ((fd = mkstemp(persist->tmp_path_name)) < 0) + { + g_free(persist->tmp_path_name), + persist->tmp_path_name = NULL; + return NULL; } - printf("salvo nel file %s\n", persist->tmp_path_name); - tmpfile = fdopen(fd, "w"); - if(!tmpfile) { - close(fd); - return NULL; + + tmpfile = fdopen(fd, "w"); + if(!tmpfile) + { + close(fd); + return NULL; } - return tmpfile; + + return tmpfile; } @@ -129,57 +160,55 @@ load_implementation(PortableServer_Servant servant, const CORBA_char *type, CORBA_Environment *ev) { - GtkMathViewPersistStream *persist = GTK_MATH_VIEW_PERSIST_STREAM (bonobo_object_from_servant (servant)); - Bonobo_Stream_iobuf *buffer; - GtkMathViewPersistStream *handle; - CORBA_long len_read; - gboolean result; - FILE *tmpfile; + GtkMathViewPersistStream *persist = GTK_MATH_VIEW_PERSIST_STREAM (bonobo_object_from_servant (servant)); + Bonobo_Stream_iobuf *buffer; + GtkMathViewPersistStream *handle; + CORBA_long len_read; + gboolean result; + FILE *tmpfile; #ifdef DEBUG - printf("persist stream loading\n"); + printf("persist stream loading\n"); #endif - printf("type = %s\n", type); - - if (strcmp (type, "application/mathml+xml") != 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_WrongDataType, NULL); - return; + if (strcmp (type, "application/mathml+xml") != 0) + { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Bonobo_Persist_WrongDataType, NULL); + return; } - tmpfile = create_tmp_file(persist); - do { - Bonobo_Stream_read (stream, 4096, &buffer, ev); - if (ev->_major != CORBA_NO_EXCEPTION) { - printf("*** eccezione 1 %s\n",ev->_major); - goto clean; - } + tmpfile = create_tmp_file(persist); + do + { + Bonobo_Stream_read (stream, 4096, &buffer, ev); + if (ev->_major != CORBA_NO_EXCEPTION) + goto clean; - len_read = buffer->_length; - printf("letti %d bytes\n", len_read); - - if (buffer->_buffer && len_read) - if(fwrite(buffer->_buffer, 1, len_read, tmpfile) != len_read) { - CORBA_free (buffer); - printf("*** eccezione 2\n"); - goto clean; - } + len_read = buffer->_length; + + if (buffer->_buffer && len_read) + if (fwrite(buffer->_buffer, 1, len_read, tmpfile) != len_read) + { + CORBA_free (buffer); + goto clean; + } - CORBA_free (buffer); + CORBA_free (buffer); } while (len_read > 0); - fclose(tmpfile); - result = gtk_math_view_load_uri(persist->math_view,persist->tmp_path_name); - if(!result) + fclose(tmpfile); + + result = gtk_math_view_load_uri(persist->math_view,persist->tmp_path_name); + if(!result) { - CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); + CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); } - return ; + return ; -clean: - fclose (tmpfile); - return; + clean: + fclose (tmpfile); + return; } static void diff --git a/helm/gtkmathview-bonobo/src/persist-stream.h b/helm/gtkmathview-bonobo/src/persist-stream.h index e90012623..848121436 100644 --- a/helm/gtkmathview-bonobo/src/persist-stream.h +++ b/helm/gtkmathview-bonobo/src/persist-stream.h @@ -1,3 +1,26 @@ +/* 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 + */ + #ifndef __GTK_MATH_VIEW_PERSIST_STREAM_H__ #define __GTK_MATH_VIEW_PERSIST_STREAM_H__ @@ -10,28 +33,26 @@ struct _GtkMathViewPersistStream; typedef struct _GtkMathViewPersistStream GtkMathViewPersistStream; typedef struct _GtkMathViewPersistStreamPrivate GtkMathViewPersistStreamPrivate; -#define GTK_MATH_VIEW_TYPE_PERSIST_STREAM (gtk_math_view_persist_stream_get_type()) - -#define GTK_MATH_VIEW_PERSIST_STREAM(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GTK_MATH_VIEW_TYPE_PERSIST_STREAM,GtkMathViewPersistStream)) - +#define GTK_MATH_VIEW_TYPE_PERSIST_STREAM (gtk_math_view_persist_stream_get_type()) +#define GTK_MATH_VIEW_PERSIST_STREAM(object) (G_TYPE_CHECK_INSTANCE_CAST((object), GTK_MATH_VIEW_TYPE_PERSIST_STREAM,GtkMathViewPersistStream)) #define GTK_MATH_VIEW_IS_PERSIST_STREAM(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), GTK_MATH_VIEW_TYPE_PERSIST_STREAM)) - #define GTK_MATH_VIEW_IS_PERSIST_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_MATH_VIEW_TYPE_PERSIST_STREAM)) -struct _GtkMathViewPersistStream{ - BonoboPersist parent; - GtkMathView *math_view; - const gchar* tmp_path_name; +struct _GtkMathViewPersistStream +{ + BonoboPersist parent; + GtkMathView *math_view; + gchar* tmp_path_name; }; -typedef struct{ - BonoboPersistClass parent_class; - - POA_Bonobo_PersistStream__epv epv; -}GtkMathViewPersistStreamClass; +typedef struct +{ + BonoboPersistClass parent_class; + POA_Bonobo_PersistStream__epv epv; +} GtkMathViewPersistStreamClass; GType gtk_math_view_persist_stream_get_type(void); -//BonoboObject *gtk_math_view_persist_stream_new(GtkMathView *math_view); +BonoboObject *gtk_math_view_persist_stream_new(GtkMathView *); G_END_DECLS diff --git a/helm/gtkmathview-bonobo/src/view.c b/helm/gtkmathview-bonobo/src/view.c index b0385a6fe..068558d25 100644 --- a/helm/gtkmathview-bonobo/src/view.c +++ b/helm/gtkmathview-bonobo/src/view.c @@ -1,3 +1,25 @@ +/* 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 @@ -325,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) { @@ -336,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) + diff --git a/helm/gtkmathview-bonobo/src/view.h b/helm/gtkmathview-bonobo/src/view.h index a652726ad..86394bec5 100644 --- a/helm/gtkmathview-bonobo/src/view.h +++ b/helm/gtkmathview-bonobo/src/view.h @@ -1,3 +1,25 @@ +/* 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 + */ #ifndef __view_h__ #define __view_h__ diff --git a/helm/gtkmathview-bonobo/test/main.c b/helm/gtkmathview-bonobo/test/main.c index 0986fdd71..e737329ec 100644 --- a/helm/gtkmathview-bonobo/test/main.c +++ b/helm/gtkmathview-bonobo/test/main.c @@ -231,8 +231,8 @@ get_top(GtkWidget *widget, control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); - top_x = bonobo_pbclient_get_long(prop_bag,"top_x",NULL); - top_y = bonobo_pbclient_get_long(prop_bag,"top_y",NULL); + top_x = bonobo_pbclient_get_long(prop_bag,"top-x",NULL); + top_y = bonobo_pbclient_get_long(prop_bag,"top-y",NULL); printf("Top X: %d ,Top Y: %d\n",top_x,top_y); @@ -252,59 +252,13 @@ get_font_size(GtkWidget *widget, control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); - font_size = bonobo_pbclient_get_long(prop_bag,"font_size",NULL); + font_size = bonobo_pbclient_get_long(prop_bag,"font-size",NULL); printf("FontSize : %d\n",font_size); bonobo_object_release_unref(prop_bag,NULL); } -static void -get_antialiasing(GtkWidget *widget, - gpointer data) -{ - gboolean antialiasing; - BonoboWidget* control; - BonoboControlFrame* control_frame; - Bonobo_PropertyBag prop_bag; - - control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data))); - control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); - prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); - - antialiasing = bonobo_pbclient_get_boolean(prop_bag,"anti_aliasing",NULL); - - if(antialiasing == TRUE) - printf("Antialiasing is set\n"); - else if(antialiasing == FALSE) - printf("Antialiasing is not set\n"); - - bonobo_object_release_unref(prop_bag,NULL); -} - -static void -get_transparency(GtkWidget *widget, - gpointer data) -{ - gboolean transparency; - BonoboWidget* control; - BonoboControlFrame* control_frame; - Bonobo_PropertyBag prop_bag; - - control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data))); - control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); - prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); - - transparency = bonobo_pbclient_get_boolean(prop_bag,"transparency",NULL); - - if(transparency == TRUE) - printf("Transparency is set\n"); - else if(transparency == FALSE) - printf("Transparency is not set\n"); - - bonobo_object_release_unref(prop_bag,NULL); -} - static void get_verbosity(GtkWidget *widget, gpointer data) @@ -325,26 +279,6 @@ get_verbosity(GtkWidget *widget, bonobo_object_release_unref(prop_bag,NULL); } -static void -get_font_manager(GtkWidget *widget, - gpointer data) -{ - gint font_manager; - BonoboWidget* control; - BonoboControlFrame* control_frame; - Bonobo_PropertyBag prop_bag; - - control = BONOBO_WIDGET(bonobo_window_get_contents(BONOBO_WINDOW(data))); - control_frame = bonobo_widget_get_control_frame(BONOBO_WIDGET(control)); - prop_bag = bonobo_control_frame_get_control_property_bag(control_frame,NULL); - - font_manager = bonobo_pbclient_get_long(prop_bag,"font_manager",NULL); - - printf("Font_manager: %d\n",font_manager); - - bonobo_object_release_unref(prop_bag,NULL); -} - static BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("OpenFile", open_through_persist_file_cb), BONOBO_UI_UNSAFE_VERB ("OpenStream", open_through_persist_stream_cb), @@ -352,10 +286,7 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("Size", get_size), BONOBO_UI_UNSAFE_VERB ("Top", get_top), BONOBO_UI_UNSAFE_VERB ("Font Size", get_font_size), - BONOBO_UI_UNSAFE_VERB ("AntiAliasing", get_antialiasing), - BONOBO_UI_UNSAFE_VERB ("Transparency", get_transparency), BONOBO_UI_UNSAFE_VERB ("Verbosity", get_verbosity), - BONOBO_UI_UNSAFE_VERB ("Font Manager", get_font_manager), BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb), BONOBO_UI_VERB_END }; @@ -372,19 +303,9 @@ static char ui [] = " " " " -" " -" " " " -" " -" " " " -" " -" " -" " " " " " " " @@ -400,20 +321,8 @@ static char ui [] = " " -" " - -" " - " " - -" " - -" " -" " " " " " " " @@ -531,16 +440,12 @@ install_property_bag_listener (BonoboWidget *control, BonoboWindow *bonobo_win) bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)height_changed, "Bonobo/Property:change:height",NULL,bonobo_win); bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)top_x_changed, - "Bonobo/Property:change:top_x",NULL,bonobo_win); + "Bonobo/Property:change:top-x",NULL,bonobo_win); bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)top_y_changed, - "Bonobo/Property:change:top_y",NULL,bonobo_win); + "Bonobo/Property:change:top-y",NULL,bonobo_win); bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)font_size_changed, - "Bonobo/Property:change:font_size",NULL,bonobo_win); + "Bonobo/Property:change:font-size",NULL,bonobo_win); bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)anti_aliasing_changed, - "Bonobo/Property:change:anti_aliasing",NULL,bonobo_win); - bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)transparency_changed, - "Bonobo/Property:change:transparency",NULL,bonobo_win); - bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)verbosity_changed, "Bonobo/Property:change:verbosity",NULL,bonobo_win); bonobo_event_source_client_add_listener(prop_bag, (BonoboListenerCallbackFn)font_manager_changed, "Bonobo/Property:change:font_manager",NULL,bonobo_win); diff --git a/helm/gtkmathview-bonobo/test/test.mml b/helm/gtkmathview-bonobo/test/test.mml index 152fe7579..e75e48838 100644 --- a/helm/gtkmathview-bonobo/test/test.mml +++ b/helm/gtkmathview-bonobo/test/test.mml @@ -25,7 +25,7 @@ x + - q + q -- 2.39.2