]> matita.cs.unibo.it Git - helm.git/commitdiff
* a few adjustments and debugging messages added
authorLuca Padovani <luca.padovani@unito.it>
Fri, 1 Aug 2003 10:15:57 +0000 (10:15 +0000)
committerLuca Padovani <luca.padovani@unito.it>
Fri, 1 Aug 2003 10:15:57 +0000 (10:15 +0000)
* works as a component in mozilla

helm/gtkmathview-bonobo/src/GNOME_GtkMathView.server.in.in
helm/gtkmathview-bonobo/src/Makefile.am
helm/gtkmathview-bonobo/src/persist-file.c
helm/gtkmathview-bonobo/src/persist-stream.c
helm/gtkmathview-bonobo/test/main.c

index 28254bc09eb80588ac5f69f94aaf37bda7ddf3ee..5d4919470f03da2695cb49c1cf9f05fc83852f48 100644 (file)
@@ -15,8 +15,8 @@
                <oaf_attribute name="repo_ids" type="stringv">
                        <item value="IDL:Bonobo/Control:1.0"/>
                        <item value="IDL:Bonobo/Unkown:1.0"/>
-                       <item value="IDL:Bonobo/PersistStream:1.0"/>
                        <item value="IDL:Bonobo/PersistFile:1.0"/>
+                       <item value="IDL:Bonobo/PersistStream:1.0"/>
                        <item value="IDL:Bonobo/Persist:1.0"/>
                </oaf_attribute>
 
@@ -26,6 +26,7 @@
                <oaf_attribute name="bonobo:editable" type="boolean" value="false"/>
                <oaf_attribute name="bonobo:supported_mime_types" type="stringv">
                        <item value="application/mathml+xml"/>
+                       <item value="text/mathml"/>
                </oaf_attribute>
 </oaf_server>
 
index 0a887c22e99d89a19241f3a520ab24a47cd91d47..3abccce7c306b7a5551bb232a82c89e915662ffe 100644 (file)
@@ -12,7 +12,7 @@ libgtkmathview_bonobo_la_LDFLAGS = -version-info @GTKMATHVIEW_CONTROL_VERSION_IN
 
 libgtkmathview_bonobo_la_SOURCES = \
   control-factory.c \
-  persist-file.c    \
+  persist-file.c \
   persist-stream.c
 
 pkginclude_HEADERS = \
index 36b4536a45b215b52bc1105804c368b9a5523040..5380ec42c3a0b0d3953df4cdeaac3195e9e2ecf1 100644 (file)
@@ -27,8 +27,7 @@ static void finalize(GObject *object)
 static Bonobo_Persist_ContentTypeList *
 get_content_types(BonoboPersist *persist,CORBA_Environment *ev)
 {
-       //FIXME: il tipo di dato non e` noto
-       return bonobo_persist_generate_content_types(0);
+  return bonobo_persist_generate_content_types(3, "application/mathml+xml", "text/mathml", "text/plain");
 }
 
 
@@ -83,32 +82,37 @@ gtk_math_view_persist_file_get_type(void)
 BonoboObject *
 gtk_math_view_persist_file_new(GtkMathView *math_view)
 {
-       BonoboObject *file;
+  BonoboObject *file;
 
-       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);
+  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_PERSIST_FILE(file)->math_view = math_view;
+  g_object_ref(math_view);
+  GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view;
 
-       return file;
+  printf("OK\n");
+
+  return file;
 }
 
 static void
 load_implementation(PortableServer_Servant servant,const gchar *path,CORBA_Environment *ev)
 {
-       gboolean 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);
-       }
-    bonobo_object_unref(BONOBO_OBJECT(file));
-       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
index 815606bde487a2764884bea46b79bcc4edea2f80..6367f7453f1de7035557eb90751f02c418fc32eb 100644 (file)
@@ -33,8 +33,7 @@ static void finalize(GObject *object)
 static Bonobo_Persist_ContentTypeList *
 get_content_types(BonoboPersist *persist,CORBA_Environment *ev)
 {
-       //FIXME:il tipo di dato non e` noto
-       return bonobo_persist_generate_content_types(0);
+  return bonobo_persist_generate_content_types(2, "application/mathml+xml", "text/mathml");
 }
 
 static void 
