summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2010-05-10 16:04:03 -0500
committerShaun McCance <shaunm@gnome.org>2010-05-13 17:41:25 -0500
commit24e5ad1546ab7daea079eb042ad3a71a45a6f48c (patch)
tree75fe339eae9b6b5e587244e67ce4ca1bea0df5b1
parent1134e857f161a7cbefcdf7e1ac6bd86cd2095c25 (diff)
downloadyelp-24e5ad1546ab7daea079eb042ad3a71a45a6f48c.tar.gz
[libyelp] Better handling of plain text documents
-rw-r--r--libyelp/yelp-simple-document.c22
-rw-r--r--libyelp/yelp-uri.c3
2 files changed, 23 insertions, 2 deletions
diff --git a/libyelp/yelp-simple-document.c b/libyelp/yelp-simple-document.c
index 0d50c8e6..de62a9ba 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 e59494ed..58d137eb 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;
}