X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fpersist-file.c;h=9f2da1bee4599b5cba70698df7b81913c73b8c45;hb=a7201afb196a65767622051aca79b84f59c6db38;hp=f1505b50cbaf7451401c20e521c5d06f829e6887;hpb=88b1f433e5018ab2ee57d2f03bd50a07555b3ee3;p=helm.git diff --git a/helm/gtkmathview-bonobo/src/persist-file.c b/helm/gtkmathview-bonobo/src/persist-file.c index f1505b50c..9f2da1bee 100644 --- a/helm/gtkmathview-bonobo/src/persist-file.c +++ b/helm/gtkmathview-bonobo/src/persist-file.c @@ -1,18 +1,23 @@ #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 CORBA_char *path,Corba_Environment *ev); +static void load_implementation(PortableServer_Servant servant,const gchar *path, + CORBA_Environment *ev); + +static void save_implementation(PortableServer_Servant servant,const gchar *path, + CORBA_Environment *ev); static void finalize(GObject *object) { GtkMathViewPersistFile *file = GTK_MATH_VIEW_PERSIST_FILE(object); if(file->math_view){ - g_object_unref(file->html); + g_object_unref(file->math_view); file->math_view = NULL; } @@ -22,16 +27,20 @@ static void finalize(GObject *object) static Bonobo_Persist_ContentTypeList * get_content_types(BonoboPersist *persist,CORBA_Environment *ev) { - return bonobo_persist_generate_content_types(); + return bonobo_persist_generate_content_types(3, "application/mathml+xml", "text/mathml", "text/plain"); } + static void -gtk_math_view_persist_file_class_init(GtkMathViewFileClass *klass) +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; +#ifdef DEBUG + printf("persist file class init\n"); +#endif gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass); epv->load = load_implementation; @@ -45,15 +54,18 @@ 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(GtkMathViewPresistFileClass), + sizeof(GtkMathViewPersistFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gtk_math_view_persist_file_class_init, NULL, /* class finalize */ NULL, /* class_data */ - sizeof(GtkMathViewPresistFile), + sizeof(GtkMathViewPersistFile), 0, /* n_preallocs */ (GInstanceInitFunc) NULL }; @@ -61,7 +73,7 @@ gtk_math_view_persist_file_get_type(void) type = bonobo_type_unique( BONOBO_TYPE_PERSIST, POA_Bonobo_PersistFile__init,POA_Bonobo_PersistFile__fini, - G_STRUCT_OFFSET(GtkMathViewPresistFileClass, epv), + G_STRUCT_OFFSET(GtkMathViewPersistFileClass, epv), &info,"GtkMathViewPresistFile"); } return type; @@ -70,32 +82,45 @@ gtk_math_view_persist_file_get_type(void) BonoboObject * gtk_math_view_persist_file_new(GtkMathView *math_view) { - BonoboObject *file; + BonoboObject *file; - file = g_object_new(gtk_math_view_persist_file_get_type(),NULL); - bonobo_persist_construct(BONOBO_PRESIST(file), CONTROL_FACTORY_ID); + 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_PRESIST_FILE (file) = math_view; + g_object_ref(math_view); + GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view; - return file; +#ifdef DEBUG + printf("gtk_math_view_persist_file_new passed\n"); +#endif + + return file; } static void -load_implementation(const gchar *path,CORBA_Environment *ev) +load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev) { - gboolean result; - g_assert(GTK_IS_MATH_VIEW(ev)); - result = gtk_math_view_load_uri((GtkMathView *) ev); - if(!result){ - CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL); - return; - } - return ; + gboolean result; + 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); + } + bonobo_object_unref(BONOBO_OBJECT(file)); + return ; } static void -save_implementation(const gchar *path,CORBA_Environment *ev) +save_implementation(PortableServer_Servant servant, + const gchar *path, + CORBA_Environment *ev) { bonobo_exception_set(ev,"save_exception"); bonobo_exception_add_handler_str("save_exception",