[gtk+/gtk-3-10] stackswitcher: Only show a button if the stack child is visible



commit feaae5db5e8693f11bd187619f2580c84c5a65d1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Oct 17 16:05:05 2013 -0400

    stackswitcher: Only show a button if the stack child is visible

 gtk/gtkstackswitcher.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index b8e008e..9f61850 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -156,7 +156,7 @@ update_button (GtkStackSwitcher *self,
 
   rebuild_child (button, icon_name, title);
 
-  gtk_widget_set_visible (button, title != NULL || icon_name != NULL);
+  gtk_widget_set_visible (button, gtk_widget_get_visible (widget) && (title != NULL || icon_name != NULL));
 
   if (icon_name != NULL)
     gtk_widget_set_size_request (button, -1, -1);
@@ -168,9 +168,9 @@ update_button (GtkStackSwitcher *self,
 }
 
 static void
-on_title_icon_updated (GtkWidget        *widget,
-                       GParamSpec       *pspec,
-                       GtkStackSwitcher *self)
+on_title_icon_visible_updated (GtkWidget        *widget,
+                               GParamSpec       *pspec,
+                               GtkStackSwitcher *self)
 {
   GtkWidget *button;
   GtkStackSwitcherPrivate *priv;
@@ -227,8 +227,9 @@ add_child (GtkStackSwitcher *self,
 
   g_object_set_data (G_OBJECT (button), "stack-child", widget);
   g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), self);
-  g_signal_connect (widget, "child-notify::title", G_CALLBACK (on_title_icon_updated), self);
-  g_signal_connect (widget, "child-notify::icon-name", G_CALLBACK (on_title_icon_updated), self);
+  g_signal_connect (widget, "notify::visible", G_CALLBACK (on_title_icon_visible_updated), self);
+  g_signal_connect (widget, "child-notify::title", G_CALLBACK (on_title_icon_visible_updated), self);
+  g_signal_connect (widget, "child-notify::icon-name", G_CALLBACK (on_title_icon_visible_updated), self);
   g_signal_connect (widget, "child-notify::position", G_CALLBACK (on_position_updated), self);
 
   g_hash_table_insert (priv->buttons, widget, button);


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