[gnome-control-center] common: Keep language chooser labels centered



commit 7c341ed630116b7d0bbd1146acb9ea7b65f58731
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri Mar 15 18:54:54 2013 +0100

    common: Keep language chooser labels centered
    
    In order to prevent the labels from moving around when hiding and
    showing the check mark we need to keep the check mark always visible
    and instead tweak its opacity.
    
    We also add an always transparent widget the same size as the check
    mark on the other side of the label to make sure that the label is
    globally centered.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695536

 panels/common/cc-language-chooser.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/panels/common/cc-language-chooser.c b/panels/common/cc-language-chooser.c
index f095602..38933d4 100644
--- a/panels/common/cc-language-chooser.c
+++ b/panels/common/cc-language-chooser.c
@@ -70,7 +70,7 @@ set_locale_id (GtkDialog *chooser,
                 if (g_strcmp0 (locale_id, language) == 0) {
                         gboolean is_extra;
 
-                        gtk_widget_show (check);
+                        gtk_widget_set_opacity (check, 1.0);
 
                         /* make sure the selected language is shown */
                         is_extra = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (row), "is-extra"));
@@ -79,7 +79,7 @@ set_locale_id (GtkDialog *chooser,
                                 egg_list_box_refilter (EGG_LIST_BOX (priv->language_list));
                         }
                 } else {
-                        gtk_widget_hide (check);
+                        gtk_widget_set_opacity (check, 0.0);
                 }
         }
         g_list_free (children);
@@ -140,13 +140,21 @@ language_widget_new (const gchar *locale_id,
 
         widget = padded_label_new (locale_name, is_extra);
 
+        /* We add a check on each side of the label to keep it centered. */
         check = gtk_image_new ();
         gtk_image_set_from_icon_name (GTK_IMAGE (check), "object-select-symbolic", GTK_ICON_SIZE_MENU);
-        gtk_widget_set_no_show_all (check, TRUE);
+        gtk_widget_set_opacity (check, 0.0);
+        g_object_set (check, "icon-size", GTK_ICON_SIZE_MENU, NULL);
+        gtk_box_pack_start (GTK_BOX (widget), check, FALSE, FALSE, 0);
+        gtk_box_reorder_child (GTK_BOX (widget), check, 0);
+
+        check = gtk_image_new ();
+        gtk_image_set_from_icon_name (GTK_IMAGE (check), "object-select-symbolic", GTK_ICON_SIZE_MENU);
+        gtk_widget_set_opacity (check, 0.0);
         g_object_set (check, "icon-size", GTK_ICON_SIZE_MENU, NULL);
         gtk_box_pack_start (GTK_BOX (widget), check, FALSE, FALSE, 0);
         if (g_strcmp0 (locale_id, current_locale_id) == 0)
-                gtk_widget_show (check);
+                gtk_widget_set_opacity (check, 1.0);
 
         g_object_set_data (G_OBJECT (widget), "check", check);
         g_object_set_data_full (G_OBJECT (widget), "locale-id", g_strdup (locale_id), g_free);


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