[gtk+] stylecontext: Keep track of children



commit 1a51ea3ea3c50d71b772dd7a15468b1842ba230b
Author: Benjamin Otte <otte redhat com>
Date:   Tue Mar 20 02:06:00 2012 +0100

    stylecontext: Keep track of children

 gtk/gtkstylecontext.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 4e8e282..6bbc6d6 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -361,6 +361,7 @@ struct _GtkStyleContextPrivate
   GtkStyleCascade *cascade;
 
   GtkStyleContext *parent;
+  GSList *children;
   GtkWidget *widget;            
   GtkWidgetPath *widget_path;
   GHashTable *style_data;
@@ -806,6 +807,9 @@ gtk_style_context_finalize (GObject *object)
   style_context = GTK_STYLE_CONTEXT (object);
   priv = style_context->priv;
 
+  /* children hold a reference to us */
+  g_assert (priv->children == NULL);
+
   gtk_style_context_set_parent (style_context, NULL);
 
   if (priv->widget_path)
@@ -1580,10 +1584,16 @@ gtk_style_context_set_parent (GtkStyleContext *context,
     return;
 
   if (parent)
-    g_object_ref (parent);
+    {
+      parent->priv->children = g_slist_prepend (parent->priv->children, context);
+      g_object_ref (parent);
+    }
 
   if (priv->parent)
-    g_object_unref (priv->parent);
+    {
+      priv->parent->priv->children = g_slist_remove (priv->parent->priv->children, context);
+      g_object_unref (priv->parent);
+    }
 
   priv->parent = parent;
 



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