From: Luca Padovani Date: Tue, 23 Mar 2004 14:49:46 +0000 (+0000) Subject: * implemented click so that the browser is notified with the new URL X-Git-Tag: v0_0_4~4 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=21ebe02ef74cd92e64fa09d2f5cefa12ad3babb5;p=helm.git * implemented click so that the browser is notified with the new URL and loads it --- diff --git a/helm/gtkmathview-bonobo/configure.ac b/helm/gtkmathview-bonobo/configure.ac index 95f12c538..e30b55212 100644 --- a/helm/gtkmathview-bonobo/configure.ac +++ b/helm/gtkmathview-bonobo/configure.ac @@ -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) diff --git a/helm/gtkmathview-bonobo/src/control-data.c b/helm/gtkmathview-bonobo/src/control-data.c index b4885bf2a..d97d0fd2f 100644 --- a/helm/gtkmathview-bonobo/src/control-data.c +++ b/helm/gtkmathview-bonobo/src/control-data.c @@ -28,9 +28,10 @@ #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) diff --git a/helm/gtkmathview-bonobo/src/control-data.h b/helm/gtkmathview-bonobo/src/control-data.h index ecbaa1a7e..46bc6cef7 100644 --- a/helm/gtkmathview-bonobo/src/control-data.h +++ b/helm/gtkmathview-bonobo/src/control-data.h @@ -24,11 +24,13 @@ #ifndef __control_data_h__ #define __control_data_h__ +#include #include #include 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*); diff --git a/helm/gtkmathview-bonobo/src/control-factory.c b/helm/gtkmathview-bonobo/src/control-factory.c index 9f3edf1a8..59611ab75 100644 --- a/helm/gtkmathview-bonobo/src/control-factory.c +++ b/helm/gtkmathview-bonobo/src/control-factory.c @@ -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, "
"); */ /* 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)); diff --git a/helm/gtkmathview-bonobo/src/handlers.c b/helm/gtkmathview-bonobo/src/handlers.c index 78dc7ee66..4861b2f0b 100644 --- a/helm/gtkmathview-bonobo/src/handlers.c +++ b/helm/gtkmathview-bonobo/src/handlers.c @@ -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; } diff --git a/helm/gtkmathview-bonobo/test/testembedding.html b/helm/gtkmathview-bonobo/test/testembedding.html index 529360057..251c4cfc2 100644 --- a/helm/gtkmathview-bonobo/test/testembedding.html +++ b/helm/gtkmathview-bonobo/test/testembedding.html @@ -9,7 +9,7 @@ The embedded object should display a mathematical formula.

- + No viewer capable of displaying the test document installed.