[gtk+/wip/cssstyle: 12/30] cssanimatedstyle: Merge two functions



commit c4f2c01670e31dde70dc51ae45c34d6b65016d86
Author: Benjamin Otte <otte redhat com>
Date:   Mon Dec 15 01:58:11 2014 +0100

    cssanimatedstyle: Merge two functions

 gtk/gtkcssanimatedstyle.c        |   47 ++++++++++++++++++-------------------
 gtk/gtkcssanimatedstyleprivate.h |   13 +++++-----
 gtk/gtkstylecontext.c            |   19 ++++++---------
 3 files changed, 37 insertions(+), 42 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index baf5be6..44e2a3f 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -119,20 +119,6 @@ gtk_css_animated_style_init (GtkCssAnimatedStyle *style)
 {
 }
 
-GtkCssStyle *
-gtk_css_animated_style_new (GtkCssStyle *style)
-{
-  GtkCssAnimatedStyle *result;
-  
-  g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
-
-  result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
-
-  result->style = g_object_ref (style);
-
-  return GTK_CSS_STYLE (result);
-}
-
 void
 gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *style,
                                            guint                id,
@@ -398,17 +384,30 @@ gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle     *style,
 
 /* PUBLIC API */
 
-void
-gtk_css_animated_style_create_animations (GtkCssAnimatedStyle     *style,
-                                          GtkCssStyle             *parent_style,
-                                          gint64                   timestamp,
-                                          GtkStyleProviderPrivate *provider,
-                                          int                      scale,
-                                          GtkCssStyle             *source)
+GtkCssStyle *
+gtk_css_animated_style_new (GtkCssStyle             *base_style,
+                            GtkCssStyle             *parent_style,
+                            gint64                   timestamp,
+                            GtkStyleProviderPrivate *provider,
+                            int                      scale,
+                            GtkCssStyle             *previous_style)
 {
-  if (source != NULL)
-    gtk_css_animated_style_create_css_transitions (style, timestamp, source);
-  gtk_css_animated_style_create_css_animations (style, parent_style, timestamp, provider, scale, source);
+  GtkCssAnimatedStyle *result;
+  
+  gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
+  gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
+  gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
+  gtk_internal_return_val_if_fail (previous_style == NULL || GTK_IS_CSS_STYLE (previous_style), NULL);
+
+  result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
+
+  result->style = g_object_ref (base_style);
+
+  if (previous_style != NULL)
+    gtk_css_animated_style_create_css_transitions (result, timestamp, previous_style);
+  gtk_css_animated_style_create_css_animations (result, parent_style, timestamp, provider, scale, 
previous_style);
+
+  return GTK_CSS_STYLE (result);
 }
 
 GtkBitmask *
diff --git a/gtk/gtkcssanimatedstyleprivate.h b/gtk/gtkcssanimatedstyleprivate.h
index 7e05ef8..e3db40c 100644
--- a/gtk/gtkcssanimatedstyleprivate.h
+++ b/gtk/gtkcssanimatedstyleprivate.h
@@ -52,7 +52,12 @@ struct _GtkCssAnimatedStyleClass
 
 GType                   gtk_css_animated_style_get_type         (void) G_GNUC_CONST;
 
-GtkCssStyle *           gtk_css_animated_style_new              (GtkCssStyle            *style);
+GtkCssStyle *           gtk_css_animated_style_new              (GtkCssStyle            *base_style,
+                                                                 GtkCssStyle            *parent_style,
+                                                                 gint64                  timestamp,
+                                                                 GtkStyleProviderPrivate *provider,
+                                                                 int                     scale,
+                                                                 GtkCssStyle            *previous_style);
 
 void                    gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle   *style,
                                                                  guint                   id,
@@ -61,12 +66,6 @@ void                    gtk_css_animated_style_set_animated_value(GtkCssAnimated
 GtkCssValue *           gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
                                                                  guint                   id);
 
-void                    gtk_css_animated_style_create_animations(GtkCssAnimatedStyle    *style,
-                                                                 GtkCssStyle            *parent_style,
-                                                                 gint64                  timestamp,
-                                                                 GtkStyleProviderPrivate*provider,
-                                                                int                     scale,
-                                                                 GtkCssStyle            *source);
 GtkBitmask *            gtk_css_animated_style_advance          (GtkCssAnimatedStyle    *style,
                                                                  gint64                  timestamp);
 void                    gtk_css_animated_style_cancel_animations(GtkCssAnimatedStyle    *style);
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index bc79821..9ed0b44 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2838,17 +2838,14 @@ _gtk_style_context_validate (GtkStyleContext  *context,
 
       style_info_set_values (info, NULL);
       values = style_values_lookup (context);
-      values = gtk_css_animated_style_new (values);
-
-      if (values != current)
-        gtk_css_animated_style_create_animations (GTK_CSS_ANIMATED_STYLE (values),
-                                                  priv->parent ? style_values_lookup (priv->parent) : NULL,
-                                                  timestamp,
-                                                  GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
-                                                  priv->scale,
-                                                  gtk_style_context_should_create_transitions (context) 
-                                                    ? current
-                                                    : NULL);
+
+      values = gtk_css_animated_style_new (values,
+                                           priv->parent ? style_values_lookup (priv->parent) : NULL,
+                                           timestamp,
+                                           GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+                                           priv->scale,
+                                           gtk_style_context_should_create_transitions (context) ? current : 
NULL);
+
       if (gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
         {
           change &= ~GTK_CSS_CHANGE_ANIMATE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]