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 return bonobo_persist_generate_content_types(3, "application/mathml+xml", "text/mathml", "text/plain");
35 gtk_math_view_persist_file_class_init(GtkMathViewPersistFileClass *klass)
37 GObjectClass *object_class = G_OBJECT_CLASS(klass);
38 BonoboPersistClass *persist_class = BONOBO_PERSIST_CLASS(klass);
39 POA_Bonobo_PersistFile__epv *epv = &klass->epv;
42 printf("persist file class init\n");
44 gtk_math_view_persist_file_parent_class = g_type_class_peek_parent(klass);
46 epv->load = load_implementation;
47 epv->save = save_implementation;
49 object_class->finalize = finalize;
50 persist_class->get_content_types = get_content_types;
54 gtk_math_view_persist_file_get_type(void)
56 static GType type = 0;
58 printf("persist file get type\n");
62 sizeof(GtkMathViewPersistFileClass),
64 (GBaseFinalizeFunc) NULL,
65 (GClassInitFunc) gtk_math_view_persist_file_class_init,
66 NULL, /* class finalize */
67 NULL, /* class_data */
68 sizeof(GtkMathViewPersistFile),
70 (GInstanceInitFunc) NULL
73 type = bonobo_type_unique(
75 POA_Bonobo_PersistFile__init,POA_Bonobo_PersistFile__fini,
76 G_STRUCT_OFFSET(GtkMathViewPersistFileClass, epv),
77 &info,"GtkMathViewPresistFile");
83 gtk_math_view_persist_file_new(GtkMathView *math_view)
87 printf("persist file new\n");
88 file = g_object_new(gtk_math_view_persist_file_get_type(),NULL);
89 bonobo_persist_construct(BONOBO_PERSIST(file),CONTROL_FACTORY_ID);
91 g_object_ref(math_view);
92 GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view;
95 printf("gtk_math_view_persist_file_new passed\n");
102 load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev)
105 GtkMathViewPersistFile* file = GTK_MATH_VIEW_PERSIST_FILE(bonobo_object_from_servant(servant));
106 //fd = open(path, O_RDONLY);
108 printf("passing from here LOAD\n");
110 result = gtk_math_view_load_uri(file->math_view,path);
113 printf("exception here!\n");
114 CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Bonobo_Persist_WrongDataType,NULL);
116 bonobo_object_unref(BONOBO_OBJECT(file));
121 save_implementation(PortableServer_Servant servant,
123 CORBA_Environment *ev)
125 bonobo_exception_set(ev,"save_exception");
126 bonobo_exception_add_handler_str("save_exception",
127 "Save option is not valid");