[Xfce4-commits] <exo:xfce-4.6> Add support for iocharset in exo-mount (bug #4294).

Nick Schermer noreply at xfce.org
Fri Oct 9 14:38:02 CEST 2009


Updating branch refs/heads/xfce-4.6
         to 8aa65148d867bc94877b51324b646ad345b8a791 (commit)
       from b33a62439e9766865a5556848981177ae7717b8f (commit)

commit 8aa65148d867bc94877b51324b646ad345b8a791
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 766b39d..e70850d 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 f08439e..f4d62db 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