@@ -108,12 +107,13 @@ create_tmp_file(GtkMathViewPersistStream *persist)
     FILE *tmpfile;
     int fd;
     
-    persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/ggvXXXXXX", NULL);
+    persist->tmp_path_name = g_strconcat(g_get_tmp_dir(), "/gmvXXXXXX", NULL);
     if((fd = mkstemp(persist->tmp_path_name)) < 0) {
         g_free(persist->tmp_path_name),
         persist->tmp_path_name = NULL;
         return NULL;
     }
+    printf("salvo nel file %s\n", persist->tmp_path_name);
     tmpfile = fdopen(fd, "w");
     if(!tmpfile) {
         close(fd);
@@ -140,6 +140,8 @@ load_implementation(PortableServer_Servant servant,
     printf("persist stream loading\n");
 #endif
     
+    printf("type = %s\n", type);
+
     if (strcmp (type, "application/mathml+xml") != 0) {
         CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
                      ex_Bonobo_Persist_WrongDataType, NULL);
@@ -150,20 +152,23 @@ load_implementation(PortableServer_Servant servant,
     do {
         Bonobo_Stream_read (stream, 4096, &buffer, ev);
         
-        if (ev->_major != CORBA_NO_EXCEPTION || buffer->_length <= 0) {
-            CORBA_free (buffer);
-            goto clean;
-            }
+        if (ev->_major != CORBA_NO_EXCEPTION) {
+         printf("*** eccezione 1\n");
+         goto clean;
+       }
 
         len_read = buffer->_length;
+       printf("letti %d bytes\n", len_read);
+
         if (buffer->_buffer && len_read)
             if(fwrite(buffer->_buffer, 1, len_read, tmpfile) != len_read) {
                 CORBA_free (buffer);
+         printf("*** eccezione 2\n");
                 goto clean;
         }
         
         CORBA_free (buffer);
-    } while (1);
+    } while (len_read > 0);
 
     fclose(tmpfile);
     result = gtk_math_view_load_uri(persist->math_view,persist->tmp_path_name);
index fc9715e6d87107b1d1a8872f9c6329cf5b8c7a19..dccb6e63a570e25b6948f5003e99adf64550fd81 100644 (file)
@@ -46,14 +46,19 @@ load_through_persist_stream(const gchar *filename,
     CORBA_Environment ev;
     CORBA_exception_init (&ev);
 
+#if 0
+    stream = bonobo_stream_open ("fs", filename,
+                                Bonobo_Storage_READ, 0);
+#endif
+
     /*if (stream == NULL) 
     {
         g_warning ("Couldn't load `%s'\n", filename);
     } else*/ {
         Bonobo_Stream corba_stream;
-        //corba_stream = bonobo_object_corba_objref (stream);
-        //Bonobo_Stream_truncate (corba_stream, 0, &ev);
-        Bonobo_PersistStream_load (pstream, corba_stream,"",&ev);
+        corba_stream = bonobo_object_corba_objref (stream);
+        Bonobo_Stream_truncate (corba_stream, 0, &ev);
+        Bonobo_PersistStream_load (pstream, corba_stream, "application/mathml+xml", &ev);
     }
     Bonobo_Unknown_unref (pstream, &ev);
     CORBA_Object_release (pstream, &ev);
@@ -90,8 +95,8 @@ file_selection_ok_cb (GtkWidget *widget,
        (GTK_FILE_SELECTION (file_selection_info.widget));
        switch (file_selection_info.Operations) {
            case LOAD_STREAM:
-               load_through_persist_stream (fname, interface);
-               break;
+            load_through_persist_stream (fname, interface);
+            break;
            case LOAD_FILE:
                load_through_persist_file (fname, interface);
                break;