diff options
author | Mikael Hallendal <micke@codefactory.se> | 2002-03-23 16:52:56 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-03-23 16:52:56 +0000 |
commit | 6461cfcfa7d09b34c1aac45b61d0ed7b2784957d (patch) | |
tree | a6b6bbe3dff0b7154a8b2d6d5e282bce62d4e87e | |
parent | a8f075024ea48e0903e4d793aeb54e43c5e10e7c (diff) | |
download | yelp-6461cfcfa7d09b34c1aac45b61d0ed7b2784957d.tar.gz |
reverted this to it's initial behaviour. (yelp_util_split_uri): added this
22002-03-23 Mikael Hallendal <micke@codefactory.se>
* src/yelp-util.c:
(yelp_util_extract_docpath_from_uri): reverted this to it's
initial behaviour.
(yelp_util_split_uri): added this instead which supports
ghelp/man/info uri's. It also always have the type of uri
prepended in the return uri.
* src/yelp-html.c (yelp_html_open_uri): this function is getting
ugly, have to clean it up.
(yelp_html_open_uri): use yelp_util_split_uri intead to get the
docpath and the anchor (it supports man and info too, not just
ghelp:-uri's. Fixes #72637).
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | src/yelp-html.c | 30 | ||||
-rw-r--r-- | src/yelp-util.c | 43 | ||||
-rw-r--r-- | src/yelp-util.h | 6 | ||||
-rw-r--r-- | src/yelp-view-content.c | 2 |
5 files changed, 72 insertions, 22 deletions
@@ -1,5 +1,18 @@ 2002-03-23 Mikael Hallendal <micke@codefactory.se> + * src/yelp-util.c: + (yelp_util_extract_docpath_from_uri): reverted this to it's + initial behaviour. + (yelp_util_split_uri): added this instead which supports + ghelp/man/info uri's. It also always have the type of uri + prepended in the return uri. + + * src/yelp-html.c (yelp_html_open_uri): this function is getting + ugly, have to clean it up. + (yelp_html_open_uri): use yelp_util_split_uri intead to get the + docpath and the anchor (it supports man and info too, not just + ghelp:-uri's. Fixes #72637). + * src/yelp-window.c: commented out the Quit-option, we might not want to have it around because you often use Yelp in another way (ie. klicking Help in an application). Fixes #75081 diff --git a/src/yelp-html.c b/src/yelp-html.c index c582c18b..a395dbf9 100644 --- a/src/yelp-html.c +++ b/src/yelp-html.c @@ -327,6 +327,9 @@ yh_link_clicked_cb (HtmlDocument *doc, const gchar *url, YelpHtml *html) handled = TRUE; } + d(g_print ("link clicked: URL=%s baseUri=%s\n", url, + html->priv->base_uri)); + g_signal_emit (html, signals[URL_SELECTED], 0, url, html->priv->base_uri, handled); } @@ -365,6 +368,7 @@ yelp_html_open_uri (YelpHtml *view, StreamData *sdata; GnomeVFSURI *uri; gchar *docpath; + gchar *anchor; d(puts(G_GNUC_FUNCTION)); @@ -373,22 +377,30 @@ yelp_html_open_uri (YelpHtml *view, priv = view->priv; - docpath = yelp_util_extract_docpath_from_uri (str_uri, TRUE); - - if (!reference) { - reference = yelp_util_find_anchor_in_uri (str_uri); + docpath = yelp_util_split_uri (str_uri, &anchor); + + if (reference && !anchor) { + anchor = g_strdup (reference); } if (!strcmp (priv->base_uri, docpath)) { /* Same document that are already shown in this view */ /* Just jump if we have an anchor */ - if (reference) { + if (anchor) { + d(g_print ("Jumping to [%s]\n", anchor)); + html_view_jump_to_anchor (HTML_VIEW (view), - reference); + anchor); + } else { + d(g_print ("Going to the beginning of the page")); + + gtk_adjustment_set_value ( + gtk_layout_get_vadjustment (GTK_LAYOUT (view)), + 0); } return; - } + } /* New document needs to be read. */ g_free (priv->base_uri); @@ -409,8 +421,8 @@ yelp_html_open_uri (YelpHtml *view, uri = gnome_vfs_uri_new (docpath); - if (reference) { - sdata->anchor = g_strdup (reference); + if (anchor) { + sdata->anchor = anchor; } d(g_print ("Trying to open: %s[%s]\n", docpath, reference)); diff --git a/src/yelp-util.c b/src/yelp-util.c index 6ca106a3..b1120057 100644 --- a/src/yelp-util.c +++ b/src/yelp-util.c @@ -472,18 +472,17 @@ yelp_util_find_node_from_uri (GNode *doc_tree, const gchar *uri) } gchar * -yelp_util_extract_docpath_from_uri (const gchar *str_uri, gboolean add_ghelp) +yelp_util_extract_docpath_from_uri (const gchar *str_uri) { GnomeVFSURI *uri; gchar *transformed_uri; gchar *docpath = NULL; gchar *extension; - gchar *ret; if (strncmp (str_uri, "ghelp:", 6)) { /* This function is only valid for ghelp-uri's */ /* g_warning ("URI not of ghelp: form"); */ - return str_uri; + return g_strdup (str_uri); } if ((extension = strstr (str_uri, ".xml"))) { @@ -527,13 +526,37 @@ yelp_util_extract_docpath_from_uri (const gchar *str_uri, gboolean add_ghelp) } } - if (add_ghelp) { - ret = g_strconcat ("ghelp:", docpath, NULL); - } else { - ret = g_strdup (docpath); + return docpath; +} + +gchar * +yelp_util_split_uri (const gchar *uri, gchar **anchor) +{ + gchar *str; + gchar *ret = NULL; + gchar *anchor_ptr; + gint len; + + anchor_ptr = yelp_util_find_anchor_in_uri (uri); + + if (!strncmp (uri, "ghelp:", 6)) { + str = yelp_util_extract_docpath_from_uri (uri); + ret = g_strconcat ("ghelp:", str, NULL); + g_free (str); } + else if (!strncmp (uri, "man:", 4) || !strncmp (uri, "info:", 5)) { + if (!anchor_ptr) { + len = strlen (uri); + } else { + len = anchor_ptr - 1 - uri; + } - g_free (docpath); + ret = g_strndup (uri, len); + } + + if (anchor) { + *anchor = g_strdup (anchor_ptr); + } return ret; } @@ -544,10 +567,10 @@ yelp_util_find_anchor_in_uri (const gchar *str_uri) gchar *anchor; if ((anchor = strstr (str_uri, "?"))) { - return g_strdup (anchor + 1); + return anchor + 1; } else if ((anchor = strstr (str_uri, "#"))) { - return g_strdup (anchor + 1); + return anchor + 1; } return NULL; diff --git a/src/yelp-util.h b/src/yelp-util.h index 11f2ac2d..dbce0b91 100644 --- a/src/yelp-util.h +++ b/src/yelp-util.h @@ -44,8 +44,10 @@ GNode * yelp_util_find_toplevel (GNode *doc_tree, GNode * yelp_util_find_node_from_uri (GNode *doc_tree, const gchar *uri); -gchar * yelp_util_extract_docpath_from_uri (const gchar *uri, - gboolean add_ghelp); +gchar * yelp_util_extract_docpath_from_uri (const gchar *uri); +gchar * yelp_util_split_uri (const gchar *uri, + gchar **anchor); + const gchar * yelp_util_find_anchor_in_uri (const gchar *str_uri); #endif /* __YELP_UTIL_H__ */ diff --git a/src/yelp-view-content.c b/src/yelp-view-content.c index bc19bc3a..2a32deb1 100644 --- a/src/yelp-view-content.c +++ b/src/yelp-view-content.c @@ -304,7 +304,7 @@ yelp_view_content_show_uri (YelpViewContent *content, /* ghelp uri-scheme /usr/share/gnome/help... */ gchar *docpath; - docpath = yelp_util_extract_docpath_from_uri (url, FALSE); + docpath = yelp_util_extract_docpath_from_uri (url); if (docpath && strcmp (docpath, priv->current_docpath)) { /* Try to find it in the scrollkeeper database, |