[gtk+/wip/cssvalue: 16/137] stylecontext: Add setter for widget
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 16/137] stylecontext: Add setter for widget
- Date: Sat, 7 Apr 2012 11:08:38 +0000 (UTC)
commit 80f2846b10dd57fd55830c996653620e8dcf55b4
Author: Benjamin Otte <otte redhat com>
Date: Sun Mar 18 23:02:33 2012 +0100
stylecontext: Add setter for widget
... and actually set the widget on the style context. Note that this
function does not take a reference on the widget, which is a very good
reason to keep it private.
gtk/gtkstylecontext.c | 12 ++++++++++++
gtk/gtkstylecontextprivate.h | 4 +++-
gtk/gtkwidget.c | 6 +++++-
3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index b5e3a2f..9d6608e 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -361,6 +361,7 @@ struct _GtkStyleContextPrivate
GtkStyleCascade *cascade;
GtkStyleContext *parent;
+ GtkWidget *widget;
GtkWidgetPath *widget_path;
GHashTable *style_data;
GSList *info_stack;
@@ -1021,6 +1022,16 @@ gtk_style_context_new (void)
return g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL);
}
+void
+_gtk_style_context_set_widget (GtkStyleContext *context,
+ GtkWidget *widget)
+{
+ g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+ g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
+
+ context->priv->widget = widget;
+}
+
/**
* gtk_style_context_add_provider:
* @context: a #GtkStyleContext
@@ -1492,6 +1503,7 @@ gtk_style_context_set_path (GtkStyleContext *context,
g_return_if_fail (path != NULL);
priv = context->priv;
+ g_return_if_fail (priv->widget == NULL);
if (priv->widget_path)
{
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index dbec998..b35a3aa 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -24,7 +24,9 @@
G_BEGIN_DECLS
-GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
+void _gtk_style_context_set_widget (GtkStyleContext *context,
+ GtkWidget *widget);
+GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
const char *property_name);
double _gtk_style_context_get_number (GtkStyleContext *context,
const char *property_name,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 66f6674..9597f2c 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10402,7 +10402,10 @@ gtk_widget_finalize (GObject *object)
gtk_widget_path_free (priv->path);
if (priv->context)
- g_object_unref (priv->context);
+ {
+ _gtk_style_context_set_widget (priv->context, NULL);
+ g_object_unref (priv->context);
+ }
_gtk_widget_free_cached_sizes (widget);
@@ -14128,6 +14131,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
gtk_style_context_set_parent (priv->context,
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]