X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2Fgtkmathview-bonobo%2Fsrc%2Fhandlers.c;fp=helm%2Fgtkmathview-bonobo%2Fsrc%2Fhandlers.c;h=0000000000000000000000000000000000000000;hp=4861b2f0b0ec6f7205d3be03e5a2c79ae80fc396;hb=1696761e4b8576e8ed81caa905fd108717019226;hpb=5325734bc2e4927ed7ec146e35a6f0f2b49f50c1 diff --git a/helm/gtkmathview-bonobo/src/handlers.c b/helm/gtkmathview-bonobo/src/handlers.c deleted file mode 100644 index 4861b2f0b..000000000 --- a/helm/gtkmathview-bonobo/src/handlers.c +++ /dev/null @@ -1,245 +0,0 @@ -/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView. - * Copyright (C) 2003 Luca Padovani - * Pouria Masoudi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * For more information, please visit the project's home page - * http://helm.cs.unibo.it/gtkmathview-bonobo - * or send an email to - */ - -#include - -#include "aux.h" -#include "handlers.h" - -static void -set_clipboard(GdomeDOMString* data) -{ - GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); - gtk_clipboard_set_text(clipboard, data->str, gdome_str_length(data)); -} - -void -set_frame(BonoboControl *control, gpointer data) -{ -} - -static void -notify_browser(GtkMathViewControlData* control_data, const char* url) -{ - BonoboObject* evs = bonobo_object_query_local_interface(BONOBO_OBJECT(control_data->control), - "IDL:Bonobo/EventSource:1.0"); - if (evs != NULL) - { - BonoboArg* arg = bonobo_arg_new(BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING(arg, url); - bonobo_event_source_notify_listeners (evs, "URL", arg, NULL); - /* bonobo_arg_release(arg); */ - bonobo_object_unref(BONOBO_OBJECT(evs)); - } -} - -void -click_cb(GtkMathView* math_view, GdomeElement* elem, gint state, - GtkMathViewControlData* control_data) -{ - GdomeException exc = 0; - - g_return_if_fail(math_view != NULL); - g_return_if_fail(control_data != NULL); - - if (elem != NULL) - { - GdomeElement* action; - GdomeDOMString* href = find_hyperlink(elem); - - if (href != NULL) - { - /*gtk_math_view_load_uri(math_view,href->str);*/ - - notify_browser(control_data, href->str); - - //set_clipboard(href); - gdome_str_unref(href); - return; - } - - action = find_self_or_ancestor(elem, MATHML_NS_URI, "maction"); - if (action != NULL) - { - gtk_math_view_freeze(math_view); - action_toggle(action); - gtk_math_view_thaw(math_view); - gdome_el_unref(action, &exc); - g_assert(exc == 0); - return; - } - } - - if (control_data->root_selected != NULL) - { - gtk_math_view_freeze(math_view); - gtk_math_view_unselect(math_view, control_data->root_selected); - gtk_math_view_thaw(math_view); - gdome_el_unref(control_data->root_selected, &exc); - g_assert(exc == 0); - control_data->root_selected = NULL; - } -} - -void -select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state, - GtkMathViewControlData* control_data) -{ - g_return_if_fail(math_view != NULL); - g_return_if_fail(control_data != NULL); - - if (elem != NULL) - { - GdomeException exc = 0; - gtk_math_view_freeze(math_view); - if (control_data->root_selected != NULL) - { - gtk_math_view_unselect(math_view, control_data->root_selected); - gdome_el_unref(control_data->root_selected, &exc); - g_assert(exc == 0); - control_data->root_selected = NULL; - } - - if (control_data->semantic_selection) - { - GdomeElement* new_elem = find_element_with_id(elem, control_data->id_ns_uri, control_data->id_name); - if (new_elem != NULL) - { - gdome_el_ref(new_elem, &exc); - g_assert(exc == 0); - } - control_data->first_selected = control_data->root_selected = new_elem; - } - else - { - gdome_el_ref(elem, &exc); - g_assert(exc == 0); - gdome_el_ref(elem, &exc); - g_assert(exc == 0); - control_data->first_selected = control_data->root_selected = elem; - } - - if (control_data->root_selected != NULL) - gtk_math_view_select(math_view, control_data->root_selected); - - gtk_math_view_thaw(math_view); - } -} - -void -select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state, - GtkMathViewControlData* control_data) -{ - g_return_if_fail(math_view != NULL); - g_return_if_fail(control_data != NULL); - - if (control_data->first_selected != NULL && elem != NULL) - { - GdomeException exc = 0; - - gtk_math_view_freeze(math_view); - - if (control_data->root_selected != NULL) - { - gtk_math_view_unselect(math_view, control_data->root_selected); - gdome_el_unref(control_data->root_selected, &exc); - g_assert(exc == 0); - control_data->root_selected = NULL; - } - - if (control_data->semantic_selection) - { - GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem); - if (new_root != NULL) - { - control_data->root_selected = find_element_with_id(new_root, control_data->id_ns_uri, control_data->id_name); - gdome_el_unref(new_root, &exc); - g_assert(exc == 0); - } - else - control_data->root_selected = NULL; - } - else - control_data->root_selected = find_common_ancestor(control_data->first_selected, elem); - - if (control_data->root_selected != NULL) - gtk_math_view_select(math_view, control_data->root_selected); - - gtk_math_view_thaw(math_view); - } -} - -void -select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state, - GtkMathViewControlData* control_data) -{ - g_return_if_fail(math_view != NULL); - g_return_if_fail(control_data != NULL); - - if (control_data->first_selected != NULL) - { - GdomeException exc = 0; - gdome_el_unref(control_data->first_selected, &exc); - g_assert(exc == 0); - control_data->first_selected = NULL; - - if (control_data->root_selected != NULL && control_data->semantic_selection) - { - GdomeException exc = 0; - GdomeDOMString* id = gdome_el_getAttributeNS(control_data->root_selected, - control_data->id_ns_uri, - control_data->id_name, &exc); - g_assert(exc == 0); - g_assert(id != NULL); - set_clipboard(id); - gdome_str_unref(id); - } - } -} - -void -select_abort_cb(GtkMathView* math_view, GtkMathViewControlData* control_data) -{ - GdomeException exc = 0; - - g_return_if_fail(math_view != NULL); - g_return_if_fail(control_data != NULL); - - if (control_data->first_selected != NULL) - { - gdome_el_unref(control_data->first_selected, &exc); - g_assert(exc == 0); - control_data->first_selected = NULL; - } - - if (control_data->root_selected != NULL) - { - gtk_math_view_freeze(math_view); - gtk_math_view_unselect(math_view, control_data->root_selected); - gtk_math_view_thaw(math_view); - gdome_el_unref(control_data->root_selected, &exc); - g_assert(exc == 0); - control_data->root_selected = NULL; - } -} -