[gnome-control-center] cc-editable-button: use GtkStack instead of GtkNotebook



commit ed4653627bcd065ea0bcdd559fe7e7b057e6e935
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Aug 14 09:15:47 2014 +0200

    cc-editable-button: use GtkStack instead of GtkNotebook
    
    https://bugzilla.gnome.org/attachment.cgi?bugid=694325

 panels/user-accounts/um-editable-button.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/panels/user-accounts/um-editable-button.c b/panels/user-accounts/um-editable-button.c
index 4fc1ea7..acc7a2a 100644
--- a/panels/user-accounts/um-editable-button.c
+++ b/panels/user-accounts/um-editable-button.c
@@ -24,7 +24,7 @@
 #define EMPTY_TEXT "\xe2\x80\x94"
 
 struct _UmEditableButtonPrivate {
-        GtkNotebook *notebook;
+        GtkStack    *stack;
         GtkLabel    *label;
         GtkButton   *button;
 
@@ -38,6 +38,9 @@ struct _UmEditableButtonPrivate {
 
 #define UM_EDITABLE_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UM_TYPE_EDITABLE_BUTTON, 
UmEditableButtonPrivate))
 
+#define PAGE_LABEL "_label"
+#define PAGE_BUTTON "_button"
+
 enum {
         PROP_0,
         PROP_TEXT,
@@ -99,7 +102,7 @@ um_editable_button_set_editable (UmEditableButton *button,
         if (priv->editable != editable) {
                 priv->editable = editable;
 
-                gtk_notebook_set_current_page (priv->notebook, editable ? 1 : 0);
+                gtk_stack_set_visible_child_name (priv->stack, editable ? PAGE_BUTTON : PAGE_LABEL);
 
                 g_object_notify (G_OBJECT (button), "editable");
         }
@@ -127,6 +130,7 @@ update_fonts (UmEditableButton *button)
         }
         if (priv->weight_set) {
                 attr = pango_attr_weight_new (priv->weight);
+
                 pango_attr_list_insert (attrs, attr);
         }
 
@@ -396,29 +400,27 @@ um_editable_button_init (UmEditableButton *button)
         priv->scale = 1.0;
         priv->scale_set = FALSE;
 
-        priv->notebook = (GtkNotebook*)gtk_notebook_new ();
-        gtk_notebook_set_show_tabs (priv->notebook, FALSE);
-        gtk_notebook_set_show_border (priv->notebook, FALSE);
+        priv->stack = GTK_STACK (gtk_stack_new ());
 
         priv->label = (GtkLabel*)gtk_label_new (EMPTY_TEXT);
         gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
-        gtk_notebook_append_page (priv->notebook, (GtkWidget*)priv->label, NULL);
+        gtk_stack_add_named (priv->stack, GTK_WIDGET (priv->label), PAGE_LABEL);
 
         priv->button = (GtkButton*)gtk_button_new_with_label (EMPTY_TEXT);
         gtk_widget_set_receives_default ((GtkWidget*)priv->button, TRUE);
         gtk_button_set_relief (priv->button, GTK_RELIEF_NONE);
         gtk_button_set_alignment (priv->button, 0.0, 0.5);
-        gtk_notebook_append_page (priv->notebook, (GtkWidget*)priv->button, NULL);
+        gtk_stack_add_named (priv->stack, GTK_WIDGET (priv->button), PAGE_BUTTON);
         g_signal_connect (priv->button, "clicked", G_CALLBACK (button_clicked), button);
         g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->button)), "size-allocate", G_CALLBACK 
(update_button_padding), button);
 
-        gtk_container_add (GTK_CONTAINER (button), (GtkWidget*)priv->notebook);
+        gtk_container_add (GTK_CONTAINER (button), GTK_WIDGET (priv->stack));
 
-        gtk_widget_show ((GtkWidget*)priv->notebook);
+        gtk_widget_show ((GtkWidget*)priv->stack);
         gtk_widget_show ((GtkWidget*)priv->label);
         gtk_widget_show ((GtkWidget*)priv->button);
 
-        gtk_notebook_set_current_page (priv->notebook, 0);
+        gtk_stack_set_visible_child_name (priv->stack, PAGE_LABEL);
 }
 
 GtkWidget *


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