[yelp] libyelp: Fixed resolving of HTML and TXT documents



commit 41a613acfce5d6a35513d38fa4e58e2fbd472c24
Author: Shaun McCance <shaunm gnome org>
Date:   Sun Sep 18 22:09:06 2011 -0400

    libyelp: Fixed resolving of HTML and TXT documents

 libyelp/yelp-document.c        |    2 ++
 libyelp/yelp-simple-document.c |   24 +++++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c
index 3fcedd1..d6c0ff7 100644
--- a/libyelp/yelp-document.c
+++ b/libyelp/yelp-document.c
@@ -181,8 +181,10 @@ yelp_document_get_for_uri (YelpUri *uri)
          * holding the file, to allow a directory of HTML files to act
          * as a single document. So we cache these by a fuller URI.
          */
+        docuri = yelp_uri_get_document_uri (uri);
         page_id = yelp_uri_get_page_id (uri);
         tmp = g_strconcat (docuri, "/", page_id, NULL);
+        g_free (docuri);
         g_free (page_id);
         docuri = tmp;
         break;
diff --git a/libyelp/yelp-simple-document.c b/libyelp/yelp-simple-document.c
index 8f2dadc..28dd31b 100644
--- a/libyelp/yelp-simple-document.c
+++ b/libyelp/yelp-simple-document.c
@@ -44,6 +44,7 @@ struct _Request {
 struct _YelpSimpleDocumentPriv {
     GFile        *file;
     GInputStream *stream;
+    gchar        *page_id;
 
     gchar        *contents;
     gssize        contents_len;
@@ -158,6 +159,7 @@ yelp_simple_document_finalize (GObject *object)
 
     g_free (document->priv->contents);
     g_free (document->priv->mime_type);
+    g_free (document->priv->page_id);
 
     G_OBJECT_CLASS (yelp_simple_document_parent_class)->finalize (object);
 }
@@ -175,6 +177,7 @@ yelp_simple_document_new (YelpUri *uri)
     g_free (doc_uri);
 
     document->priv->file = yelp_uri_get_file (uri);
+    document->priv->page_id = yelp_uri_get_page_id (uri);
 
     return (YelpDocument *) document;
 }
@@ -294,15 +297,30 @@ file_info_cb (GFile              *file,
         document->priv->mime_type = g_strdup (type);
     g_object_unref (info);
 
-    if (g_str_equal (document->priv->mime_type, "text/plain")) {
-        gchar *basename = g_file_get_basename (document->priv->file);
+    if (document->priv->page_id) {
+        yelp_document_set_page_id (YELP_DOCUMENT (document),
+                                   document->priv->page_id,
+                                   document->priv->page_id);
+        yelp_document_set_page_id (YELP_DOCUMENT (document),
+                                   "//index",
+                                   document->priv->page_id);
+        yelp_document_set_page_id (YELP_DOCUMENT (document),
+                                   NULL,
+                                   document->priv->page_id);
+    }
+    else {
         yelp_document_set_page_id (YELP_DOCUMENT (document), "//index", "//index");
         yelp_document_set_page_id (YELP_DOCUMENT (document), NULL, "//index");
+    }
+
+    if (g_str_equal (document->priv->mime_type, "text/plain")) {
+        gchar *basename = g_file_get_basename (document->priv->file);
         yelp_document_set_page_title (YELP_DOCUMENT (document), "//index", basename);
-        yelp_document_set_page_icon (YELP_DOCUMENT (document), "//index", "text-x-generic");
         g_free (basename);
     }
 
+    yelp_document_set_page_icon (YELP_DOCUMENT (document), "//index", "yelp-page-symbolic");
+
     g_file_read_async (document->priv->file,
 		       G_PRIORITY_DEFAULT,
 		       NULL,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]