[gnome-control-center/gnome-3-8] region: Make sure not to display an empty input sources list



commit 365a7139f38eb65a6c7a8b28708631514114a0de
Author: Rui Matos <tiagomatos gmail com>
Date:   Sun Jun 16 23:08:23 2013 +0200

    region: Make sure not to display an empty input sources list
    
    Just like the system settings, the user's settings might be empty
    because some other component failed before us. Still, we shouldn't
    show an empty list since that looks broken.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701871

 panels/region/cc-region-panel.c |   38 +++++++++++++++++++++++++++++---------
 1 files changed, 29 insertions(+), 9 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 83c8946..72c5fc2 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -776,6 +776,22 @@ adjust_input_list_scrolling (CcRegionPanel *self)
         }
 }
 
+static void
+remove_no_input_row (GtkContainer *list)
+{
+        GList *l;
+
+        l = gtk_container_get_children (list);
+        if (!l)
+                return;
+        if (l->next != NULL)
+                goto out;
+        if (g_strcmp0 (g_object_get_data (G_OBJECT (l->data), "type"), "none") == 0)
+                gtk_container_remove (list, GTK_WIDGET (l->data));
+out:
+        g_list_free (l);
+}
+
 static GtkWidget *
 add_input_row (CcRegionPanel   *self,
                const gchar     *type,
@@ -788,14 +804,7 @@ add_input_row (CcRegionPanel   *self,
         GtkWidget *label;
         GtkWidget *image;
 
-        if (priv->login) {
-                GList *l;
-                l = gtk_container_get_children (GTK_CONTAINER (priv->input_list));
-                if (l && l->next == NULL &&
-                    g_strcmp0 (g_object_get_data (G_OBJECT (l->data), "type"), "none") == 0)
-                        gtk_container_remove (GTK_CONTAINER (priv->input_list), GTK_WIDGET (l->data));
-                g_list_free (l);
-        }
+        remove_no_input_row (GTK_CONTAINER (priv->input_list));
 
         row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
         label = gtk_label_new (name);
@@ -833,6 +842,12 @@ add_input_row (CcRegionPanel   *self,
 }
 
 static void
+add_no_input_row (CcRegionPanel *self)
+{
+        add_input_row (self, "none", "none", _("No input source selected"), NULL);
+}
+
+static void
 add_input_sources (CcRegionPanel *self,
                    GVariant      *sources)
 {
@@ -844,6 +859,11 @@ add_input_sources (CcRegionPanel *self,
         gchar *display_name;
         GDesktopAppInfo *app_info;
 
+        if (g_variant_n_children (sources) < 1) {
+                add_no_input_row (self);
+                return;
+        }
+
         g_variant_iter_init (&iter, sources);
         while (g_variant_iter_next (&iter, "(&s&s)", &type, &id)) {
                 display_name = NULL;
@@ -1506,7 +1526,7 @@ add_input_sources_from_localed (CcRegionPanel *self)
                 g_free (id);
         }
         if (n == 0) {
-                add_input_row (self, "none", "none", _("No input source selected"), NULL);
+                add_no_input_row (self);
         }
 
         g_strfreev (variants);


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