summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libyelp/yelp-document.c19
-rw-r--r--libyelp/yelp-uri.c33
-rw-r--r--libyelp/yelp-view.c24
3 files changed, 67 insertions, 9 deletions
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c
index 1ead2fa4..45017775 100644
--- a/libyelp/yelp-document.c
+++ b/libyelp/yelp-document.c
@@ -136,6 +136,7 @@ yelp_document_get_for_uri (YelpUri *uri)
{
static GHashTable *documents = NULL;
gchar *docuri;
+ gchar *page_id, *tmp;
YelpDocument *document = NULL;
if (documents == NULL)
@@ -148,6 +149,24 @@ yelp_document_get_for_uri (YelpUri *uri)
if (docuri == NULL)
return NULL;
+ switch (yelp_uri_get_document_type (uri)) {
+ case YELP_URI_DOCUMENT_TYPE_TEXT:
+ case YELP_URI_DOCUMENT_TYPE_HTML:
+ case YELP_URI_DOCUMENT_TYPE_XHTML:
+ /* We use YelpSimpleDocument for these, which is a single-file
+ * responder. But the document URI may be set to the directory
+ * holding the file, to allow a directory of HTML files to act
+ * as a single document. So we cache these by a fuller URI.
+ */
+ page_id = yelp_uri_get_page_id (uri);
+ tmp = g_strconcat (docuri, "/", page_id, NULL);
+ g_free (page_id);
+ g_free (docuri);
+ docuri = tmp;
+ break;
+ default:
+ break;
+ }
document = g_hash_table_lookup (documents, docuri);
if (document != NULL) {
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c
index 7e76042c..e59494ed 100644
--- a/libyelp/yelp-uri.c
+++ b/libyelp/yelp-uri.c
@@ -288,7 +288,7 @@ resolve_async (YelpUri *uri)
case YELP_URI_DOCUMENT_TYPE_TEXT:
case YELP_URI_DOCUMENT_TYPE_HTML:
case YELP_URI_DOCUMENT_TYPE_XHTML:
- /* FIXME: look up a relative file */
+ resolve_file_path (uri);
break;
case YELP_URI_DOCUMENT_TYPE_TOC:
/* FIXME: what do we do? */
@@ -468,6 +468,13 @@ resolve_file_path (YelpUri *uri)
gchar *path;
const gchar *hash = strchr (priv->res_arg, '#');
+ /* Treat xref: URIs like relative file paths */
+ if (g_str_has_prefix (priv->res_arg, "xref:")) {
+ gchar *tmp = g_strdup (priv->res_arg + 5);
+ g_free (priv->res_arg);
+ priv->res_arg = tmp;
+ }
+
if (priv->res_base)
base_priv = GET_PRIV (priv->res_base);
@@ -1103,15 +1110,25 @@ resolve_gfile (YelpUri *uri, const gchar *hash)
priv->frag_id = g_strdup (splithash[1]);
}
}
- else if (g_str_equal (mime_type, "text/html")) {
- priv->tmptype = YELP_URI_DOCUMENT_TYPE_HTML;
- if (priv->frag_id == NULL)
- priv->frag_id = g_strdup (hash);
- }
- else if (g_str_equal (mime_type, "application/xhtml+xml")) {
- priv->tmptype = YELP_URI_DOCUMENT_TYPE_XHTML;
+ else if (g_str_equal (mime_type, "text/html") ||
+ g_str_equal (mime_type, "application/xhtml+xml")) {
+ GFile *parent = g_file_get_parent (priv->gfile);
+ priv->docuri = g_file_get_uri (parent);
+ g_object_unref (parent);
+ priv->tmptype = mime_type[0] == 't' ? YELP_URI_DOCUMENT_TYPE_HTML : YELP_URI_DOCUMENT_TYPE_XHTML;
+ if (priv->page_id == NULL)
+ priv->page_id = g_file_get_basename (priv->gfile);
if (priv->frag_id == NULL)
priv->frag_id = g_strdup (hash);
+ if (priv->fulluri == NULL) {
+ gchar *fulluri;
+ fulluri = g_file_get_uri (priv->gfile);
+ priv->fulluri = g_strconcat (fulluri,
+ priv->frag_id ? "#" : NULL,
+ priv->frag_id,
+ NULL);
+ g_free (fulluri);
+ }
}
else if (g_str_equal (mime_type, "application/x-gzip")) {
if (g_str_has_suffix (basename, ".info.gz"))
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index baf15bd7..6ef75139 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -66,6 +66,9 @@ static void view_resource_request (WebKitWebView *vi
WebKitNetworkRequest *request,
WebKitNetworkResponse *response,
gpointer user_data);
+static void view_title_changed (WebKitWebView *view,
+ GParamSpec *spec,
+ gpointer user_data);
static void view_print (GtkAction *action,
YelpView *view);
@@ -204,6 +207,8 @@ yelp_view_init (YelpView *view)
G_CALLBACK (view_navigation_requested), NULL);
g_signal_connect (view, "resource-request-starting",
G_CALLBACK (view_resource_request), NULL);
+ g_signal_connect (view, "notify::title",
+ G_CALLBACK (view_title_changed), NULL);
priv->action_group = gtk_action_group_new ("YelpView");
gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE);
@@ -402,7 +407,10 @@ yelp_view_get_property (GObject *object,
g_value_set_string (value, priv->page_desc);
break;
case PROP_PAGE_ICON:
- g_value_set_string (value, priv->page_icon);
+ if (priv->page_icon)
+ g_value_set_string (value, priv->page_icon);
+ else
+ g_value_set_string (value, "help-contents");
break;
case PROP_STATE:
g_value_set_enum (value, priv->state);
@@ -610,6 +618,20 @@ view_resource_request (WebKitWebView *view,
}
static void
+view_title_changed (WebKitWebView *view,
+ GParamSpec *spec,
+ gpointer user_data)
+{
+ YelpViewPrivate *priv = GET_PRIV (view);
+ if (priv->page_title == NULL) {
+ priv->page_title = g_strdup (webkit_web_view_get_title (view));
+ spec = g_object_class_find_property ((GObjectClass *) YELP_VIEW_GET_CLASS (view),
+ "page-title");
+ g_signal_emit_by_name (view, "notify::page-title", spec);
+ }
+}
+
+static void
view_print (GtkAction *action, YelpView *view)
{
webkit_web_frame_print (webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)));