[yelp] Let ghelp: URIs reference Mallard documents, stop-gap for 2.28



commit a4dd0c67948a1cd458767d72b73c80e15d31bd0c
Author: Shaun McCance <shaunm gnome org>
Date:   Sun Aug 9 15:46:03 2009 -0500

    Let ghelp: URIs reference Mallard documents, stop-gap for 2.28

 src/yelp-mallard.c |    2 +-
 src/yelp-utils.c   |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/src/yelp-mallard.c b/src/yelp-mallard.c
index 30c5208..611a033 100644
--- a/src/yelp-mallard.c
+++ b/src/yelp-mallard.c
@@ -376,7 +376,7 @@ mallard_try_run (YelpMallard *mallard,
 
     page_data = g_hash_table_lookup (mallard->priv->pages_hash, page_id);
     if (page_data == NULL) {
-        printf ("FIXME: page not found\n");
+        printf ("FIXME: page not found: %s\n", page_id);
         return;
     }
 
diff --git a/src/yelp-utils.c b/src/yelp-utils.c
index 3444306..4330360 100644
--- a/src/yelp-utils.c
+++ b/src/yelp-utils.c
@@ -92,7 +92,8 @@ resolve_process_ghelp (char *uri, gchar **result)
 	else if (g_str_equal (mime, "text/plain"))
 	    type = YELP_RRN_TYPE_TEXT;
 
-    } else {
+    }
+    else if (uri[6] == '/') {
 	gint file_cut = 6;
 	/* If a full file path after ghelp:, see if the file
 	 * exists and return type if it does 
@@ -102,6 +103,36 @@ resolve_process_ghelp (char *uri, gchar **result)
 	type = resolve_full_file (&uri[file_cut]);
 	*result = g_strdup (&uri[file_cut]);
     }
+    else {
+        const gchar * const *dirs = g_get_system_data_dirs ();
+        gchar *dir, *hash;
+        gint i;
+        hash = strchr (uri + 6, '#');
+        if (hash) {
+            dir = g_strndup (uri + 6, hash + 6);
+            hash++;
+        } else {
+            dir = g_strdup (uri + 6);
+            hash = NULL;
+        }
+        for (i = 0; type != YELP_RRN_TYPE_MAL && dirs[i]; i++) {
+            gchar *path = g_strdup_printf ("%s/gnome/help/%s", dirs[i], dir);
+            if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
+                const gchar * const *langs = g_get_language_names ();
+                gint j;
+                for (j = 0; type != YELP_RRN_TYPE_MAL && langs[j]; j++) {
+                    gchar *index = g_strdup_printf ("%s/gnome/help/%s/%s/index.page", dirs[i], dir, langs[j]);
+                    if (g_file_test (index, G_FILE_TEST_IS_REGULAR)) {
+                        type = YELP_RRN_TYPE_MAL;
+                        *result = g_strdup_printf ("%s/gnome/help/%s/%s", dirs[i], dir, langs[j]);
+                    }
+                    g_free (index);
+                }
+            }
+            g_free (path);
+        }
+        g_free (dir);
+    }
 
     return type;
 }



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