[gtk+/gtk-style-context: 316/347] GtkStyle: Listen to context changes.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 316/347] GtkStyle: Listen to context changes.
- Date: Thu, 11 Nov 2010 01:31:04 +0000 (UTC)
commit e1f813157ecfd67af3aaa5ef7ced9abfb73b2a35
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Nov 3 12:18:48 2010 +0100
GtkStyle: Listen to context changes.
This way the GtkStyle is updated to the latest style info, actually
emitting ::style-set must be performed after invalidating the style
context.
gtk/gtkstyle.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 5b0721e..6c45302 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -79,6 +79,7 @@ typedef struct _GtkStylePrivate GtkStylePrivate;
struct _GtkStylePrivate {
GSList *color_hashes;
GtkStyleContext *context;
+ gulong context_changed_id;
};
enum {
@@ -610,7 +611,12 @@ gtk_style_finalize (GObject *object)
g_object_unref (style->rc_style);
if (priv->context)
- g_object_unref (priv->context);
+ {
+ if (priv->context_changed_id)
+ g_signal_handler_disconnect (priv->context, priv->context_changed_id);
+
+ g_object_unref (priv->context);
+ }
G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object);
}
@@ -736,6 +742,13 @@ gtk_style_update_from_context (GtkStyle *style)
}
static void
+style_context_changed (GtkStyleContext *context,
+ gpointer user_data)
+{
+ gtk_style_update_from_context (GTK_STYLE (user_data));
+}
+
+static void
gtk_style_constructed (GObject *object)
{
GtkStylePrivate *priv;
@@ -746,7 +759,8 @@ gtk_style_constructed (GObject *object)
{
gtk_style_update_from_context (GTK_STYLE (object));
- /* FIXME: Listen to context changes */
+ priv->context_changed_id = g_signal_connect (priv->context, "changed",
+ G_CALLBACK (style_context_changed), object);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]