[gtk+/wip/spinner: 2/3] stylecontext: add a private API to find a GtkStyleAnimation by name



commit c5fab68c5ccba590022e112ed5d3b27840a0dade
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Sep 10 13:14:12 2012 -0400

    stylecontext: add a private API to find a GtkStyleAnimation by name
    
    This will be useful to animate the fallback rendering of GtkSpinner.

 gtk/gtkcssanimatedvalues.c        |   38 ++++++++++++++++++------------------
 gtk/gtkcssanimatedvaluesprivate.h |    4 +++
 gtk/gtkstylecontext.c             |   15 ++++++++++++++
 gtk/gtkstylecontextprivate.h      |    4 +++
 4 files changed, 42 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtkcssanimatedvalues.c b/gtk/gtkcssanimatedvalues.c
index 2efd847..b1255e7 100644
--- a/gtk/gtkcssanimatedvalues.c
+++ b/gtk/gtkcssanimatedvalues.c
@@ -218,24 +218,6 @@ gtk_css_animated_values_start_transitions (GtkCssAnimatedValues *values,
     }
 }
 
-static GtkStyleAnimation *
-gtk_css_animated_values_find_animation (GtkCssAnimatedValues *values,
-                                        const char           *name)
-{
-  GSList *list;
-
-  for (list = values->animations; list; list = list->next)
-    {
-      if (!GTK_IS_CSS_ANIMATION (list->data))
-        continue;
-
-      if (g_str_equal (_gtk_css_animation_get_name (list->data), name))
-        return list->data;
-    }
-
-  return NULL;
-}
-
 static void
 gtk_css_animated_values_start_css_animations (GtkCssAnimatedValues *values,
                                               gint64                timestamp,
@@ -269,7 +251,7 @@ gtk_css_animated_values_start_css_animations (GtkCssAnimatedValues *values,
       if (g_ascii_strcasecmp (name, "none") == 0)
         continue;
 
-      animation = gtk_css_animated_values_find_animation (values, name);
+      animation = _gtk_css_animated_values_find_animation (values, name);
       if (animation)
         {
           g_print ("animation exists already!\n");
@@ -307,6 +289,24 @@ gtk_css_animated_values_start_animations (GtkCssAnimatedValues *values,
   gtk_css_animated_values_start_css_animations (values, timestamp, context);
 }
 
+GtkStyleAnimation *
+_gtk_css_animated_values_find_animation (GtkCssAnimatedValues *values,
+                                         const char           *name)
+{
+  GSList *list;
+
+  for (list = values->animations; list; list = list->next)
+    {
+      if (!GTK_IS_CSS_ANIMATION (list->data))
+        continue;
+
+      if (g_str_equal (_gtk_css_animation_get_name (list->data), name))
+        return list->data;
+    }
+
+  return NULL;
+}
+
 GtkCssComputedValues *
 _gtk_css_animated_values_new (GtkCssComputedValues *computed,
                               GtkCssComputedValues *source,
diff --git a/gtk/gtkcssanimatedvaluesprivate.h b/gtk/gtkcssanimatedvaluesprivate.h
index 1877d3b..6365101 100644
--- a/gtk/gtkcssanimatedvaluesprivate.h
+++ b/gtk/gtkcssanimatedvaluesprivate.h
@@ -21,6 +21,7 @@
 #define __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__
 
 #include "gtk/gtkcsscomputedvaluesprivate.h"
+#include "gtk/gtkstyleanimationprivate.h"
 
 G_BEGIN_DECLS
 
@@ -59,6 +60,9 @@ GtkBitmask *            _gtk_css_animated_values_advance              (GtkCssAni
                                                                        gint64                    timestamp) G_GNUC_WARN_UNUSED_RESULT;
 gboolean                _gtk_css_animated_values_is_finished          (GtkCssAnimatedValues     *values);
 
+GtkStyleAnimation *     _gtk_css_animated_values_find_animation       (GtkCssAnimatedValues     *values,
+                                                                       const char               *name);
+
 
 G_END_DECLS
 
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 174650c..e91e4ea 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -3038,6 +3038,21 @@ gtk_style_context_should_animate (GtkStyleContext *context)
   return animate;
 }
 
+GtkStyleAnimation *
+_gtk_style_context_find_animation (GtkStyleContext *context,
+                                   const gchar     *name)
+{
+  StyleData *style_data;
+
+  if (!gtk_style_context_is_animating (context) ||
+      !gtk_style_context_should_animate (context))
+    return NULL;
+
+  style_data = style_data_lookup (context);
+  return _gtk_css_animated_values_find_animation (GTK_CSS_ANIMATED_VALUES (style_data->store),
+                                                  name);
+}
+
 static void
 gtk_style_context_start_animations (GtkStyleContext      *context,
                                     GtkCssComputedValues *previous,
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index e099478..e20e7cc 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -19,6 +19,7 @@
 #define __GTK_STYLE_CONTEXT_PRIVATE_H__
 
 #include "gtkstylecontext.h"
+#include "gtkstyleanimationprivate.h"
 #include "gtkstyleproviderprivate.h"
 #include "gtksymboliccolor.h"
 #include "gtkbitmaskprivate.h"
@@ -62,6 +63,9 @@ GtkStyleProviderPrivate *
                _gtk_style_context_get_style_provider         (GtkStyleContext    *context);
 
 void           _gtk_style_context_stop_animations            (GtkStyleContext    *context);
+GtkStyleAnimation *
+               _gtk_style_context_find_animation             (GtkStyleContext    *context,
+                                                              const gchar        *name);
 
 G_END_DECLS
 



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