[gtk+/wip/matthiasc/tab-strip] Propagate needs-attention



commit 2e66f4201ac5b9ff984171d936ce786a3dce6439
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jun 8 14:53:07 2016 -0400

    Propagate needs-attention
    
    Add the .needs-attention style class to tabs whose pages have
    GtkStack::needs-attention set to TRUE.

 gtk/gtktabstrip.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtktabstrip.c b/gtk/gtktabstrip.c
index 93d56cd..92412c8 100644
--- a/gtk/gtktabstrip.c
+++ b/gtk/gtktabstrip.c
@@ -383,6 +383,34 @@ gtk_tab_strip_child_position_changed (GtkTabStrip *self,
 }
 
 static void
+gtk_tab_strip_child_needs_attention_changed (GtkTabStrip *self,
+                                             GParamSpec  *pspec,
+                                             GtkWidget   *child)
+{
+  GtkWidget *parent;
+  GtkWidget *tab;
+  gboolean needs_attention;
+  GtkStyleContext *context;
+
+  tab = g_object_get_data (G_OBJECT (child), "GTK_TAB");
+
+  if (!tab || !GTK_IS_TAB (tab))
+    return;
+
+  parent = gtk_widget_get_parent (child);
+
+  gtk_container_child_get (GTK_CONTAINER (parent), GTK_WIDGET (child),
+                           "needs-attention", &needs_attention,
+                           NULL);
+
+  context = gtk_widget_get_style_context (tab);
+  if (needs_attention)
+    gtk_style_context_add_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+  else
+    gtk_style_context_remove_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+}
+
+static void
 gtk_tab_strip_child_title_changed (GtkTabStrip *self,
                                    GParamSpec  *pspec,
                                    GtkWidget   *child)
@@ -522,6 +550,10 @@ gtk_tab_strip_stack_add (GtkTabStrip *self,
                            G_CALLBACK (gtk_tab_strip_child_title_changed), self,
                            G_CONNECT_SWAPPED);
 
+  g_signal_connect_object (widget, "child-notify::needs-attention",
+                           G_CALLBACK (gtk_tab_strip_child_needs_attention_changed), self,
+                           G_CONNECT_SWAPPED);
+
   gtk_box_pack_start (GTK_BOX (priv->tabs), GTK_WIDGET (tab), TRUE, TRUE, 0);
 
   g_object_bind_property (widget, "visible", tab, "visible", G_BINDING_SYNC_CREATE);


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