diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ab66dd571a..bcbb91a850 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4389,10 +4389,7 @@ gtk_widget_realize (GtkWidget *widget) gtk_widget_ensure_style (widget); if (priv->style_update_pending) - { - g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0); - priv->style_update_pending = FALSE; - } + g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0); g_signal_emit (widget, widget_signals[REALIZE], 0); @@ -6471,13 +6468,16 @@ gtk_widget_real_query_tooltip (GtkWidget *widget, static void gtk_widget_real_style_updated (GtkWidget *widget) { - /* Trigger ::style-set for old - * widgets not listening to this - */ - g_signal_emit (widget, - widget_signals[STYLE_SET], - 0, - widget->priv->style); + if (gtk_widget_get_realized (widget)) + { + /* Trigger ::style-set for old + * widgets not listening to this + */ + g_signal_emit (widget, + widget_signals[STYLE_SET], + 0, + widget->priv->style); + } if (widget->priv->context) { @@ -7692,12 +7692,6 @@ gtk_widget_set_parent (GtkWidget *widget, gtk_widget_push_verify_invariants (widget); - if (!widget->priv->context) - { - /* Ensure the style context is there */ - gtk_widget_get_style_context (widget); - } - priv->parent = parent; parent_flags = gtk_widget_get_state_flags (parent); @@ -7713,7 +7707,7 @@ gtk_widget_set_parent (GtkWidget *widget, data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget); gtk_widget_propagate_state (widget, &data); - gtk_widget_reset_style (widget); + gtk_widget_reset_rc_styles (widget); g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL); if (priv->parent->priv->anchored) @@ -7753,6 +7747,19 @@ gtk_widget_set_parent (GtkWidget *widget, gtk_widget_queue_compute_expand (parent); } + if (widget->priv->context) + { + GdkScreen *screen; + + _gtk_widget_update_path (widget); + gtk_style_context_set_path (widget->priv->context, widget->priv->path); + + screen = gtk_widget_get_screen (widget); + + if (screen) + gtk_style_context_set_screen (widget->priv->context, screen); + } + gtk_widget_pop_verify_invariants (widget); } @@ -8703,16 +8710,9 @@ reset_style_recurse (GtkWidget *widget, gpointer data) { if (widget->priv->context) { - GdkScreen *screen; - _gtk_widget_update_path (widget); gtk_style_context_set_path (widget->priv->context, widget->priv->path); - - screen = gtk_widget_get_screen_unchecked (widget); - - if (screen) - gtk_style_context_set_screen (widget->priv->context, screen); } if (GTK_IS_CONTAINER (widget)) @@ -14304,13 +14304,12 @@ style_context_changed (GtkStyleContext *context, gtk_widget_update_pango_context (widget); - if (widget->priv->parent && - gtk_widget_get_screen_unchecked (widget)) + if (gtk_widget_get_realized (widget)) g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0); - else if (!gtk_widget_get_realized (widget)) + else { /* Compress all style updates so it - * is emitted at least once pre-realize + * is only emitted once pre-realize. */ widget->priv->style_update_pending = TRUE; }