[Xfce4-commits] <ristretto:master> Revert "Simplify launch_help"
Stephan Arts
noreply at xfce.org
Sat Jan 14 17:52:05 CET 2012
Updating branch refs/heads/master
to 228347cee87601ec6c8a068df3d2afc46327885d (commit)
from 2ab305e4c618dace30d27eaa0a66c090e1bd6ef3 (commit)
commit 228347cee87601ec6c8a068df3d2afc46327885d
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Jan 14 16:48:48 2012 +0100
Revert "Simplify launch_help"
This reverts commit aa74058f8c7b53fcb0ef4956c8d7f2ec4aee4242.
Conflicts:
src/util.c
src/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/src/util.c b/src/util.c
index c1d48e8..d4916ff 100644
--- a/src/util.c
+++ b/src/util.c
@@ -26,8 +26,70 @@
gboolean
rstto_launch_help (void)
{
+ gchar *locale = NULL;
+ gchar *offset;
+ gchar *docpath = NULL;
gchar *cur_dir = g_get_current_dir();
- gchar *docpath = g_strdup("http://docs.xfce.org/apps/ristretto/start");
+
+ /* Find localized documentation path on disk */
+#ifdef ENABLE_NLS
+#ifdef HAVE_LOCALE_H
+ locale = g_strdup (setlocale (LC_MESSAGES, ""));
+ if (locale != NULL)
+ {
+ offset = g_strrstr (locale, ".");
+ if (offset != NULL)
+ {
+ *offset = '\0';
+ }
+ }
+ else
+ {
+ locale = g_strdup ("C");
+ }
+#else
+ locale = g_strdup ("C");
+#endif
+
+ docpath = g_strdup_printf (DOCDIR"/html/%s/index.html", locale);
+ if (!g_file_test (docpath, G_FILE_TEST_EXISTS))
+ {
+ offset = g_strrstr (locale, "_");
+ if (offset == NULL)
+ {
+ g_free (docpath);
+ docpath = g_strdup (DOCDIR"/html/C/index.html");
+ }
+ else
+ {
+ *offset = '\0';
+ g_free (docpath);
+ docpath = g_strdup_printf (DOCDIR"/html/%s/index.html", locale);
+ if (!g_file_test (docpath, G_FILE_TEST_EXISTS))
+ {
+ g_free (docpath);
+ docpath = g_strdup (DOCDIR"/html/C/index.html");
+ }
+ }
+ }
+
+ g_free (locale);
+#else
+ docpath = g_strdup (DOCDIR"/html/C/index.html");
+#endif
+
+ /* Revert to online documentation if not available on disk */
+ if (g_file_test (docpath, G_FILE_TEST_EXISTS))
+ {
+ gchar *tmp = docpath;
+ docpath = g_strdup_printf ("file://%s", docpath);
+ g_free (tmp);
+ }
+ else
+ {
+ g_free (docpath);
+ docpath = g_strdup("http://docs.xfce.org/apps/ristretto/start");
+ }
if (FALSE == exo_execute_preferred_application (
"WebBrowser",
More information about the Xfce4-commits
mailing list