X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fcontrol-data.c;h=b4885bf2afdb68343415bfbd3cea3755603f6f55;hb=4faf0e37e7019de16dd6862bb34d84f799a2a230;hp=8668a3867b87f79aca1bf72557d94aa71c59457c;hpb=fc35fbb35a01c110f221c52661f1193ea5664aa6;p=helm.git diff --git a/helm/gtkmathview-bonobo/src/control-data.c b/helm/gtkmathview-bonobo/src/control-data.c index 8668a3867..b4885bf2a 100644 --- a/helm/gtkmathview-bonobo/src/control-data.c +++ b/helm/gtkmathview-bonobo/src/control-data.c @@ -32,10 +32,14 @@ gtk_math_view_control_data_new(GtkMathView *math_view) { GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1); 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 +47,13 @@ void gtk_math_view_control_data_destroy(GtkMathViewControlData* cd) { GdomeException exc = 0; - //gtk_object_unref(cd->math_view); + 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 +108,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); +}