[gtk+/gtk-3-0] widget: Propagate the right states to the widget when setting the parent



commit b467d5fdbba559bd1ab79e9da048aafb6201be9c
Author: Benjamin Otte <otte redhat com>
Date:   Wed Mar 30 16:38:45 2011 +0200

    widget: Propagate the right states to the widget when setting the parent

 gtk/gtkwidget.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9d214a1..29fa22b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -299,6 +299,13 @@
  * </refsect2>
  */
 
+/* Add flags here that should not be propagated to children. By default,
+ * all flags will be set on children (think prelight or active), but we
+ * might want to not do this for some.
+ */
+#define GTK_STATE_FLAGS_DONT_PROPAGATE (GTK_STATE_FLAG_FOCUSED)
+#define GTK_STATE_FLAGS_DO_PROPAGATE (~GTK_STATE_FLAGS_DONT_PROPAGATE)
+
 #define WIDGET_CLASS(w)	 GTK_WIDGET_GET_CLASS (w)
 #define	INIT_PATH_SIZE	(512)
 
@@ -7698,9 +7705,8 @@ gtk_widget_set_parent (GtkWidget *widget,
   parent_flags = gtk_widget_get_state_flags (parent);
 
   /* Merge both old state and current parent state,
-   * We don't want the insensitive flag to propagate
-   * to the new child though */
-  data.flags = parent_flags & ~GTK_STATE_FLAG_INSENSITIVE;
+   * making sure to only propagate the right states */
+  data.flags = parent_flags & GTK_STATE_FLAGS_DO_PROPAGATE;
   data.flags |= priv->state_flags;
 
   data.operation = STATE_CHANGE_REPLACE;
@@ -11238,8 +11244,8 @@ gtk_widget_propagate_state (GtkWidget    *widget,
         {
           GtkStateData child_data = *data;
 
-          /* Do not propagate focused state further */
-          child_data.flags &= ~GTK_STATE_FLAG_FOCUSED;
+          /* Make sure to only propate the right states further */
+          child_data.flags &= GTK_STATE_FLAGS_DO_PROPAGATE;
 
           if (child_data.use_forall)
             gtk_container_forall (GTK_CONTAINER (widget),



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