[gtk+/wip/cssvalue: 22/137] stylecontext: Invalidate when setting classes/state/regions
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 22/137] stylecontext: Invalidate when setting classes/state/regions
- Date: Sat, 7 Apr 2012 11:09:08 +0000 (UTC)
commit 74a367df2231c56c4e6dbe02924acacb7825f386
Author: Benjamin Otte <otte redhat com>
Date: Tue Mar 20 03:35:36 2012 +0100
stylecontext: Invalidate when setting classes/state/regions
... and nobody has called style_context_save().
gtk/gtkstylecontext.c | 40 ++++++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index d7631b2..809605e 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -1015,6 +1015,32 @@ style_data_lookup (GtkStyleContext *context,
return data;
}
+/* returns TRUE if someone called gtk_style_context_save() but hasn't
+ * called gtk_style_context_restore() yet.
+ * In those situations we don't invalidate the context when somebody
+ * changes state/regions/classes.
+ */
+static gboolean
+gtk_style_context_is_saved (GtkStyleContext *context)
+{
+ return context->priv->info_stack->next != NULL;
+}
+
+static void
+gtk_style_context_queue_invalidate_internal (GtkStyleContext *context,
+ GtkCssChange change)
+{
+ GtkStyleContextPrivate *priv = context->priv;
+
+ priv->current_data = NULL;
+
+ if (!gtk_style_context_is_saved (context))
+ {
+ _gtk_style_context_queue_invalidate (context, GTK_CSS_CHANGE_STATE);
+ /* XXX: We need to invalidate siblings here somehow */
+ }
+}
+
/**
* gtk_style_context_new:
*
@@ -1404,6 +1430,8 @@ gtk_style_context_set_state (GtkStyleContext *context,
priv = context->priv;
info = priv->info_stack->data;
info->state_flags = flags;
+
+ gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_STATE);
}
/**
@@ -1826,8 +1854,7 @@ gtk_style_context_add_class (GtkStyleContext *context,
{
g_array_insert_val (info->style_classes, position, class_quark);
- /* Unset current data, as it likely changed due to the class change */
- priv->current_data = NULL;
+ gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_CLASS);
}
}
@@ -1866,8 +1893,7 @@ gtk_style_context_remove_class (GtkStyleContext *context,
{
g_array_remove_index (info->style_classes, position);
- /* Unset current data, as it likely changed due to the class change */
- priv->current_data = NULL;
+ gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_CLASS);
}
}
@@ -2071,8 +2097,7 @@ gtk_style_context_add_region (GtkStyleContext *context,
g_array_insert_val (info->regions, position, region);
- /* Unset current data, as it likely changed due to the region change */
- priv->current_data = NULL;
+ gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_REGION);
}
}
@@ -2111,8 +2136,7 @@ gtk_style_context_remove_region (GtkStyleContext *context,
{
g_array_remove_index (info->regions, position);
- /* Unset current data, as it likely changed due to the region change */
- priv->current_data = NULL;
+ gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_REGION);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]