2006-04-12 [wwp] 2.1.0cvs32
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 12 Apr 2006 07:17:36 +0000 (07:17 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 12 Apr 2006 07:17:36 +0000 (07:17 +0000)
* src/prefs_gtk.c
fix for bug #935: always store prefs files in UTF-8 (thanks
to Colin).

ChangeLog
PATCHSETS
configure.ac
src/prefs_gtk.c

index bd5d682..84c1425 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-12 [wwp]       2.1.0cvs32
+
+       * src/prefs_gtk.c
+               fix for bug #935: always store prefs files in UTF-8 (thanks
+               to Colin).
+
 2006-04-11 [colin]     2.1.0cvs31
 
        * src/compose.c
index 8576dea..f1a2a5a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.261 -r 1.382.2.262 src/compose.c;  cvs diff -u -r 1.204.2.83 -r 1.204.2.84 src/prefs_common.c;  ) > 2.1.0cvs29.patchset
 ( cvs diff -u -r 1.149.2.46 -r 1.149.2.47 src/inc.c;  ) > 2.1.0cvs30.patchset
 ( cvs diff -u -r 1.382.2.262 -r 1.382.2.263 src/compose.c;  ) > 2.1.0cvs31.patchset
+( cvs diff -u -r 1.10.2.18 -r 1.10.2.19 src/prefs_gtk.c;  ) > 2.1.0cvs32.patchset
index c96c05a..abdaae2 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=1
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=31
+EXTRA_VERSION=32
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 24fa2cf..718353d 100644 (file)
@@ -62,6 +62,9 @@ void prefs_read_config(PrefParam *param, const gchar *label,
        g_return_if_fail(label != NULL);
        g_return_if_fail(rcfile != NULL);
 
+       if (encoding != NULL)
+               g_warning("Encoding is ignored\n");
+
        debug_print("Reading configuration...\n");
 
        prefs_set_default(param);
@@ -138,13 +141,19 @@ void prefs_config_parse_one_line(PrefParam *param, const gchar *buf)
                switch (param[i].type) {
                case P_STRING:
                {
-                       gchar *tmp;
+                       gchar *tmp = NULL;
 
-                       tmp = *value ?
-                               conv_codeset_strdup(value,
-                                                   conv_get_locale_charset_str(),
-                                                   CS_UTF_8)
-                               : g_strdup("");
+                       if (*value) {
+                               if (g_utf8_validate(value, -1, NULL))
+                                       tmp = g_strdup(value);
+                               else {
+                                       tmp = conv_codeset_strdup(value,
+                                                   conv_get_locale_charset_str_no_utf8(),
+                                                   CS_INTERNAL);
+                               }
+                       } else {
+                               tmp = g_strdup("");
+                       }
                        if (!tmp) {
                                g_warning("failed to convert character set.");
                                tmp = g_strdup(value);
@@ -293,11 +302,15 @@ gint prefs_write_param(PrefParam *param, FILE *fp)
                        gchar *tmp = NULL;
 
                        if (*((gchar **)param[i].data)) {
-                               tmp = conv_codeset_strdup(*((gchar **)param[i].data),
-                                                         CS_UTF_8,
-                                                         conv_get_locale_charset_str());
-                               if (!tmp)
+                               if (g_utf8_validate(*((gchar **)param[i].data), -1, NULL))
                                        tmp = g_strdup(*((gchar **)param[i].data));
+                               else {
+                                       tmp = conv_codeset_strdup(*((gchar **)param[i].data),
+                                               conv_get_locale_charset_str_no_utf8(),
+                                               CS_INTERNAL);
+                                       if (!tmp)
+                                               tmp = g_strdup(*((gchar **)param[i].data));
+                               }
                        }
 
                        g_snprintf(buf, sizeof(buf), "%s=%s\n", param[i].name,
@@ -386,7 +399,7 @@ void prefs_set_default(PrefParam *param)
                                        tmp = envstr && *envstr ?
                                                conv_codeset_strdup(envstr,
                                                                    conv_get_locale_charset_str(),
-                                                                   CS_UTF_8)
+                                                                   CS_INTERNAL)
                                                : g_strdup("");
                                        if (!tmp) {
                                                g_warning("faild to convert character set.");