1 /* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView.
2 * Copyright (C) 2003 Luca Padovani <lpadovan@cs.unibo.it>
3 * Pouria Masoudi <pmasoudi@cs.unibo.it>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * For more information, please visit the project's home page
20 * http://helm.cs.unibo.it/gtkmathview-bonobo
21 * or send an email to <lpadovan@cs.unibo.it>
30 set_clipboard(GdomeDOMString* data)
32 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
33 gtk_clipboard_set_text(clipboard, data->str, gdome_str_length(data));
37 set_frame(BonoboControl *control, gpointer data)
42 click_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
43 GtkMathViewControlData* control_data)
45 GdomeException exc = 0;
47 g_return_if_fail(math_view != NULL);
48 g_return_if_fail(control_data != NULL);
53 GdomeDOMString* href = find_hyperlink(elem);
57 /*gtk_math_view_load_uri(math_view,href->str);*/
59 gdome_str_unref(href);
63 action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction");
66 gtk_math_view_freeze(math_view);
67 action_toggle(action);
68 gtk_math_view_thaw(math_view);
69 gdome_el_unref(action, &exc);
75 if (control_data->root_selected != NULL)
77 gtk_math_view_freeze(math_view);
78 gtk_math_view_unselect(math_view, control_data->root_selected);
79 gtk_math_view_thaw(math_view);
80 gdome_el_unref(control_data->root_selected, &exc);
82 control_data->root_selected = NULL;
87 select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
88 GtkMathViewControlData* control_data)
90 g_return_if_fail(math_view != NULL);
91 g_return_if_fail(control_data != NULL);
95 GdomeException exc = 0;
96 gtk_math_view_freeze(math_view);
97 if (control_data->root_selected != NULL)
99 gtk_math_view_unselect(math_view, control_data->root_selected);
100 gdome_el_unref(control_data->root_selected, &exc);
102 control_data->root_selected = NULL;
105 if (control_data->semantic_selection)
107 GdomeElement* new_elem = find_element_with_id(elem, control_data->id_ns_uri, control_data->id_name);
108 if (new_elem != NULL)
110 gdome_el_ref(new_elem, &exc);
113 control_data->first_selected = control_data->root_selected = new_elem;
117 gdome_el_ref(elem, &exc);
119 gdome_el_ref(elem, &exc);
121 control_data->first_selected = control_data->root_selected = elem;
124 if (control_data->root_selected != NULL)
125 gtk_math_view_select(math_view, control_data->root_selected);
127 gtk_math_view_thaw(math_view);
132 select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
133 GtkMathViewControlData* control_data)
135 g_return_if_fail(math_view != NULL);
136 g_return_if_fail(control_data != NULL);
138 if (control_data->first_selected != NULL && elem != NULL)
140 GdomeException exc = 0;
142 gtk_math_view_freeze(math_view);
144 if (control_data->root_selected != NULL)
146 gtk_math_view_unselect(math_view, control_data->root_selected);
147 gdome_el_unref(control_data->root_selected, &exc);
149 control_data->root_selected = NULL;
152 if (control_data->semantic_selection)
154 GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem);
155 if (new_root != NULL)
157 control_data->root_selected = find_element_with_id(new_root, control_data->id_ns_uri, control_data->id_name);
158 gdome_el_unref(new_root, &exc);
162 control_data->root_selected = NULL;
165 control_data->root_selected = find_common_ancestor(control_data->first_selected, elem);
167 if (control_data->root_selected != NULL)
168 gtk_math_view_select(math_view, control_data->root_selected);
170 gtk_math_view_thaw(math_view);
175 select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
176 GtkMathViewControlData* control_data)
178 g_return_if_fail(math_view != NULL);
179 g_return_if_fail(control_data != NULL);
181 if (control_data->first_selected != NULL)
183 GdomeException exc = 0;
184 gdome_el_unref(control_data->first_selected, &exc);
186 control_data->first_selected = NULL;
188 if (control_data->root_selected != NULL && control_data->semantic_selection)
190 GdomeException exc = 0;
191 GdomeDOMString* id = gdome_el_getAttributeNS(control_data->root_selected,
192 control_data->id_ns_uri,
193 control_data->id_name, &exc);
195 g_assert(id != NULL);
203 select_abort_cb(GtkMathView* math_view, GtkMathViewControlData* control_data)
205 GdomeException exc = 0;
207 g_return_if_fail(math_view != NULL);
208 g_return_if_fail(control_data != NULL);
210 if (control_data->first_selected != NULL)
212 gdome_el_unref(control_data->first_selected, &exc);
214 control_data->first_selected = NULL;
217 if (control_data->root_selected != NULL)
219 gtk_math_view_freeze(math_view);
220 gtk_math_view_unselect(math_view, control_data->root_selected);
221 gtk_math_view_thaw(math_view);
222 gdome_el_unref(control_data->root_selected, &exc);
224 control_data->root_selected = NULL;