[gtk+] widget: Create the widget's style lazily
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Create the widget's style lazily
- Date: Sat, 26 Mar 2011 23:55:29 +0000 (UTC)
commit af8a6a7abd02c0862be794c33e477ef2128a01ac
Author: Benjamin Otte <otte redhat com>
Date: Sat Mar 26 23:33:39 2011 +0100
widget: Create the widget's style lazily
That way we don't have to update the style's colors all the time on
theme changes when the widget is not actually using GtkStyle.
gtk/gtkwidget.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 7f47f1f..4c91548 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -7874,21 +7874,13 @@ gtk_widget_ensure_style (GtkWidget *widget)
if (priv->style == gtk_widget_get_default_style ())
{
- GtkStyle *style;
-
g_object_unref (priv->style);
- style = g_object_new (GTK_TYPE_STYLE,
- "context", gtk_widget_get_style_context (widget),
- NULL);
-
- priv->style = g_object_ref (style);
+ priv->style = NULL;
g_signal_emit (widget,
widget_signals[STYLE_SET],
0, NULL);
-
- g_object_unref (style);
}
}
@@ -7905,9 +7897,21 @@ gtk_widget_ensure_style (GtkWidget *widget)
GtkStyle*
gtk_widget_get_style (GtkWidget *widget)
{
+ GtkWidgetPrivate *priv;
+
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- return widget->priv->style;
+ priv = widget->priv;
+
+ if (priv->style == NULL)
+ {
+ priv->style = g_object_new (GTK_TYPE_STYLE,
+ "context", gtk_widget_get_style_context (widget),
+ NULL);
+
+ }
+
+ return priv->style;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]