diff options
author | Alex Larsson <alexl@redhat.com> | 2002-01-11 16:51:56 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2002-01-11 16:51:56 +0000 |
commit | 5b4acca3376c5cafcc200f316cf7c009573de9a7 (patch) | |
tree | d9a2f68fc840e48c6c18b83fe42390b4a6458433 | |
parent | 394715cb9822a0ff667805125b63a8bad717da1c (diff) | |
download | yelp-5b4acca3376c5cafcc200f316cf7c009573de9a7.tar.gz |
Shortcut pure relative links. (yelp_html_open_section): If there is a
2002-01-11 Alex Larsson <alexl@redhat.com>
* src/yelp-html.c (yh_link_clicked_cb):
Shortcut pure relative links.
(yelp_html_open_section): If there is a fragment
in the uri, put that in sdata->anchor so that we
jump to the anchor on load.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/yelp-html.c | 28 |
2 files changed, 30 insertions, 6 deletions
@@ -1,5 +1,13 @@ 2002-01-11 Alex Larsson <alexl@redhat.com> + * src/yelp-html.c (yh_link_clicked_cb): + Shortcut pure relative links. + (yelp_html_open_section): If there is a fragment + in the uri, put that in sdata->anchor so that we + jump to the anchor on load. + +2002-01-11 Alex Larsson <alexl@redhat.com> + * src/yelp-util.[ch]: Add yelp_util_resolve_relative_uri() that resolves relative text uris. Taken from Gnome VFS. We can't use diff --git a/src/yelp-html.c b/src/yelp-html.c index 1ce2ad88..5c972531 100644 --- a/src/yelp-html.c +++ b/src/yelp-html.c @@ -24,6 +24,10 @@ #include <config.h> #endif +#include "yelp-util.h" + +#include <string.h> + #include <libgnomevfs/gnome-vfs.h> #include <libgnome/gnome-i18n.h> #include <stdio.h> @@ -158,7 +162,7 @@ yh_async_close_cb (GnomeVFSAsyncHandle *handle, d(puts(__FUNCTION__)); sdata = (StreamData *) callback_data; - + if (sdata->anchor) { html_view_jump_to_anchor (HTML_VIEW (sdata->view), sdata->anchor); @@ -338,6 +342,13 @@ yh_link_clicked_cb (HtmlDocument *doc, const gchar *url, YelpHtml *html) priv = html->priv; + /* If this is a relative reference. Shortcut reload. */ + if (url && url[0] == '#') { + html_view_jump_to_anchor (HTML_VIEW (html), + &url[1]); + return; + } + if (priv->base_uri) { abs_uri = yelp_util_resolve_relative_uri (priv->base_uri, url); g_print ("Link '%s' pressed relative to: %s -> %s\n", @@ -384,6 +395,7 @@ yelp_html_open_section (YelpHtml *view, const YelpSection *section) YelpHtmlPriv *priv; StreamData *sdata; GnomeVFSURI *uri; + const char *fragment; d(puts(__FUNCTION__)); @@ -409,10 +421,6 @@ yelp_html_open_section (YelpHtml *view, const YelpSection *section) sdata->stream = priv->doc->current_stream; sdata->anchor = NULL; - if (section->reference) { - sdata->anchor = g_strdup (section->reference); - } - priv->connections = g_slist_prepend (priv->connections, sdata); if (section->reference) { @@ -424,7 +432,15 @@ yelp_html_open_section (YelpHtml *view, const YelpSection *section) uri = gnome_vfs_uri_new (section->uri); } - + if (section->reference) { + sdata->anchor = g_strdup (section->reference); + } else if (uri) { + fragment = gnome_vfs_uri_get_fragment_identifier (uri); + if (fragment) { + sdata->anchor = g_strdup (fragment); + } + } + gnome_vfs_async_open_uri (&sdata->handle, uri, GNOME_VFS_OPEN_READ, |