]> matita.cs.unibo.it Git - helm.git/blob - helm/gtkmathview-bonobo/src/control-data.c
* advanced implementation of View interface
[helm.git] / helm / gtkmathview-bonobo / src / control-data.c
1
2 #include "control-data.h"
3
4 GtkMathViewControlData*
5 gtk_math_view_control_data_new(GtkMathView *math_view)
6 {
7   GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1);
8   cd->math_view = math_view;
9   cd->semantic_selection = FALSE;
10   cd->first_selected = NULL;
11   cd->root_selected = NULL;
12   cd->id_ns_uri = NULL;
13   cd->id_name = NULL;
14   return cd;
15 }
16
17 void
18 gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
19 {
20   GdomeException exc = 0;
21   //gtk_object_unref(cd->math_view);
22   cd->math_view = NULL;
23   if (cd->first_selected != NULL)
24     {
25       gdome_el_unref(cd->first_selected, &exc);
26       g_assert(exc == 0);
27       cd->first_selected = NULL;
28     }
29   if (cd->root_selected != NULL)
30     {
31       gdome_el_unref(cd->root_selected, &exc);
32       g_assert(exc == 0);
33       cd->root_selected = NULL;
34     }
35   if (cd->id_ns_uri != NULL)
36     {
37       gdome_str_unref(cd->id_ns_uri);
38       cd->id_ns_uri = NULL;
39     }
40   if (cd->id_name != NULL)
41     {
42       gdome_str_unref(cd->id_name);
43       cd->id_name = NULL;
44     }
45   g_free(cd);
46 }
47
48 void
49 gtk_math_view_control_data_set_id_attribute(GtkMathViewControlData* cd,
50                                             const char* ns_uri, const char* name)
51 {
52   g_return_if_fail(cd != NULL);
53   if (cd->id_ns_uri != NULL)
54     {
55       gdome_str_unref(cd->id_ns_uri);
56       cd->id_ns_uri = NULL;
57     }
58   if (cd->id_name != NULL)
59     {
60       gdome_str_unref(cd->id_name);
61       cd->id_name = NULL;
62     }
63   if (ns_uri) cd->id_ns_uri = gdome_str_mkref(ns_uri);
64   if (name) cd->id_name = gdome_str_mkref(name);
65 }