X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fcontrol-data.c;h=d97d0fd2f77700338a039c1f33b8e4b2f12b2952;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=8668a3867b87f79aca1bf72557d94aa71c59457c;hpb=2a9857d047063f36dfd15b0e07902bde1dd3d466;p=helm.git diff --git a/helm/gtkmathview-bonobo/src/control-data.c b/helm/gtkmathview-bonobo/src/control-data.c index 8668a3867..d97d0fd2f 100644 --- a/helm/gtkmathview-bonobo/src/control-data.c +++ b/helm/gtkmathview-bonobo/src/control-data.c @@ -28,14 +28,19 @@ #include "control-data.h" GtkMathViewControlData* -gtk_math_view_control_data_new(GtkMathView *math_view) +gtk_math_view_control_data_new(BonoboControl* control, GtkMathView *math_view) { GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1); + cd->control = control; /* we don't ref the control this is a weak pointer */ cd->math_view = math_view; + gtk_widget_ref(GTK_WIDGET(math_view)); + cd->item_factory = NULL; + cd->semantic_selection = FALSE; cd->first_selected = NULL; cd->root_selected = NULL; cd->id_ns_uri = gdome_str_mkref("http://www.cs.unibo.it/helm"); cd->id_name = gdome_str_mkref("xref"); + cd->x = cd->y = 0; return cd; } @@ -43,8 +48,14 @@ void gtk_math_view_control_data_destroy(GtkMathViewControlData* cd) { GdomeException exc = 0; - //gtk_object_unref(cd->math_view); + cd->control = NULL; /* don't unref the control, see above */ + gtk_widget_unref(GTK_WIDGET(cd->math_view)); cd->math_view = NULL; + if (cd->item_factory != NULL) + { + gtk_object_unref(cd->item_factory); + cd->item_factory = NULL; + } if (cd->first_selected != NULL) { gdome_el_unref(cd->first_selected, &exc); @@ -99,3 +110,29 @@ gtk_math_view_control_data_set_id_name(GtkMathViewControlData* cd, const gchar* if (cd->id_name != NULL) gdome_str_unref(cd->id_name); cd->id_name = (name != NULL) ? gdome_str_mkref_dup(name) : NULL; } + +void +gtk_math_view_control_data_set_root_selected(GtkMathViewControlData* cd, GdomeElement* elem) +{ + g_return_if_fail(cd != NULL); + GdomeException exc = 0; + + gtk_math_view_freeze(cd->math_view); + + if (cd->root_selected != NULL) + { + gtk_math_view_unselect(cd->math_view, cd->root_selected); + gdome_el_unref(cd->root_selected, &exc); + g_assert(exc == 0); + } + + cd->root_selected = elem; + if (cd->root_selected != NULL) + { + gdome_el_ref(cd->root_selected, &exc); + g_assert(exc == 0); + gtk_math_view_select(cd->math_view, cd->root_selected); + } + + gtk_math_view_thaw(cd->math_view); +}