]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/gtkmathview-bonobo/src/handlers.c
ocaml 3.09 transition
[helm.git] / helm / gtkmathview-bonobo / src / handlers.c
index e7e100aa22125e2d6a59ddb6183ba5b851360164..4861b2f0b0ec6f7205d3be03e5a2c79ae80fc396 100644 (file)
@@ -1,4 +1,29 @@
+/* This file is part of GtkMathView-Bonobo, a Bonobo wrapper for GtkMathView.
+ * Copyright (C) 2003 Luca Padovani <lpadovan@cs.unibo.it>
+ *                    Pouria Masoudi <pmasoudi@cs.unibo.it>
+ * 
+ * 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 <lpadovan@cs.unibo.it>
+ */
 
+#include <config.h>
+
+#include "aux.h"
 #include "handlers.h"
 
 static void
@@ -13,6 +38,21 @@ 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)
@@ -21,7 +61,7 @@ click_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
   
   g_return_if_fail(math_view != NULL);
   g_return_if_fail(control_data != NULL);
-  
+
   if (elem != NULL)
     {
       GdomeElement* action;
@@ -30,7 +70,10 @@ click_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
       if (href != NULL)
        {
           /*gtk_math_view_load_uri(math_view,href->str);*/
-         set_clipboard(href);
+
+         notify_browser(control_data, href->str);
+
+         //set_clipboard(href);
           gdome_str_unref(href);
          return;
        }
@@ -77,7 +120,7 @@ select_begin_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
          control_data->root_selected = NULL;
        }
       
-      if (control_data->id_ns_uri != NULL || control_data->id_name != 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)
@@ -124,7 +167,7 @@ select_over_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
           control_data->root_selected = NULL;
        }
       
-      if (control_data->id_ns_uri != NULL || control_data->id_name != NULL)
+      if (control_data->semantic_selection)
        {
          GdomeElement* new_root = find_common_ancestor(control_data->first_selected, elem);
          if (new_root != NULL)
@@ -160,8 +203,7 @@ select_end_cb(GtkMathView* math_view, GdomeElement* elem, gint state,
       g_assert(exc == 0);
       control_data->first_selected = NULL;
 
-      if (control_data->root_selected != NULL &&
-         (control_data->id_ns_uri != NULL || control_data->id_name != NULL))
+      if (control_data->root_selected != NULL && control_data->semantic_selection)
        {
          GdomeException exc = 0;
          GdomeDOMString* id = gdome_el_getAttributeNS(control_data->root_selected,