X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fpersist-file.c;h=1d3fd36c672b9b34fed7cf0482bfac4d09a4581d;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=9f2da1bee4599b5cba70698df7b81913c73b8c45;hpb=914b0da7aa23c8d11db1e415c56594ac52972b58;p=helm.git 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"); }