[gtk+] GtkStyleContext is meant to have a GdkScreen
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkStyleContext is meant to have a GdkScreen
- Date: Sun, 6 Feb 2011 10:25:29 +0000 (UTC)
commit 217d3fd796c29c01dac9420b5ff599d2a55d9d73
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Feb 6 02:40:06 2011 +0100
GtkStyleContext is meant to have a GdkScreen
It is used to get the default providers, without them
the style context can't do much. A check for NULL screen
is done before any sensitive call to
gtk_style_context_set_screen(), in the hope that any widget
will open the display before doing anything related to
styling. Fixes bug #641429, reported by Bastien Nocera.
gtk/gtkstyle.c | 1 +
gtk/gtkstylecontext.c | 2 +-
gtk/gtkwidget.c | 16 ++++++++++++----
3 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 5347119..1d31d1e 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -822,6 +822,7 @@ _gtk_style_new_for_path (GdkScreen *screen,
if (screen)
gtk_style_context_set_screen (context, screen);
+
gtk_style_context_set_path (context, path);
style = g_object_new (GTK_TYPE_STYLE,
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 6eed378..7cd0dab 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2617,7 +2617,7 @@ gtk_style_context_set_screen (GtkStyleContext *context,
GtkStyleContextPrivate *priv;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
+ g_return_if_fail (GDK_IS_SCREEN (screen));
priv = context->priv;
if (priv->screen == screen)
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 74d83f2..bea97d8 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -7738,11 +7738,15 @@ gtk_widget_set_parent (GtkWidget *widget,
if (widget->priv->context)
{
+ GdkScreen *screen;
+
_gtk_widget_update_path (widget);
gtk_style_context_set_path (widget->priv->context, widget->priv->path);
- gtk_style_context_set_screen (widget->priv->context,
- gtk_widget_get_screen (widget));
+ screen = gtk_widget_get_screen (widget);
+
+ if (screen)
+ gtk_style_context_set_screen (widget->priv->context, screen);
}
gtk_widget_pop_verify_invariants (widget);
@@ -14171,6 +14175,8 @@ gtk_widget_get_style_context (GtkWidget *widget)
if (G_UNLIKELY (!widget->priv->context))
{
+ GdkScreen *screen;
+
widget->priv->context = g_object_new (GTK_TYPE_STYLE_CONTEXT,
"direction", gtk_widget_get_direction (widget),
NULL);
@@ -14178,8 +14184,10 @@ gtk_widget_get_style_context (GtkWidget *widget)
g_signal_connect (widget->priv->context, "changed",
G_CALLBACK (style_context_changed), widget);
- gtk_style_context_set_screen (widget->priv->context,
- gtk_widget_get_screen (widget));
+ screen = gtk_widget_get_screen (widget);
+
+ if (screen)
+ gtk_style_context_set_screen (widget->priv->context, screen);
_gtk_widget_update_path (widget);
gtk_style_context_set_path (widget->priv->context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]