[Xfce4-commits] <exo:master> Add support for iocharset in exo-mount (bug #4294).
Nick Schermer
noreply at xfce.org
Fri Oct 9 14:38:01 CEST 2009
Updating branch refs/heads/master
to 8bf62890d12cfeb895014c0aa442db9a4c8856f4 (commit)
from 886816e1de4bb1dd9bc58858aa75a285b8353914 (commit)
commit 8bf62890d12cfeb895014c0aa442db9a4c8856f4
Author: Nick Schermer <nick at xfce.org>
Date: Fri Oct 9 14:35:37 2009 +0200
Add support for iocharset in exo-mount (bug #4294).
When the wrong charset if detected you can override it
with the environment variable EXO_MOUNT_IOCHARSET.
exo-mount/exo-mount-hal.c | 14 +++++++++++++-
exo-mount/main.c | 6 ++++++
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/exo-mount/exo-mount-hal.c b/exo-mount/exo-mount-hal.c
index 40a6c21..d5be8fa 100644
--- a/exo-mount/exo-mount-hal.c
+++ b/exo-mount/exo-mount-hal.c
@@ -661,6 +661,7 @@ exo_mount_hal_device_mount (ExoMountHalDevice *device,
const gchar *fs;
gchar *s;
gint m, n = 0;
+ const gchar *charset;
g_return_val_if_fail (device != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -713,7 +714,18 @@ exo_mount_hal_device_mount (ExoMountHalDevice *device,
&& strcmp (fs, "ntfs-3g") == 0)
{
/* we need to pass umask=0077 to ntfs-g3 or else it gets 0777 perms */
- options[n++] = g_strdup_printf ("umask=0077");
+ options[n++] = g_strdup ("umask=0077");
+ }
+ else if (strcmp (device->fsoptions[m], "iocharset=") == 0)
+ {
+ /* get the charset from a variable set by the user or glib */
+ charset = g_getenv ("EXO_MOUNT_IOCHARSET");
+ if (G_LIKELY (charset == NULL))
+ if (g_get_charset (&charset))
+ charset = "utf8";
+
+ if (G_LIKELY (charset != NULL && *charset != '\0'))
+ options[n++] = g_strdup_printf ("iocharset=%s", charset);
}
}
}
diff --git a/exo-mount/main.c b/exo-mount/main.c
index 1e837c3..904b133 100644
--- a/exo-mount/main.c
+++ b/exo-mount/main.c
@@ -38,6 +38,9 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
#include <glib/gstdio.h>
@@ -97,6 +100,9 @@ main (int argc, char **argv)
/* initialize the i18n support */
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+ /* unset the CTYPE so we get a reliable when setting the iocharset */
+ setlocale (LC_CTYPE, "");
+
/* initialize GTK+ */
if (!gtk_init_with_args (&argc, &argv, "Xfce mount", entries, GETTEXT_PACKAGE, &err))
{
More information about the Xfce4-commits
mailing list