]> matita.cs.unibo.it Git - helm.git/commitdiff
* implemented click so that the browser is notified with the new URL
authorLuca Padovani <luca.padovani@unito.it>
Tue, 23 Mar 2004 14:49:46 +0000 (14:49 +0000)
committerLuca Padovani <luca.padovani@unito.it>
Tue, 23 Mar 2004 14:49:46 +0000 (14:49 +0000)
  and loads it

helm/gtkmathview-bonobo/configure.ac
helm/gtkmathview-bonobo/src/control-data.c
helm/gtkmathview-bonobo/src/control-data.h
helm/gtkmathview-bonobo/src/control-factory.c
helm/gtkmathview-bonobo/src/handlers.c
helm/gtkmathview-bonobo/test/testembedding.html

index 95f12c5380563431ffec2e94d2f84174fe18640d..e30b55212778810961d20b63e721a4a7c74e2e35 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(gtkmathview-bonobo, [0.0.1])
+AC_INIT(gtkmathview-bonobo, [0.0.3])
 AC_CONFIG_SRCDIR(src/GNOME_GtkMathView.server.in.in)
 AM_INIT_AUTOMAKE($AC_PACKAGE_NAME, $AC_PACKAGE_VERSION)
 
index b4885bf2afdb68343415bfbd3cea3755603f6f55..d97d0fd2f77700338a039c1f33b8e4b2f12b2952 100644 (file)
 #include "control-data.h"
 
 GtkMathViewControlData*
-gtk_math_view_control_data_new(GtkMathView *math_view)
+gtk_math_view_control_data_new(BonoboControl* control, GtkMathView *math_view)
 {
   GtkMathViewControlData *cd = g_new(GtkMathViewControlData,1);
+  cd->control = control; /* we don't ref the control this is a weak pointer */
   cd->math_view = math_view;
   gtk_widget_ref(GTK_WIDGET(math_view));
   cd->item_factory = NULL;
@@ -47,6 +48,7 @@ void
 gtk_math_view_control_data_destroy(GtkMathViewControlData* cd)
 {
   GdomeException exc = 0;
+  cd->control = NULL; /* don't unref the control, see above */
   gtk_widget_unref(GTK_WIDGET(cd->math_view));
   cd->math_view = NULL;
   if (cd->item_factory != NULL)
index ecbaa1a7eca75690aeba77e207920d2c84838b6e..46bc6cef77487f61ed5b7b525099ca49c23f9950 100644 (file)
 #ifndef __control_data_h__
 #define __control_data_h__
 
+#include <bonobo.h>
 #include <gtkmathview.h>
 #include <gdome.h>
 
 typedef struct _GtkMathViewControlData
 {
+  BonoboControl* control; /* the control this data belongs to */
   GtkMathView* math_view;
   GtkWidget* item_factory;
   gboolean semantic_selection;
@@ -40,7 +42,7 @@ typedef struct _GtkMathViewControlData
   gint y;
 } GtkMathViewControlData;
 
-GtkMathViewControlData* gtk_math_view_control_data_new(GtkMathView*);
+GtkMathViewControlData* gtk_math_view_control_data_new(BonoboControl*, GtkMathView*);
 void gtk_math_view_control_data_destroy(GtkMathViewControlData*);
 gchar* gtk_math_view_control_data_get_id_ns_uri(GtkMathViewControlData*);
 void gtk_math_view_control_data_set_id_ns_uri(GtkMathViewControlData*, const gchar*);
index 9f3edf1a8cdee29407cf0c731736c9e7f9888ac8..59611ab755586a488f7376740ffcc138a754e283 100644 (file)
@@ -317,12 +317,13 @@ gtk_math_view_control_init(BonoboControl *control, GtkWidget *scrolled_window)
   BonoboPropertyBag *prop_bag;
   BonoboObject *persist_file;
   BonoboObject *persist_stream;
+  BonoboEventSource *evs;
   View* view;
 
   math_view = gtk_math_view_new(NULL,NULL);
   gtk_widget_show(math_view);
 
-  control_data = gtk_math_view_control_data_new((GtkMathView*)math_view);
+  control_data = gtk_math_view_control_data_new(control, (GtkMathView*)math_view);
   
   g_signal_connect (control, "destroy", G_CALLBACK (control_destroy), control_data);
   
@@ -331,6 +332,9 @@ gtk_math_view_control_init(BonoboControl *control, GtkWidget *scrolled_window)
   gtk_item_factory_create_items (control_data->item_factory, nmenu_items, menu_items, control_data);
   /* control_data->popup_menu = gtk_item_factory_get_widget (control_data->item_factory, "<main>"); */
   /* gtk_widget_ref(control_data->popup_menu); */
+  
+  evs = bonobo_event_source_new();
+  bonobo_object_add_interface(BONOBO_OBJECT(control), BONOBO_OBJECT(evs));
 
   gtk_container_add(GTK_CONTAINER (scrolled_window), GTK_WIDGET (control_data->math_view));
 
index 78dc7ee66a4d51a47ba0212bc90db2c40b27c4bc..4861b2f0b0ec6f7205d3be03e5a2c79ae80fc396 100644 (file)
@@ -38,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)
@@ -46,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;
@@ -55,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;
        }
index 529360057a4af423f11db371abe414314a8b8db2..251c4cfc2bc1af0764b58649501c8cb9d872a1bb 100644 (file)
@@ -9,7 +9,7 @@
 The embedded object should display a mathematical formula.
 <br />
 <br />
-<object data="test.mml" width="400" height="100" type="application/mathml+xml">
+<object data="test2.mml" width="400" height="100" type="application/mathml+xml">
 No viewer capable of displaying the test document installed.
 </object>