Commit bbc28af8 authored by Rui Matos's avatar Rui Matos
Browse files

region: Display current locale country in formats if setting is empty

https://bugzilla.gnome.org/show_bug.cgi?id=694888
parent 8cd8d8bd
......@@ -20,6 +20,7 @@
*/
#include <config.h>
#include <locale.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
......@@ -423,6 +424,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)
{
......@@ -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
......@@ -458,19 +489,6 @@ update_language_from_user (CcRegionPanel *self)
update_language_label (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)
{
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment