]> matita.cs.unibo.it Git - helm.git/blob - helm/gtkmathview-bonobo/src/handlers.c
select and click signal added
[helm.git] / helm / gtkmathview-bonobo / src / handlers.c
1 #include "handlers.h"
2
3 void
4 set_frame(BonoboControl *control,gpointer data)
5 {     
6     /*Bonobo_UIContainer remote_ui_container;
7     BonoboUIComponent *ui_component;
8     GtkMathViewControlData *control_data;
9     GtkWidget *scrolled_window;
10     Bonobo_ControlFrame frame;
11     control_data = (GtkMathViewControlData *) data;*/
12 }
13
14 void
15 click_cb(GtkMathView* math_view, GdomeElement* elem, gint state, GtkMathViewControlData* control_data)
16 {
17   GdomeException exc;
18   GdomeDOMString* name;
19   GdomeDOMString* ns_uri;
20   //GdomeElement* p;
21   
22   g_return_if_fail(math_view != NULL);
23   
24   printf("*** click signal: %p %x %p\n", elem, state, control_data);
25   
26   if (elem != NULL)
27   {
28       GdomeElement* action;
29       GdomeDOMString* href = find_hyperlink(elem);
30       if (href != NULL)
31       {
32           /*    printf("hyperlink %s\n", href->str); */
33           gtk_math_view_load_uri(math_view,href->str);
34           gdome_str_unref(href);
35       }
36       else
37       {
38           action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction");
39           /*       printf("action? %p\n", action); */
40           if (action != NULL)
41           {
42                gtk_math_view_freeze(math_view);
43                action_toggle(action);
44                gtk_math_view_thaw(math_view);
45                gdome_el_unref(action, &exc);
46                g_assert(exc == 0);
47                return;
48           }
49       }
50       if (control_data->root_selected != NULL)
51       {
52         gtk_math_view_freeze(math_view);
53         gtk_math_view_unselect(math_view, control_data->root_selected);
54         gtk_math_view_thaw(math_view);
55         gdome_el_unref(control_data->root_selected, &exc);
56         g_assert(exc == 0);
57         control_data->root_selected = NULL;
58       }
59   }
60 }
61
62 void
63 select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state,GtkMathViewControlData* control_data)
64 {
65   g_return_if_fail(math_view != NULL);
66   g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
67   printf("*** select_begin signal: %p %x\n", elem, state);
68   if (elem != NULL)
69     {
70       GdomeException exc = 0;
71       gtk_math_view_freeze(math_view);
72       if (control_data->root_selected != NULL)
73       {
74         gtk_math_view_unselect(math_view,control_data->root_selected);
75         gdome_el_unref(control_data->root_selected, &exc);
76         g_assert(exc == 0);
77         control_data->root_selected = NULL;
78       }
79       
80       if (control_data->semantic_selection)
81       {
82         GdomeElement* new_elem = find_xref_element(elem);
83         if (new_elem != NULL)
84         {
85           gdome_el_ref(new_elem, &exc);
86           g_assert(exc == 0);
87         }
88         control_data->first_selected = control_data->root_selected = new_elem;
89       }
90       else
91       {
92         gdome_el_ref(elem, &exc);
93         g_assert(exc == 0);
94         gdome_el_ref(elem, &exc);
95         g_assert(exc == 0);
96         control_data->first_selected = control_data->root_selected = elem;
97       }
98       
99       if (control_data->root_selected != NULL)
100           gtk_math_view_select(math_view, control_data->root_selected);
101       
102       gtk_math_view_thaw(math_view);
103     }
104 }
105
106 void
107 select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state,GtkMathViewControlData* control_data)
108 {
109   g_return_if_fail(math_view != NULL);
110   g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
111
112   printf("*** select_over signal: %p %x\n", elem, state);
113
114   if (control_data->first_selected != NULL && elem != NULL)
115     {
116       GdomeException exc = 0;
117
118       gtk_math_view_freeze(math_view);
119
120       if (control_data->root_selected != NULL)
121       {
122           gtk_math_view_unselect(math_view, control_data->root_selected);
123           gdome_el_unref(control_data->root_selected, &exc);
124           g_assert(exc == 0);
125           control_data->root_selected = NULL;
126       }
127
128       if (control_data->semantic_selection)
129       {
130         GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem);
131         if (new_root != NULL)
132         {
133           control_data->root_selected = find_xref_element(new_root);
134           gdome_el_unref(new_root, &exc);
135           g_assert(exc == 0);
136         }
137       else
138         control_data->root_selected = NULL;
139       }
140       else
141         control_data->root_selected = find_common_ancestor(control_data->first_selected, elem);
142
143       if (control_data->root_selected != NULL)
144         gtk_math_view_select(math_view, control_data->root_selected);
145
146       gtk_math_view_thaw(math_view);
147     }
148 }
149
150 void
151 select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state,GtkMathViewControlData* control_data)
152 {
153   g_return_if_fail(math_view != NULL);
154   g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
155   
156   printf("*** select_end signal: %p %x\n", elem, state);
157   
158   if (control_data->first_selected != NULL)
159   {
160       GdomeException exc = 0;
161       gdome_el_unref(control_data->first_selected, &exc);
162       g_assert(exc == 0);
163       control_data->first_selected = NULL;
164   }
165 }
166
167 void
168 select_abort_cb(GtkMathView* math_view,GtkMathViewControlData* control_data)
169 {
170   GdomeException exc = 0;
171   
172   g_return_if_fail(math_view != NULL);
173   g_return_if_fail(GTK_IS_MATH_VIEW(math_view));
174   
175   printf("*** select_abort signal\n");
176   
177   if (control_data->first_selected != NULL)
178   {
179       gdome_el_unref(control_data->first_selected, &exc);
180       g_assert(exc == 0);
181       control_data->first_selected = NULL;
182   }
183   if (control_data->root_selected != NULL)
184     {
185       gtk_math_view_freeze(math_view);
186       gtk_math_view_unselect(math_view, control_data->root_selected);
187       gtk_math_view_thaw(math_view);
188       gdome_el_unref(control_data->root_selected, &exc);
189       g_assert(exc == 0);
190       control_data->root_selected = NULL;
191     }
192 }
193