diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2011-02-06 02:40:06 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2011-02-06 11:21:42 +0100 |
commit | 217d3fd796c29c01dac9420b5ff599d2a55d9d73 (patch) | |
tree | 99ce236dffa82f2be75850d8f1f6e7dcb4b89195 /gtk | |
parent | f23585b7bb96d3da3844337aa8a99609ddbb89d4 (diff) | |
download | gtk+-217d3fd796c29c01dac9420b5ff599d2a55d9d73.tar.gz |
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.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkstyle.c | 1 | ||||
-rw-r--r-- | gtk/gtkstylecontext.c | 2 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 16 |
3 files changed, 14 insertions, 5 deletions
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 5347119ef0..1d31d1ef03 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 6eed378d0e..7cd0dab1c1 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 74d83f21ce..bea97d816b 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, |