[yelp] [libyelp] Better handling of plain text documents



commit 24e5ad1546ab7daea079eb042ad3a71a45a6f48c
Author: Shaun McCance <shaunm gnome org>
Date:   Mon May 10 16:04:03 2010 -0500

    [libyelp] Better handling of plain text documents

 libyelp/yelp-simple-document.c |   22 ++++++++++++++++++++--
 libyelp/yelp-uri.c             |    3 +++
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/libyelp/yelp-simple-document.c b/libyelp/yelp-simple-document.c
index 0d50c8e..de62a9b 100644
--- a/libyelp/yelp-simple-document.c
+++ b/libyelp/yelp-simple-document.c
@@ -259,11 +259,16 @@ document_signal_all (YelpSimpleDocument *document)
     GSList *cur;
     for (cur = document->priv->reqs; cur != NULL; cur = cur->next) {
         Request *request = (Request *) cur->data;
-        if (request->callback)
+        if (request->callback) {
+            request->callback (request->document,
+                               YELP_DOCUMENT_SIGNAL_INFO,
+                               request->user_data,
+                               NULL);
             request->callback (request->document,
                                YELP_DOCUMENT_SIGNAL_CONTENTS,
                                request->user_data,
                                NULL);
+        }
     }
     return FALSE;
 }
@@ -278,8 +283,21 @@ file_info_cb (GFile              *file,
     GFileInfo *info = g_file_query_info_finish (file, result, NULL);
     const gchar *type = g_file_info_get_attribute_string (info,
 							  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
-    document->priv->mime_type = g_strdup (type);
+    if (g_str_equal (type, "text/x-readme"))
+        document->priv->mime_type = g_strdup ("text/plain");
+    else
+        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);
+        yelp_document_set_page_id (YELP_DOCUMENT (document), "//index", "//index");
+        yelp_document_set_page_id (YELP_DOCUMENT (document), NULL, "//index");
+        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);
+    }
+
     g_file_read_async (document->priv->file,
 		       G_PRIORITY_DEFAULT,
 		       NULL,
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c
index e59494e..58d137e 100644
--- a/libyelp/yelp-uri.c
+++ b/libyelp/yelp-uri.c
@@ -1164,6 +1164,9 @@ resolve_gfile (YelpUri *uri, const gchar *hash)
                 if (priv->frag_id == NULL)
                     priv->frag_id = g_strdup (hash);
             }
+            else if (g_str_equal (mime_type, "text/x-readme")) {
+                priv->tmptype = YELP_URI_DOCUMENT_TYPE_TEXT;
+            }
             else {
                 priv->tmptype = YELP_URI_DOCUMENT_TYPE_EXTERNAL;
             }



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