[control-center] - Fix crasher running region and language with KDE apps installed

Bastien Nocera hadess at fedoraproject.org
Sat Feb 5 02:10:17 UTC 2011


commit b40eb4f1178e495d9f9babbca0da392ca00bee41
Author: Bastien Nocera <hadess at hadess.net>
Date:   Sat Feb 5 02:10:11 2011 +0000

    - Fix crasher running region and language with KDE apps installed

 ...-language-names-for-locales-with-3-letter.patch |  131 ++++++++++++++++++++
 control-center.spec                                |    7 +-
 2 files changed, 137 insertions(+), 1 deletions(-)
---
diff --git a/0001-common-Load-language-names-for-locales-with-3-letter.patch b/0001-common-Load-language-names-for-locales-with-3-letter.patch
new file mode 100644
index 0000000..7f24a4c
--- /dev/null
+++ b/0001-common-Load-language-names-for-locales-with-3-letter.patch
@@ -0,0 +1,131 @@
+From 40e2c9eed4a3a21d8e722bfda21dbf962dc7bc49 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess at hadess.net>
+Date: Thu, 3 Feb 2011 19:11:02 +0000
+Subject: [PATCH] common: Load language names for locales with 3 letters
+
+If software with "Chhattisgarhi" translations was loaded (such
+as k3b), we would fail to load the language name for it, as we
+were not parsing the ISO-639-3 database.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=641373
+---
+ panels/common/gdm-languages.c |   45 ++++++++++++++++++++++++++++++++--------
+ 1 files changed, 36 insertions(+), 9 deletions(-)
+
+diff --git a/panels/common/gdm-languages.c b/panels/common/gdm-languages.c
+index 5607221..fa2f040 100644
+--- a/panels/common/gdm-languages.c
++++ b/panels/common/gdm-languages.c
+@@ -781,15 +781,18 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
+         const char *ccode_longB;
+         const char *ccode_longT;
+         const char *ccode;
++        const char *ccode_id;
+         const char *lang_name;
+ 
+-        if (! g_str_equal (element_name, "iso_639_entry") || attr_names == NULL || attr_values == NULL) {
++        if (! (g_str_equal (element_name, "iso_639_entry") || g_str_equal (element_name, "iso_639_3_entry"))
++            || attr_names == NULL || attr_values == NULL) {
+                 return;
+         }
+ 
+         ccode = NULL;
+         ccode_longB = NULL;
+         ccode_longT = NULL;
++        ccode_id = NULL;
+         lang_name = NULL;
+ 
+         while (*attr_names && *attr_values) {
+@@ -817,6 +820,15 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
+                                 }
+                                 ccode_longT = *attr_values;
+                         }
++                } else if (g_str_equal (*attr_names, "id")) {
++                        /* skip if empty */
++                        if (**attr_values) {
++                                if (strlen (*attr_values) != 2 &&
++                                    strlen (*attr_values) != 3) {
++                                        return;
++                                }
++                                ccode_id = *attr_values;
++                        }
+                 } else if (g_str_equal (*attr_names, "name")) {
+                         lang_name = *attr_values;
+                 }
+@@ -844,6 +856,11 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
+                                      g_strdup (ccode_longT),
+                                      g_strdup (lang_name));
+         }
++        if (ccode_id != NULL) {
++                g_hash_table_insert (gdm_languages_map,
++                                     g_strdup (ccode_id),
++                                     g_strdup (lang_name));
++        }
+ }
+ 
+ static void
+@@ -934,20 +951,20 @@ territories_parse_start_tag (GMarkupParseContext      *ctx,
+ }
+ 
+ static void
+-languages_init (void)
++languages_variant_init (const char *variant)
+ {
+         GError  *error;
+         gboolean res;
+         char    *buf;
+         gsize    buf_len;
++        char    *filename;
+ 
+-        bindtextdomain ("iso_639", ISO_CODES_LOCALESDIR);
+-        bind_textdomain_codeset ("iso_639", "UTF-8");
+-
+-        gdm_languages_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
++        bindtextdomain (variant, ISO_CODES_LOCALESDIR);
++        bind_textdomain_codeset (variant, "UTF-8");
+ 
+         error = NULL;
+-        res = g_file_get_contents (ISO_CODES_DATADIR "/iso_639.xml",
++        filename = g_strdup_printf (ISO_CODES_DATADIR "/%s.xml", variant);
++        res = g_file_get_contents (filename,
+                                    &buf,
+                                    &buf_len,
+                                    &error);
+@@ -962,22 +979,32 @@ languages_init (void)
+ 
+                 if (! res) {
+                         g_warning ("Failed to parse '%s': %s\n",
+-                                   ISO_CODES_DATADIR "/iso_639.xml",
++                                   filename,
+                                    error->message);
+                         g_error_free (error);
++                        g_free (filename);
+                 }
+ 
+                 g_markup_parse_context_free (ctx);
+                 g_free (buf);
+         } else {
+                 g_warning ("Failed to load '%s': %s\n",
+-                           ISO_CODES_DATADIR "/iso_639.xml",
++                           filename,
+                            error->message);
+                 g_error_free (error);
+         }
+ }
+ 
+ static void
++languages_init (void)
++{
++        gdm_languages_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
++
++        languages_variant_init ("iso_639");
++        languages_variant_init ("iso_639_3");
++}
++
++static void
+ territories_init (void)
+ {
+         GError  *error;
+-- 
+1.7.4
+
diff --git a/control-center.spec b/control-center.spec
index 2b1f1eb..59bafa4 100644
--- a/control-center.spec
+++ b/control-center.spec
@@ -18,7 +18,7 @@
 Summary: Utilities to configure the GNOME desktop
 Name: control-center
 Version: 2.91.6
-Release: 4%{?dist}
+Release: 5%{?dist}
 Epoch: 1
 License: GPLv2+ and GFDL
 Group: User Interface/Desktops
@@ -92,6 +92,7 @@ Obsoletes: control-center-extra < 1:2.30.3-3
 Obsoletes: accountsdialog <= 0.6
 
 Patch0: 0001-datetime-Fix-crash-when-TZ-is-an-alias.patch
+Patch1: 0001-common-Load-language-names-for-locales-with-3-letter.patch
 
 %description
 This package contains configuration utilities for the GNOME desktop, which
@@ -129,6 +130,7 @@ utilities.
 %prep
 %setup -q -n gnome-control-center-%{version}
 %patch0 -p1 -b .tz-aliases
+%patch1 -p1 -b .iso-639-3
 
 %build
 autoreconf -f
@@ -234,6 +236,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor >&/dev/null || :
 
 
 %changelog
+* Sat Feb 05 2011 Bastien Nocera <bnocera at redhat.com> 2.91.6-5
+- Fix crasher running region and language with KDE apps installed
+
 * Fri Feb 04 2011 Bastien Nocera <bnocera at redhat.com> 2.91.6-4
 - Fix crasher running date and time on the live CD
 


More information about the scm-commits mailing list