[gnumeric] Function selector: fix criticals on function switch.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Function selector: fix criticals on function switch.
- Date: Wed, 17 Jun 2009 08:39:52 -0400 (EDT)
commit 54aaa8af9a0657769e5a17e635f35a9a22767772
Author: Morten Welinder <terra gnome org>
Date: Wed Jun 17 08:39:11 2009 -0400
Function selector: fix criticals on function switch.
configure.in | 2 +-
src/dialogs/dialog-function-select.c | 54 ++++++++++++++++++++-------------
2 files changed, 34 insertions(+), 22 deletions(-)
---
diff --git a/configure.in b/configure.in
index d42307a..85240a7 100644
--- a/configure.in
+++ b/configure.in
@@ -668,7 +668,7 @@ LIBS="$GNUMERIC_LIBS $LIBS"
AC_CHECK_FUNCS(g_date_set_time_t g_slice_alloc g_option_context_set_delocalize)
AC_CHECK_FUNCS(pango_font_map_create_context)
-AC_CHECK_FUNCS(gtk_recent_manager_get_default gtk_orientable_set_orientation gtk_adjustment_configure gsf_open_pkg_foreach_rel)
+AC_CHECK_FUNCS(gtk_recent_manager_get_default gtk_orientable_set_orientation gtk_adjustment_configure gsf_open_pkg_foreach_rel gtk_show_uri)
AC_CHECK_FUNCS(gsf_infile_msvba_steal_modules)
AC_MSG_CHECKING([for PANGO_WEIGHT_THIN etc.])
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index adda129..54aded2 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -338,14 +338,19 @@ make_link (GtkTextBuffer *description, const char *name,
GCallback cb, gpointer user)
{
GtkTextTag *link =
- gtk_text_buffer_create_tag
- (description, name,
- "underline", PANGO_UNDERLINE_SINGLE,
- "foreground", "#0000ff",
- NULL);
-
- if (cb)
- g_signal_connect (link, "event", cb, user);
+ gtk_text_tag_table_lookup
+ (gtk_text_buffer_get_tag_table (description), name);
+
+ if (!link) {
+ link = gtk_text_buffer_create_tag
+ (description, name,
+ "underline", PANGO_UNDERLINE_SINGLE,
+ "foreground", "#0000ff",
+ NULL);
+
+ if (cb)
+ g_signal_connect (link, "event", cb, user);
+ }
return link;
}
@@ -353,22 +358,33 @@ make_link (GtkTextBuffer *description, const char *name,
static gboolean
cb_link_event (GtkTextTag *link, GObject *trigger,
GdkEvent *event, GtkTextIter *iter,
- const char *uri)
+ gpointer user)
{
switch (event->type) {
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS: {
GdkEventButton *eb = (GdkEventButton *)event;
- GdkScreen *screen;
+ const char *uri = g_object_get_data (G_OBJECT (link), "uri");
+ GError *error = NULL;
if (eb->button != 1)
break;
if (event->type != GDK_BUTTON_PRESS)
return TRUE;
- screen = gdk_event_get_screen (event);
- gtk_show_uri (screen, uri, GDK_CURRENT_TIME, NULL);
+#ifdef HAVE_GTK_SHOW_URI
+ gtk_show_uri (gdk_event_get_screen (event), uri,
+ GDK_CURRENT_TIME, &error);
+#else
+ error = go_url_show (uri);
+#endif
+ if (error) {
+ g_printerr ("Failed to show %s\n(%s)\n",
+ uri,
+ error->message);
+ g_error_free (error);
+ }
return TRUE;
}
@@ -474,12 +490,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
const char *text = help->text; /* Not translated */
const char *pre = _("See also: ");
GtkTextTag *link =
- gtk_text_tag_table_lookup
- (gtk_text_buffer_get_tag_table (description), "LINK");
-
- if (link == NULL)
- link = make_link (description, "LINK",
- NULL, NULL);
+ make_link (description, "LINK", NULL, NULL);
ADD_TEXT ("\n");
@@ -501,7 +512,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
return;
case GNM_FUNC_HELP_EXTREF: {
GtkTextTag *link;
- char *uri;
+ char *uri, *tagname;
const char *text;
/*
@@ -514,10 +525,11 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
uri = g_strdup_printf ("http://projects.gnome.org/gnumeric/func-doc.shtml?%s", func->name);
+ tagname = g_strdup_printf ("EXTLINK-%s", func->name);
link = make_link
- (description, "EXTLINK",
+ (description, tagname,
G_CALLBACK (cb_link_event),
- uri);
+ NULL);
g_object_set_data_full (G_OBJECT (link),
"uri", uri,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]