[gtk+/gtk-style-context: 250/260] GtkWidget: Store GtkStyleContext in private struct.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 250/260] GtkWidget: Store GtkStyleContext in private struct.
- Date: Wed, 20 Oct 2010 10:42:26 +0000 (UTC)
commit 105c88047710a5747959717d28545a202ca32c79
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Oct 11 19:27:36 2010 +0200
GtkWidget: Store GtkStyleContext in private struct.
gtk/gtkwidget.c | 69 ++++++++++++++++++++----------------------------------
1 files changed, 26 insertions(+), 43 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 0f473ed..efca7ba 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -299,6 +299,7 @@ struct _GtkWidgetPrivate
* the font to use for text.
*/
GtkStyle *style;
+ GtkStyleContext *context;
/* The widget's allocated size.
*/
@@ -622,7 +623,6 @@ static GQuark quark_tooltip_markup = 0;
static GQuark quark_has_tooltip = 0;
static GQuark quark_tooltip_window = 0;
static GQuark quark_visual = 0;
-static GQuark quark_style_context = 0;
GParamSpecPool *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
@@ -736,7 +736,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip");
quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
quark_visual = g_quark_from_static_string ("gtk-widget-visual");
- quark_style_context = g_quark_from_static_string ("gtk-style-context");
style_property_spec_pool = g_param_spec_pool_new (FALSE);
_gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
@@ -6298,12 +6297,8 @@ gtk_widget_real_query_tooltip (GtkWidget *widget,
static void
gtk_widget_real_style_updated (GtkWidget *widget)
{
- GtkStyleContext *context;
-
- context = g_object_get_qdata (G_OBJECT (widget),
- quark_style_context);
- if (context)
- gtk_style_context_invalidate (context);
+ if (widget->priv->context)
+ gtk_style_context_invalidate (widget->priv->context);
}
static gboolean
@@ -7322,7 +7317,6 @@ gtk_widget_set_parent (GtkWidget *widget,
{
GtkWidgetPrivate *priv;
GtkStateData data;
- GtkStyleContext *context;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_IS_WIDGET (parent));
@@ -7397,14 +7391,12 @@ gtk_widget_set_parent (GtkWidget *widget,
gtk_widget_queue_compute_expand (parent);
}
- context = g_object_get_qdata (G_OBJECT (widget),
- quark_style_context);
- if (context)
+ if (widget->priv->context)
{
_gtk_widget_update_path (widget);
- gtk_style_context_set_path (context, widget->priv->path);
+ gtk_style_context_set_path (widget->priv->context, widget->priv->path);
- gtk_style_context_set_screen (context,
+ gtk_style_context_set_screen (widget->priv->context,
gtk_widget_get_screen (widget));
}
}
@@ -8201,19 +8193,16 @@ _gtk_widget_propagate_screen_changed (GtkWidget *widget,
static void
reset_style_recurse (GtkWidget *widget, gpointer data)
{
- GtkStyleContext *context;
-
#if 0
if (widget->priv->rc_style)
gtk_widget_reset_rc_style (widget);
#endif
- context = g_object_get_qdata (G_OBJECT (widget),
- quark_style_context);
- if (context)
+ if (widget->priv->context)
{
_gtk_widget_update_path (widget);
- gtk_style_context_set_path (context, widget->priv->path);
+ gtk_style_context_set_path (widget->priv->context,
+ widget->priv->path);
}
if (GTK_IS_CONTAINER (widget))
@@ -9708,12 +9697,8 @@ gtk_widget_set_direction (GtkWidget *widget,
if (old_dir != gtk_widget_get_direction (widget))
{
- GtkStyleContext *context;
-
- context = g_object_get_qdata (G_OBJECT (widget), quark_style_context);
-
- if (context)
- gtk_style_context_set_direction (context,
+ if (widget->priv->context)
+ gtk_style_context_set_direction (widget->priv->context,
gtk_widget_get_direction (widget));
gtk_widget_emit_direction_changed (widget, old_dir);
@@ -9876,6 +9861,12 @@ gtk_widget_finalize (GObject *object)
if (accessible)
g_object_unref (accessible);
+ if (priv->path)
+ gtk_widget_path_free (priv->path);
+
+ if (priv->context)
+ g_object_unref (priv->context);
+
if (g_object_is_floating (object))
g_warning ("A floating object was finalized. This means that someone\n"
"called g_object_unref() on an object that had only a floating\n"
@@ -13372,32 +13363,24 @@ style_context_changed (GtkStyleContext *context,
GtkStyleContext *
gtk_widget_get_style_context (GtkWidget *widget)
{
- GtkStyleContext *context;
-
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- context = g_object_get_qdata (G_OBJECT (widget),
- quark_style_context);
-
- if (G_UNLIKELY (!context))
+ if (G_UNLIKELY (!widget->priv->context))
{
- context = g_object_new (GTK_TYPE_STYLE_CONTEXT,
- "direction", gtk_widget_get_direction (widget),
- NULL);
+ widget->priv->context = g_object_new (GTK_TYPE_STYLE_CONTEXT,
+ "direction", gtk_widget_get_direction (widget),
+ NULL);
- g_signal_connect (context, "changed",
+ g_signal_connect (widget->priv->context, "changed",
G_CALLBACK (style_context_changed), widget);
- g_object_set_qdata_full (G_OBJECT (widget),
- quark_style_context, context,
- (GDestroyNotify) g_object_unref);
-
- gtk_style_context_set_screen (context,
+ gtk_style_context_set_screen (widget->priv->context,
gtk_widget_get_screen (widget));
_gtk_widget_update_path (widget);
- gtk_style_context_set_path (context, widget->priv->path);
+ gtk_style_context_set_path (widget->priv->context,
+ widget->priv->path);
}
- return context;
+ return widget->priv->context;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]