[gtk+] GtkHeaderBar: Update separator visibility when needed



commit 3404e92312d1305415ba92c6d4a892c5d11b1de6
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Aug 28 22:54:18 2014 -0400

    GtkHeaderBar: Update separator visibility when needed
    
    We need to be a little more forthcoming with showing and hiding
    the separators - their visibility now depends on the the visibility
    and pack type of the regular headerbar children. This was observed
    in gnome-contacts, where headerbar buttons are shown and hidden.

 gtk/gtkheaderbar.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 313bc47..2dd8dee 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -1473,6 +1473,14 @@ gtk_header_bar_set_property (GObject      *object,
 }
 
 static void
+notify_child_cb (GObject      *child,
+                 GParamSpec   *pspec,
+                 GtkHeaderBar *bar)
+{
+  _gtk_header_bar_update_separator_visibility (bar);
+}
+
+static void
 gtk_header_bar_pack (GtkHeaderBar *bar,
                      GtkWidget    *widget,
                      GtkPackType   pack_type)
@@ -1490,6 +1498,7 @@ gtk_header_bar_pack (GtkHeaderBar *bar,
 
   gtk_widget_freeze_child_notify (widget);
   gtk_widget_set_parent (widget, GTK_WIDGET (bar));
+  g_signal_connect (widget, "notify::visible", G_CALLBACK (notify_child_cb), bar);
   gtk_widget_child_notify (widget, "pack-type");
   gtk_widget_child_notify (widget, "position");
   gtk_widget_thaw_child_notify (widget);
@@ -1535,6 +1544,7 @@ gtk_header_bar_remove (GtkContainer *container,
   if (l)
     {
       child = l->data;
+      g_signal_handlers_disconnect_by_func (widget, notify_child_cb, bar);
       gtk_widget_unparent (child->widget);
       priv->children = g_list_delete_link (priv->children, l);
       g_free (child);
@@ -1635,16 +1645,18 @@ gtk_header_bar_set_child_property (GtkContainer *container,
                                    const GValue *value,
                                    GParamSpec   *pspec)
 {
+  GtkHeaderBar *bar = GTK_HEADER_BAR (container);
   GList *l;
   Child *child;
 
-  l = find_child_link (GTK_HEADER_BAR (container), widget);
+  l = find_child_link (bar, widget);
   child = l->data;
 
   switch (property_id)
     {
     case CHILD_PROP_PACK_TYPE:
       child->pack_type = g_value_get_enum (value);
+      _gtk_header_bar_update_separator_visibility (bar);
       break;
     default:
       GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);


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