[gtk+/wip/cssvalue: 17/164] stylecontext: Notify widget directly of changes



commit 0afa5ca41cbe24036246530a3a2cf35eac5bedde
Author: Benjamin Otte <otte redhat com>
Date:   Mon Mar 19 00:25:31 2012 +0100

    stylecontext: Notify widget directly of changes
    
    This way, we don't need to g_signal_connect(), which saves a bunch of
    memory and performance.

 gtk/gtkstylecontext.c  |   11 +++++++++++
 gtk/gtkwidget.c        |    9 ++-------
 gtk/gtkwidgetprivate.h |    2 ++
 3 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 9d6608e..8192a34 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -411,6 +411,15 @@ static GtkSymbolicColor *
 G_DEFINE_TYPE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT)
 
 static void
+gtk_style_context_real_changed (GtkStyleContext *context)
+{
+  GtkStyleContextPrivate *priv = context->priv;
+
+  if (priv->widget)
+    _gtk_widget_style_context_invalidated (priv->widget);
+}
+
+static void
 gtk_style_context_class_init (GtkStyleContextClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -419,6 +428,8 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
   object_class->set_property = gtk_style_context_impl_set_property;
   object_class->get_property = gtk_style_context_impl_get_property;
 
+  klass->changed = gtk_style_context_real_changed;
+
   signals[CHANGED] =
     g_signal_new (I_("changed"),
                   G_TYPE_FROM_CLASS (object_class),
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 9597f2c..0e5b04f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -14072,12 +14072,9 @@ gtk_widget_get_path (GtkWidget *widget)
   return widget->priv->path;
 }
 
-static void
-style_context_changed (GtkStyleContext *context,
-                       gpointer         user_data)
+void
+_gtk_widget_style_context_invalidated (GtkWidget *widget)
 {
-  GtkWidget *widget = user_data;
-
   if (gtk_widget_get_realized (widget))
     g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
   else
@@ -14132,8 +14129,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
                                       gtk_widget_get_style_context (priv->parent));
 
       _gtk_style_context_set_widget (priv->context, widget);
-      g_signal_connect (widget->priv->context, "changed",
-                        G_CALLBACK (style_context_changed), widget);
     }
 
   return widget->priv->context;
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 9774c13..608cf7c 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -173,6 +173,8 @@ void              _gtk_widget_set_captured_event_handler (GtkWidget
 gboolean          _gtk_widget_captured_event               (GtkWidget *widget,
                                                             GdkEvent  *event);
 
+void              _gtk_widget_style_context_invalidated    (GtkWidget *widget);
+
 G_END_DECLS
 
 #endif /* __GTK_WIDGET_PRIVATE_H__ */



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