X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fcontrol-factory.c;h=bfed0d5b82db85598c33990dfd1f4a433a9a08cd;hb=914b0da7aa23c8d11db1e415c56594ac52972b58;hp=025e645e93ce3e057170659da926c42e2d65f6b0;hpb=4f52daab3f629aaae5cec7ccd8cc720733a0c13e;p=helm.git 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);