[gtk+/composite-templates] stylecontext: Only create transitions conditionally
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates] stylecontext: Only create transitions conditionally
- Date: Sat, 6 Oct 2012 16:59:54 +0000 (UTC)
commit 823abfe62d704bf4f80fede66f7af492aad594d5
Author: Benjamin Otte <otte redhat com>
Date: Mon Sep 17 11:30:21 2012 +0200
stylecontext: Only create transitions conditionally
While regular animations should always be created, transitions should
not. This patch allows to express this by passing NULL as the values to
transition from.
It also adds a gtk_style_context_should_create_transitions() function
that returns TRUE when transitions should be created.
gtk/gtkcsscomputedvalues.c | 3 ++-
gtk/gtkstylecontext.c | 23 ++++++++++++++++++++++-
2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c
index 7ec040e..cd2f66b 100644
--- a/gtk/gtkcsscomputedvalues.c
+++ b/gtk/gtkcsscomputedvalues.c
@@ -492,7 +492,8 @@ _gtk_css_computed_values_create_animations (GtkCssComputedValues *values,
GtkCssComputedValues *source,
GtkStyleContext *context)
{
- gtk_css_computed_values_create_css_transitions (values, timestamp, source);
+ if (source != NULL)
+ gtk_css_computed_values_create_css_transitions (values, timestamp, source);
gtk_css_computed_values_create_css_animations (values, timestamp, context);
}
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index e42ac88..b06d4d8 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -3077,6 +3077,27 @@ gtk_style_context_needs_full_revalidate (GtkStyleContext *context,
return FALSE;
}
+static gboolean
+gtk_style_context_should_create_transitions (GtkStyleContext *context)
+{
+ GtkStyleContextPrivate *priv;
+ gboolean animate;
+
+ priv = context->priv;
+
+ if (priv->widget == NULL)
+ return FALSE;
+
+ if (!gtk_widget_get_mapped (priv->widget))
+ return FALSE;
+
+ g_object_get (gtk_widget_get_settings (context->priv->widget),
+ "gtk-enable-animations", &animate,
+ NULL);
+
+ return animate;
+}
+
void
_gtk_style_context_validate (GtkStyleContext *context,
gint64 timestamp,
@@ -3144,7 +3165,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
_gtk_css_computed_values_create_animations (data->store,
timestamp,
- current->store,
+ gtk_style_context_should_create_transitions (context) ? current->store : NULL,
context);
if (_gtk_css_computed_values_is_static (data->store))
change &= ~GTK_CSS_CHANGE_ANIMATE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]