]> matita.cs.unibo.it Git - helm.git/commitdiff
persist file with factory.
authorpmasoudi <??>
Wed, 16 Jul 2003 16:13:29 +0000 (16:13 +0000)
committerpmasoudi <??>
Wed, 16 Jul 2003 16:13:29 +0000 (16:13 +0000)
helm/gtkmathview-bonobo/src/control-factory.c
helm/gtkmathview-bonobo/src/control-factory.h
helm/gtkmathview-bonobo/src/persist-file.c

index 3b24af7eee564c84fde850aa7ac92fd6e6bf6d2f..c0bda201bcefd77b14edeb89f87cff614d71f83f 100644 (file)
@@ -267,3 +267,65 @@ notify_property_bag(GtkMathView *math_view,gpointer data)
 
   //bonobo_property_bag_notify_listeners(prop_bag,);
 }
+
+/*
+GtkMathViewPresistFile *
+gtk_math_view_bonobo_data_construct(gchar *data_file)
+{
+       BonoboObject *retval;
+       BonoboPersistFile *file;
+
+       file = bonobo_persist_file_new(gtk_math_view_load_from_file,
+                       gtk_math_view_save_to_file,
+                       "OAFIID:GNOME_MATH_VIEW_FILE_Control",
+                       data_file);
+
+       if(file == NULL)
+       {
+               bonobo_object_unref(BONOBO_OBJECT (data_file));
+               g_warning("gtk_math_view_bonobo_data_construct:unable to create a new file");
+               return NULL;
+       }
+
+       bonobo_object_add_interface(BONOBO_OBJECT(data_file),
+                                       BONOBO_OBJECT(file));
+       return data_file;
+}
+
+static gint
+gtk_math_view_bonobo_load_from_file(BonoboPresistFile  *pf,
+               const CORBA_char        *filename,
+               CORBA_Environment       *ev,
+               void                    *closure)
+{
+       Bonobo_PersistStream ps = closure;
+       BonoboStream *stream;
+
+       g_return_val_if_fail (data != NULL, -1);
+       //FIXME: controllo del tipo di dato in input
+       
+       stram = bonobo_stream_open(
+                       BONOBO_IO_DRIVER_FS,
+                       filename,Bonobo_STORAGE_READ,
+                       0);
+       if(!stream)
+               return 0;
+
+       //FIXME:I have to extract content type from file
+               
+       
+       Bonobo_PersistStream_load(ps, type, ev);
+       
+       return 1;  //return 1 on success
+}
+
+static gint 
+gtk_math_view_bonobo_save_to_file(BonoboPresistFile            *pf,
+               const CORBA_char        *filename,
+               CORBA_Environment       *ev,
+               void                    *closure)
+{
+       return 1;   //return 1 on success
+}*/
+
+
index 68830bc87ab5baceaf2afa3e423bc034afacfba4..739d02cd601274edd9b9fad92362c52381dcf785 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, 
  * Boston, MA 02111-1307, USA.
  */
+
+#ifdef GTK_MATH_VIEW_CONTROL_FACTORY_H_
+#define GTK_MATH_VIEW_CONTROL_FACTORY_H_
+
 #include <bonobo.h>
 #include <glib.h>
 #include <bonobo/bonobo-control.h>
-
 #include <gtkmathview.h>
 
+#define CONTROL_FACTORY_ID     "OAFIID:GNOME_GtkMathView_Factory:" MATH_VIEW_API_VERSION
+#define CONTROL_ID             "OAFIID:GNOME_GtkMathView:" MATH_VIEW_API_VERSION
 
 enum math_args;
 
+BonoboObject *gtk_math_view_control_factory(BonoboGenericFactory *factory,const gchar *component_id, gpointer closure);
 static void get_prop(BonoboPropertyBag*, BonoboArg *, guint , CorbaEnvironment*, gpointer);
 static void set_prop(BonoboPropertyBag*, BonoboArg *, guint , CorbaEnvironment*, gpointer);
 
@@ -33,4 +39,4 @@ static BonoboControl* instantiate_func(void);
 
 static void notify_property_bag(GtkMathView* ,gpointer);
 
-
+#endif
index eceb4e77a31cbb5bb6a88e3b544113eefddec4f5..f1505b50cbaf7451401c20e521c5d06f829e6887 100644 (file)
@@ -82,71 +82,23 @@ gtk_math_view_persist_file_new(GtkMathView *math_view)
 }
 
 static void
-load_implementation(PortableServer_Servant servant,const CORBA_char *path,CORBA_Environment *ev)
+load_implementation(const gchar *path,CORBA_Environment *ev)
 {
-       GtkMathViewPersistFile *file = GTK_MATH_VIEW_
-}
-
-Dom::Document *
-gtk_math_view_bonobo_data_construct(Dom::Document *data_file)
-{
-       BonoboObject *retval;
-       BonoboPersistFile *file;
-
-       file = bonobo_persist_file_new(gtk_math_view_load_from_file,
-                       gtk_math_view_save_to_file,
-                       "OAFIID:GNOME_MATH_VIEW_FILE_Control",
-                       data_file);
-
-       if(file == NULL)
-       {
-               bonobo_object_unref(BONOBO_OBJECT (data_file));
-               return NULL;
+       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;
        }
-
-       bonobo_object_add_interface(BONOBO_OBJECT(data_file),
-                                       BONOBO_OBJECT(file));
-       return data_file;
-}
-
-
+       return ;
 }
 
-
-static gint
-gtk_math_view_bonobo_load_from_file(BonoboPresistFile  *pf,
-               const CORBA_char        *filename,
-               CORBA_Environment       *ev,
-               void                    *closure)
-{
-       Bonobo_PersistStream ps = closure;
-       BonoboStream *stream;
-
-       g_return_val_if_fail (data != NULL, -1);
-       //FIXME: controllo del tipo di dato in input
-       
-       stram = bonobo_stream_open(
-                       BONOBO_IO_DRIVER_FS,
-                       filename,Bonobo_STORAGE_READ,
-                       0);
-       if(!stream)
-               return 0;
-
-       //FIXME:I have to extract content type from file
-               
-       
-       Bonobo_PersistStream_load(ps, type, ev);
-       
-       return 1;  //return 1 on success
-}
-
-static gint 
-gtk_math_view_bonobo_save_to_file(BonoboPresistFile            *pf,
-               const CORBA_char        *filename,
-               CORBA_Environment       *ev,
-               void                    *closure)
+static void
+save_implementation(const gchar *path,CORBA_Environment *ev)
 {
-       return 1;   //return 1 on success
+       bonobo_exception_set(ev,"save_exception");
+       bonobo_exception_add_handler_str("save_exception",
+                                         "Save option is not valid");
+       return;
 }
-
-