[gnome-control-center] region: Display current locale country in formats if setting is empty



commit bbc28af85d17b79ca04d07108c5cc9c5bf70f317
Author: Rui Matos <tiagomatos gmail com>
Date:   Sun Mar 10 02:10:20 2013 +0100

    region: Display current locale country in formats if setting is empty
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694888

 panels/region/cc-region-panel.c |   46 +++++++++++++++++++++++++++-----------
 1 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 3eb54c6..ea15e30 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -20,6 +20,7 @@
  */
 
 #include <config.h>
+#include <locale.h>
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <gio/gdesktopappinfo.h>
@@ -424,6 +425,33 @@ activate_language_child (CcRegionPanel *self, GtkWidget *child)
 }
 
 static void
+update_region_label (CcRegionPanel *self)
+{
+        CcRegionPanelPrivate *priv = self->priv;
+        const gchar *region;
+        gchar *name;
+
+        if (priv->region == NULL || priv->region[0] == '\0')
+                region = priv->language;
+        else
+                region = priv->region;
+
+        name = gnome_get_country_from_locale (region, region);
+        gtk_label_set_label (GTK_LABEL (priv->formats_label), name);
+        g_free (name);
+}
+
+static void
+update_region_from_setting (CcRegionPanel *self)
+{
+        CcRegionPanelPrivate *priv = self->priv;
+
+        g_free (priv->region);
+        priv->region = g_settings_get_string (priv->locale_settings, KEY_REGION);
+        update_region_label (self);
+}
+
+static void
 update_language_label (CcRegionPanel *self)
 {
        CcRegionPanelPrivate *priv = self->priv;
@@ -440,6 +468,9 @@ update_language_label (CcRegionPanel *self)
                 name = g_strdup (C_("Language", "None"));
         gtk_label_set_label (GTK_LABEL (priv->language_label), name);
         g_free (name);
+
+        /* Formats will change too if not explicitly set. */
+        update_region_label (self);
 }
 
 static void
@@ -459,19 +490,6 @@ update_language_from_user (CcRegionPanel *self)
 }
 
 static void
-update_region_from_setting (CcRegionPanel *self)
-{
-       CcRegionPanelPrivate *priv = self->priv;
-        gchar *name;
-
-        g_free (priv->region);
-        priv->region = g_settings_get_string (priv->locale_settings, KEY_REGION);
-        name = gnome_get_country_from_locale (priv->region, priv->region);
-        gtk_label_set_label (GTK_LABEL (priv->formats_label), name);
-        g_free (name);
-}
-
-static void
 setup_language_section (CcRegionPanel *self)
 {
        CcRegionPanelPrivate *priv = self->priv;
@@ -502,8 +520,8 @@ setup_language_section (CcRegionPanel *self)
         g_signal_connect_swapped (widget, "child-activated",
                                   G_CALLBACK (activate_language_child), self);
 
-        update_region_from_setting (self);
         update_language_from_user (self);
+        update_region_from_setting (self);
 }
 
 #ifdef HAVE_IBUS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]