2 #include <gtkmathview.h>
4 #include "persist-file.h"
5 #include "control-factory.h"
7 static BonoboObjectClass *gtk_math_view_persist_file_parent_class;
9 static void load_implementation(PortableServer_Servant servant,const gchar *path,
10 CORBA_Environment *ev);
12 static void save_implementation(PortableServer_Servant servant,const gchar *path,
13 CORBA_Environment *ev);
15 static void finalize(GObject *object)
17 GtkMathViewPersistFile *file = GTK_MATH_VIEW_PERSIST_FILE(object);
20 g_object_unref(file->math_view);
21 file->math_view = NULL;
24 G_OBJECT_CLASS(gtk_math_view_persist_file_parent_class)->finalize (object);
27 static Bonobo_Persist_ContentTypeList *
28 get_content_types(BonoboPersist *persist,CORBA_Environment *ev)
30 //FIXME: il tipo di dato non e` noto
31 return bonobo_persist_generate_content_types(0);
36 gtk_math_view_persist_file_class_init(GtkMathViewPersistFileClass *klass)
38 GObjectClass *object_class = G_OBJECT_CLASS(klass);
39 BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass);
40 POA_Bonobo_PersistFile__epv *epv = &klass->epv;
42 printf("persist file class init\n");
43 gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass);
45 epv->load = load_implementation;
46 epv->save = save_implementation;
48 object_class->finalize = finalize;
49 persist_class->get_content_types = get_content_types;
53 gtk_math_view_persist_file_get_type(void)
55 static GType type = 0;
56 printf("persist file get type\n");
59 sizeof(GtkMathViewPersistFileClass),
61 (GBaseFinalizeFunc) NULL,
62 (GClassInitFunc) gtk_math_view_persist_file_class_init,
63 NULL, /* class finalize */
64 NULL, /* class_data */
65 sizeof(GtkMathViewPersistFile),
67 (GInstanceInitFunc) NULL
70 type = bonobo_type_unique(
72 POA_Bonobo_PersistFile__init,POA_Bonobo_PersistFile__fini,
73 G_STRUCT_OFFSET(GtkMathViewPersistFileClass, epv),
74 &info,"GtkMathViewPresistFile");
80 gtk_math_view_persist_file_new(GtkMathView *math_view)
84 printf("persist file new\n");
85 file = g_object_new(gtk_math_view_persist_file_get_type(),NULL);
86 bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID);
88 g_object_ref(math_view);
89 GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view;
95 load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev)
98 GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant));
99 //fd = open(path, O_RDONLY);
101 result = gtk_math_view_load_uri(file->math_view,path);
104 CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL);
110 save_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev)
112 bonobo_exception_set(ev,"save_exception");
113 bonobo_exception_add_handler_str("save_exception",
114 "Save option is not valid");