[gtk+/wip/css: 128/143] widget: Only emit style-updated when we updated the style
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css: 128/143] widget: Only emit style-updated when we updated the style
- Date: Fri, 6 Jan 2012 14:56:56 +0000 (UTC)
commit 0a2756a96c2ab136dfc876620b49e370db5415cd
Author: Benjamin Otte <otte redhat com>
Date: Wed Jan 4 03:29:27 2012 +0100
widget: Only emit style-updated when we updated the style
Don't do anything upon style invalidation, only queue a resize and mark
the emission as necessary. Style-updated will then be emitted when a
style is queried the next time or when the resize loop runs.
gtk/gtksizerequest.c | 1 +
gtk/gtkwidget.c | 42 +++++++++++++++++++++++++++++-------------
gtk/gtkwidgetprivate.h | 1 +
3 files changed, 31 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 13c7b34..bb3fdbb 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -341,6 +341,7 @@ compute_size_for_orientation (GtkWidget *widget,
{
gint adjusted_min, adjusted_natural, adjusted_for_size = for_size;
+ _gtk_widget_ensure_style (widget);
gtk_widget_ensure_style (widget);
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 033aeb0..988bd69 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4400,7 +4400,10 @@ gtk_widget_realize (GtkWidget *widget)
gtk_widget_ensure_style (widget);
if (priv->style_update_pending)
- g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
+ {
+ g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
+ priv->style_update_pending = FALSE;
+ }
g_signal_emit (widget, widget_signals[REALIZE], 0);
@@ -6574,9 +6577,6 @@ gtk_widget_real_style_updated (GtkWidget *widget)
gtk_style_context_set_background (widget->priv->context,
widget->priv->window);
}
-
- if (widget->priv->anchored)
- gtk_widget_queue_resize (widget);
}
static gboolean
@@ -13819,20 +13819,34 @@ style_context_changed (GtkStyleContext *context,
{
GtkWidget *widget = user_data;
- if (gtk_widget_get_realized (widget))
- g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
- else
- {
- /* Compress all style updates so it
- * is only emitted once pre-realize.
- */
- widget->priv->style_update_pending = TRUE;
- }
+ widget->priv->style_update_pending = TRUE;
if (widget->priv->anchored)
gtk_widget_queue_resize (widget);
}
+void
+_gtk_widget_ensure_style (GtkWidget *widget)
+{
+ if (widget->priv->style_update_pending &&
+ gtk_widget_get_realized (widget))
+ {
+ widget->priv->style_update_pending = FALSE;
+
+ g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
+ }
+}
+
+static void
+style_context_updated (GtkStyleContext *context,
+ gpointer so_far_unused_update_info,
+ gpointer user_data)
+{
+ GtkWidget *widget = user_data;
+
+ _gtk_widget_ensure_style (widget);
+}
+
/**
* gtk_widget_get_style_context:
* @widget: a #GtkWidget
@@ -13865,6 +13879,8 @@ gtk_widget_get_style_context (GtkWidget *widget)
g_signal_connect (widget->priv->context, "changed",
G_CALLBACK (style_context_changed), widget);
+ g_signal_connect (widget->priv->context, "updated",
+ G_CALLBACK (style_context_updated), widget);
screen = gtk_widget_get_screen (widget);
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 35f99b9..621505c 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -161,6 +161,7 @@ void _gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
GtkStyle * _gtk_widget_get_style (GtkWidget *widget);
void _gtk_widget_set_style (GtkWidget *widget,
GtkStyle *style);
+void _gtk_widget_ensure_style (GtkWidget *widget);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]