]> matita.cs.unibo.it Git - helm.git/commitdiff
Persist file completed.
authorpmasoudi <??>
Thu, 17 Jul 2003 12:52:47 +0000 (12:52 +0000)
committerpmasoudi <??>
Thu, 17 Jul 2003 12:52:47 +0000 (12:52 +0000)
helm/gtkmathview-bonobo/src/Makefile.am
helm/gtkmathview-bonobo/src/control-factory.c
helm/gtkmathview-bonobo/src/persist-file.c
helm/gtkmathview-bonobo/src/persist-file.h

index 013d93a5bbd5e85b6bf579ef855057b8f4c00fc6..b5dbb421b4095fb2a9cebb0ac92bd64e8e7e8f0a 100644 (file)
@@ -5,10 +5,12 @@ libgtkmathview_bonobo_la_LIBADD = $(GTKMATHVIEW_LIBS) $(BONOBOUI_LIBS) $(BONOBO_
 libgtkmathview_bonobo_la_LDFLAGS = -version-info @GTKMATHVIEW_CONTROL_VERSION_INFO@
 
 libgtkmathview_bonobo_la_SOURCES = \
-  control-factory.c
+  control-factory.c \
+  persist-file.c
 
 pkginclude_HEADERS = \
-  control-factory.h
+  control-factory.h \
+  persist-file.h
 
 INCLUDES = \
   $(BONOBOUI_CFLAGS) \
index ba20733cf6f5e42db994d27564a1514ff9a52609..5039e34ac2a374c8e8c671b2ba948b5d74d59dd8 100644 (file)
@@ -211,16 +211,15 @@ gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* compon
   BonoboControl *control;
   BonoboPropertyBag *prop_bag;
   GtkWidget *math_view;
+  BonoboObject *persist_file;
        
   math_view = gtk_math_view_new(NULL,NULL);
   gtk_widget_show(math_view);
 
   control = bonobo_control_new(math_view);
 
-  /*
   persist_file = gtk_math_view_persist_file_new(GTK_MATH_VIEW(math_view));
   bonobo_object_add_interface(BONOBO_OBJECT(control), persist_file);
-  */
 
   prop_bag = bonobo_property_bag_new(get_prop, set_prop, math_view);
   bonobo_control_set_properties(control, BONOBO_OBJREF(prop_bag), NULL);
index f1505b50cbaf7451401c20e521c5d06f829e6887..68914ded4133fe07d42ab3c4f7c2f470a8a4a195 100644 (file)
@@ -1,18 +1,23 @@
 #include <bonobo.h>
-#include <gtk_math_view.h>
+#include <gtkmathview.h>
 #include <glib.h>
-
+#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,19 @@ static void finalize(GObject *object)
 static Bonobo_Persist_ContentTypeList *
 get_content_types(BonoboPersist *persist,CORBA_Environment *ev)
 {
-       return bonobo_persist_generate_content_types();
+       //FIXME: il tipo di dato non e` noto
+       return bonobo_persist_generate_content_types(0);
 }
 
+
 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;
 
+       printf("persist file class init\n");
        gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass);
 
        epv->load = load_implementation;
@@ -45,15 +53,16 @@ GType
 gtk_math_view_persist_file_get_type(void)
 {
        static GType type = 0;
+       printf("persist file get type\n");
        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 +70,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;
@@ -72,30 +81,33 @@ 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_PRESIST(file), CONTROL_FACTORY_ID);
+       bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID);
 
        g_object_ref(math_view);
-       GTK_MATH_VIEW_PRESIST_FILE (file) = math_view;
+       GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view;
 
        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){
+       GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant));
+       //fd = open(path, O_RDONLY);
+               
+       result = gtk_math_view_load_uri(file->math_view,path);
+       if(!result)
+       {
                CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL);
-               return;
        }
        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",
index feef4598b34f77d34d4becb81cbb9917272a5b71..eb2b113f4313297ec9b75d4109f9e4b0a35411b7 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef _GTK_MATH_VIEW_PERSIST_FILE_H_
+#ifndef _GTK_MATH_VIEW_PERSIST_FILE_H_
 #define _GTK_MATH_VIEW_PERSIST_FILE_H_
 
 #include <bonobo/bonobo-persist.h>