]> matita.cs.unibo.it Git - helm.git/blob - helm/gtkmathview-bonobo/src/control-data.c
* completed 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->first_selected = NULL;
10   cd->root_selected = NULL;
11   cd->id_ns_uri = NULL;
12   cd->id_name = NULL;
13   return cd;
14 }
15
16 void
17 gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
18 {
19   GdomeException exc = 0;
20   //gtk_object_unref(cd->math_view);
21   cd->math_view = NULL;
22   if (cd->first_selected != NULL)
23     {
24       gdome_el_unref(cd->first_selected, &exc);
25       g_assert(exc == 0);
26       cd->first_selected = NULL;
27     }
28   if (cd->root_selected != NULL)
29     {
30       gdome_el_unref(cd->root_selected, &exc);
31       g_assert(exc == 0);
32       cd->root_selected = NULL;
33     }
34   if (cd->id_ns_uri != NULL)
35     {
36       gdome_str_unref(cd->id_ns_uri);
37       cd->id_ns_uri = NULL;
38     }
39   if (cd->id_name != NULL)
40     {
41       gdome_str_unref(cd->id_name);
42       cd->id_name = NULL;
43     }
44   g_free(cd);
45 }
46
47 void
48 gtk_math_view_control_data_set_id_attribute(GtkMathViewControlData* cd,
49                                             const char* ns_uri, const char* name)
50 {
51   g_return_if_fail(cd != NULL);
52   if (cd->id_ns_uri != NULL)
53     {
54       gdome_str_unref(cd->id_ns_uri);
55       cd->id_ns_uri = NULL;
56     }
57   if (cd->id_name != NULL)
58     {
59       gdome_str_unref(cd->id_name);
60       cd->id_name = NULL;
61     }
62   if (ns_uri) cd->id_ns_uri = gdome_str_mkref(ns_uri);
63   if (name) cd->id_name = gdome_str_mkref(name);
64 }