[Xfce4-commits] <ristretto:master> Copy launch_help from xfce4-clipman-plugin
Stephan Arts
noreply at xfce.org
Fri Oct 28 17:12:02 CEST 2011
Updating branch refs/heads/master
to e9aaa9291ddec312b56422481953b510dd68d960 (commit)
from df78db5c1f1f3b924a2cbc6c7b99432e1d40ba9d (commit)
commit e9aaa9291ddec312b56422481953b510dd68d960
Author: Stephan Arts <stephan at xfce.org>
Date: Fri Oct 28 16:55:20 2011 +0200
Copy launch_help from xfce4-clipman-plugin
docs | 2 +-
src/util.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletions(-)
diff --git a/docs b/docs
index 538fcec..fe37bb2 160000
--- a/docs
+++ b/docs
@@ -1 +1 @@
-Subproject commit 538fcece452491a22c41a0c185d3040aa8c5f453
+Subproject commit fe37bb23cebea84d85a26a4cc6d1a49e780e7389
diff --git a/src/util.c b/src/util.c
index c9a0250..1acfd27 100644
--- a/src/util.c
+++ b/src/util.c
@@ -25,5 +25,81 @@
gboolean
rstto_launch_help (void)
{
+ gchar *locale = NULL;
+ gchar *offset;
+ gchar *docpath = NULL;
+ gchar *cur_dir = g_get_current_dir();
+
+ /* 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/help.php?package=ristretto");
+ }
+
+ if (FALSE == exo_execute_preferred_application (
+ "WebBrowser",
+ docpath,
+ cur_dir,
+ NULL,
+ NULL))
+ {
+
+ }
+
+ g_free (docpath);
+ g_free (cur_dir);
}
More information about the Xfce4-commits
mailing list