From: pmasoudi Date: Thu, 4 Sep 2003 15:05:48 +0000 (+0000) Subject: scrollbars added & control structure screated X-Git-Tag: v0_0_1~51 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=914b0da7aa23c8d11db1e415c56594ac52972b58;p=helm.git scrollbars added & control structure screated --- diff --git a/helm/gtkmathview-bonobo/src/control-factory.c b/helm/gtkmathview-bonobo/src/control-factory.c index 025e645e9..bfed0d5b8 100644 --- a/helm/gtkmathview-bonobo/src/control-factory.c +++ b/helm/gtkmathview-bonobo/src/control-factory.c @@ -3,6 +3,11 @@ #include #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); diff --git a/helm/gtkmathview-bonobo/src/persist-file.c b/helm/gtkmathview-bonobo/src/persist-file.c index 5380ec42c..9f2da1bee 100644 --- a/helm/gtkmathview-bonobo/src/persist-file.c +++ b/helm/gtkmathview-bonobo/src/persist-file.c @@ -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; } diff --git a/helm/gtkmathview-bonobo/src/persist-stream.c b/helm/gtkmathview-bonobo/src/persist-stream.c index c816048db..f971b721b 100644 --- a/helm/gtkmathview-bonobo/src/persist-stream.c +++ b/helm/gtkmathview-bonobo/src/persist-stream.c @@ -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); diff --git a/helm/gtkmathview-bonobo/src/persist-stream.h b/helm/gtkmathview-bonobo/src/persist-stream.h index 88e3682ab..e90012623 100644 --- a/helm/gtkmathview-bonobo/src/persist-stream.h +++ b/helm/gtkmathview-bonobo/src/persist-stream.h @@ -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