]> matita.cs.unibo.it Git - helm.git/commitdiff
scrollbars added & control structure screated
authorpmasoudi <??>
Thu, 4 Sep 2003 15:05:48 +0000 (15:05 +0000)
committerpmasoudi <??>
Thu, 4 Sep 2003 15:05:48 +0000 (15:05 +0000)
helm/gtkmathview-bonobo/src/control-factory.c
helm/gtkmathview-bonobo/src/persist-file.c
helm/gtkmathview-bonobo/src/persist-stream.c
helm/gtkmathview-bonobo/src/persist-stream.h

index 025e645e93ce3e057170659da926c42e2d65f6b0..bfed0d5b82db85598c33990dfd1f4a433a9a08cd 100644 (file)
@@ -3,6 +3,11 @@
 #include <gtkmathview.h>
 #include "control-factory.h"
 
+typedef struct _GtkMathViewControlData
+{
+        GtkMathView *math_view;
+} GtkMathViewControlData;
+
 enum {
   MATH_VIEW_WIDTH,
   MATH_VIEW_HEIGHT,
@@ -16,13 +21,22 @@ enum {
 } math_args;
 
 
-/*static char *
-make_reg_id(const char *iid)
+static GtkMathViewControlData*
+gtk_math_view_control_data_new(GtkMathView *math_view)
 {
-       char *id;
-       id = bonobo_activation_make_registration_id(iid,Display_String(gdk_display));
-       return id;
-}*/
+       GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1);
+       cd->math_view = math_view;
+       return cd;
+}
+
+static void
+gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
+{
+       //gtk_object_unref(cd->math_view);
+       cd->math_view = NULL;
+
+       g_free(cd);
+}
 
 static void
 get_prop(BonoboPropertyBag     *bag,
@@ -130,18 +144,6 @@ set_prop(BonoboPropertyBag *bag,
 
   switch(arg_id)
     {
-      /*case MATH_VIEW_WIDTH:
-       g_assert(arg->_type == BONOBO_ARG_INT);
-                       
-       guint i = gtk_math_view_set_width(math_view);
-       BONOBO_ARG_SET_INT(arg,i);
-       break;
-       case MATH_VIEW_HEIGHT:
-       g_assert(arg->_type == BONOBO_ARG_INT);
-                       
-       guint i = gtk_math_view_get_height(math_view);
-       BONOBO_ARG_SET_INT(arg,i);      
-       break;*/
     case MATH_VIEW_TOP_X:
       {
        guint old_top_y;
@@ -204,19 +206,43 @@ set_prop(BonoboPropertyBag        *bag,
     }
 }
 
-static BonoboObject*
-gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* component_id, gpointer closure)
+static void 
+control_destroy(BonoboObject *object,GtkMathViewControlData *cd)
 {
-  BonoboControl *control;
-  BonoboPropertyBag *prop_bag;
+       gtk_math_view_control_data_destroy(cd);
+}
+
+static void 
+set_frame(BonoboControl *control,gpointer data)
+{
+    Bonobo_UIContainer remote_ui_container;
+    BonoboUIComponent *ui_component;
+    GtkMathViewControlData *control_data;
+    GtkWidget *scrolled_window;
+    Bonobo_ControlFrame frame;
+    
+    control_data = (GtkMathViewControlData *) data;
+}
+
+static void 
+gtk_math_view_control_init(BonoboControl *control,GtkWidget *scrolled_window)
+{
+  GtkMathViewControlData *control_data;
   GtkWidget *math_view;
+  Bonobo_UIContainer remote_ui_container;
+  BonoboUIComponent *ui_component;
+  
+  BonoboPropertyBag *prop_bag;
   BonoboObject *persist_file;
   BonoboObject *persist_stream;
-       
+  
   math_view = gtk_math_view_new(NULL,NULL);
   gtk_widget_show(math_view);
-
-  control = bonobo_control_new(math_view);
+  
+  control_data = gtk_math_view_control_data_new((GtkMathView*)math_view);
+  g_signal_connect (control, "destroy", G_CALLBACK (control_destroy), control_data);
+  
+  gtk_container_add(GTK_CONTAINER (scrolled_window), GTK_WIDGET (control_data->math_view));
 
   persist_file = gtk_math_view_persist_file_new(GTK_MATH_VIEW(math_view));
   bonobo_object_add_interface(BONOBO_OBJECT(control), persist_file);
@@ -247,10 +273,30 @@ gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* compon
                          NULL,"font_manager",0);
 
   bonobo_object_unref(BONOBO_OBJECT(prop_bag));
-  //bonobo_object_unref(BONOBO_OBJECT(persist_file));
-  //bonobo_object_unref(BONOBO_OBJECT(persist_stream));
+  
+  g_signal_connect(control,"set_frame",G_CALLBACK(set_frame),control_data);
+}
+
+static BonoboObject*
+gtk_math_view_control_factory(BonoboGenericFactory* factory, const gchar* component_id, gpointer closure)
+{
+  BonoboControl *control;
+  GtkWidget *scrolled_window;
+  
+  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+  gtk_widget_show_all (scrolled_window);
+  
+  control = bonobo_control_new(scrolled_window);
 
-  return BONOBO_OBJECT(control);
+  if(control)
+  {
+         gtk_math_view_control_init(control,scrolled_window);
+         return BONOBO_OBJECT(control);
+  }
+  else
+         return NULL;
 }
 
 BONOBO_ACTIVATION_SHLIB_FACTORY (CONTROL_FACTORY_ID, "GtkMathView Factory", gtk_math_view_control_factory, NULL);
index 5380ec42c3a0b0d3953df4cdeaac3195e9e2ecf1..9f2da1bee4599b5cba70698df7b81913c73b8c45 100644 (file)
@@ -91,7 +91,9 @@ gtk_math_view_persist_file_new(GtkMathView *math_view)
   g_object_ref(math_view);
   GTK_MATH_VIEW_PERSIST_FILE(file)->math_view = math_view;
 
-  printf("OK\n");
+#ifdef DEBUG
+  printf("gtk_math_view_persist_file_new passed\n");
+#endif
 
   return file;
 }
index c816048db3bc568e09bcf57763697a627df2097c..f971b721be07fea138935fd1c1bc450133903b84 100644 (file)
@@ -147,25 +147,24 @@ load_implementation(PortableServer_Servant servant,
                      ex_Bonobo_Persist_WrongDataType, NULL);
         return;
     }
-
+    
     tmpfile = create_tmp_file(persist);
     do {
         Bonobo_Stream_read (stream, 4096, &buffer, ev);
-        
         if (ev->_major != CORBA_NO_EXCEPTION) {
-         printf("*** eccezione 1\n");
-         goto clean;
-       }
-
+            printf("*** eccezione 1 %s\n",ev->_major);
+            goto clean;
+        }
+        
         len_read = buffer->_length;
-       printf("letti %d bytes\n", len_read);
+           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");
+                   printf("*** eccezione 2\n");
                 goto clean;
-        }
+            }
         
         CORBA_free (buffer);
     } while (len_read > 0);
index 88e3682ab6ca5586b2d2a3c77818cb38ee7d1938..e90012623deb184184f6e5f9847643885da0b617 100644 (file)
@@ -31,7 +31,7 @@ typedef struct{
 }GtkMathViewPersistStreamClass;
 
 GType   gtk_math_view_persist_stream_get_type(void);
-BonoboObject       *gtk_math_view_persist_stream_new(GtkMathView *math_view);
+//BonoboObject       *gtk_math_view_persist_stream_new(GtkMathView *math_view);
 
 G_END_DECLS