[gnumeric] Function selector: handle external references.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Function selector: handle external references.
- Date: Tue, 16 Jun 2009 22:16:11 -0400 (EDT)
commit cdc911dbf510c4d226c6464fec0ae871db5e9ca0
Author: Morten Welinder <terra gnome org>
Date: Tue Jun 16 22:15:41 2009 -0400
Function selector: handle external references.
src/dialogs/ChangeLog | 4 +
src/dialogs/dialog-function-select.c | 102 ++++++++++++++++++++++++++++++---
src/func.c | 12 +++-
3 files changed, 104 insertions(+), 14 deletions(-)
---
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 76acfbc..2c64b10 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-16 Morten Welinder <terra gnome org>
+
+ * dialog-function-select.c: Handle external references.
+
2009-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-cell-sort.c (dialog_load_selection): return info about
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index 35ccd58..adda129 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -333,6 +333,59 @@ describe_old_style (GtkTextBuffer *description, GnmFunc const *func)
tokenized_help_destroy (help);
}
+static GtkTextTag *
+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);
+
+ return link;
+}
+
+static gboolean
+cb_link_event (GtkTextTag *link, GObject *trigger,
+ GdkEvent *event, GtkTextIter *iter,
+ const char *uri)
+{
+ switch (event->type) {
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS: {
+ GdkEventButton *eb = (GdkEventButton *)event;
+ GdkScreen *screen;
+
+ 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);
+
+ return TRUE;
+ }
+
+#if 0
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ /* We aren't getting these. */
+#endif
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+
#define ADD_LTEXT(text,len) gtk_text_buffer_insert (description, &ti, (text), (len))
#define ADD_TEXT(text) ADD_LTEXT((text),-1)
#define ADD_BOLD_TEXT(text,len) gtk_text_buffer_insert_with_tags (description, &ti, (text), (len), bold, NULL)
@@ -353,6 +406,7 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
NULL);
gboolean seen_args = FALSE;
gboolean seen_examples = FALSE;
+ gboolean seen_extref = FALSE;
gtk_text_buffer_get_end_iter (description, &ti);
@@ -419,17 +473,13 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
case GNM_FUNC_HELP_SEEALSO: {
const char *text = help->text; /* Not translated */
const char *pre = _("See also: ");
- GtkTextTag *link = NULL;
-
- link = gtk_text_tag_table_lookup
+ GtkTextTag *link =
+ gtk_text_tag_table_lookup
(gtk_text_buffer_get_tag_table (description), "LINK");
if (link == NULL)
- link =gtk_text_buffer_create_tag
- (description, "LINK",
- "underline", PANGO_UNDERLINE_SINGLE,
- "foreground", "#0000ff",
- NULL);
+ link = make_link (description, "LINK",
+ NULL, NULL);
ADD_TEXT ("\n");
@@ -449,8 +499,40 @@ describe_new_style (GtkTextBuffer *description, GnmFunc const *func)
}
case GNM_FUNC_HELP_END:
return;
- case GNM_FUNC_HELP_EXTREF:
- /* FIXME! */
+ case GNM_FUNC_HELP_EXTREF: {
+ GtkTextTag *link;
+ char *uri;
+ const char *text;
+
+ /*
+ * We put in just one link and let the web page handle
+ * the rest. In particular, we do not even look at
+ * what the help->text is here.
+ */
+ if (seen_extref)
+ break;
+
+ uri = g_strdup_printf ("http://projects.gnome.org/gnumeric/func-doc.shtml?%s", func->name);
+
+ link = make_link
+ (description, "EXTLINK",
+ G_CALLBACK (cb_link_event),
+ uri);
+
+ g_object_set_data_full (G_OBJECT (link),
+ "uri", uri,
+ g_free);
+
+ ADD_TEXT (_("Further information: "));
+
+ text = _("online descriptions");
+ ADD_LINK_TEXT (text, strlen (text));
+
+ ADD_TEXT (".\n");
+
+ seen_extref = TRUE;
+ break;
+ }
default:
break;
}
diff --git a/src/func.c b/src/func.c
index 35c46a9..e4a1018 100644
--- a/src/func.c
+++ b/src/func.c
@@ -226,7 +226,7 @@ dump_externals (GPtrArray *defs, FILE *out)
case GNM_FUNC_HELP_EXTREF:
if (!any) {
any = TRUE;
- fprintf (out, "<!--#if expr=\"${QUERY_STRING_UNESCAPED} = %s\" -->", fd->name);
+ fprintf (out, "<!--#if expr=\"${QUERY_STRING} = %s\" -->", fd->name);
}
if (strncmp (s, "wolfram:", 8) == 0) {
@@ -251,11 +251,15 @@ dump_externals (GPtrArray *defs, FILE *out)
fprintf (out, "<div class=\"floatflush\">\n");
fprintf (out, "<h1>Online Documentation for \"<!--#echo var=\"QUERY_STRING\" -->\"</h1>\n");
+ fprintf (out, "<p>When last checked, these sources provided useful information about\n");
+ fprintf (out, "this function. However, since the links are not controlled by the\n");
+ fprintf (out, "Gnumeric Team, we cannot guarantee that the links still work. If\n");
+ fprintf (out, "you find that they do not work, please drop us a line.</p>\n");
fprintf (out, "<ul>");
fprintf (out, "<!--#if expr=\"${wolfram} != none\"-->");
- fprintf (out, "<li><a href=\"http://mathworld.wolfram.com/<!--#echo var=\"wolfram\" -->\">Wolfram Mathworld entry</a>.</li><!--#endif-->");
- fprintf (out, "<!--#if expr=\"${wiki} != none\"--><li><a href=\"http://<!--#echo var=\"wiki_lang\" -->.wikipedia.org/wiki/<!--#echo var=\"wiki\" -->\">Wikipedia entry</a>.</li><!--#endif-->");
- fprintf (out, "<li><a href=\"http://www.google.com/#q=<!--#echo var=\"QUERY_STRING_UNESCAPED\" -->\">Google Search</a>.</li>");
+ fprintf (out, "<li><a href=\"http://mathworld.wolfram.com/<!--#echo var=\"wolfram\" -->\">Wolfram Mathworld\nentry</a>.</li><!--#endif-->");
+ fprintf (out, "<!--#if expr=\"${wiki} != none\"--><li><a href=\"http://<!--#echo var=\"wiki_lang\" -->.wikipedia.org/wiki/<!--#echo var=\"wiki\" -->\">Wikipedia\nentry</a>.</li><!--#endif-->");
+ fprintf (out, "<li><a href=\"http://www.google.com/#q=<!--#echo var=\"QUERY_STRING\" -->\">Google Search</a>.</li>");
fprintf (out, "</ul>");
fprintf (out, "</div>\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]