[gtk+/wip/cssvalue: 100/137] cssstyleproperty: Add _gtk_css_style_property_is_animated()



commit 41fad5fc602e32434764af1c1712715892af5eb4
Author: Benjamin Otte <otte redhat com>
Date:   Mon Apr 2 08:53:51 2012 +0200

    cssstyleproperty: Add _gtk_css_style_property_is_animated()

 gtk/gtkcssstyleproperty.c        |   34 +++++++++++++++++++++++++++++++++-
 gtk/gtkcssstylepropertyimpl.c    |    4 +++-
 gtk/gtkcssstylepropertyprivate.h |    2 ++
 3 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 05a80f0..82d0a88 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -36,6 +36,7 @@
 
 enum {
   PROP_0,
+  PROP_ANIMATED,
   PROP_ID,
   PROP_INHERIT,
   PROP_INITIAL
@@ -65,6 +66,9 @@ gtk_css_style_property_set_property (GObject      *object,
 
   switch (prop_id)
     {
+    case PROP_ANIMATED:
+      property->animated = g_value_get_boolean (value);
+      break;
     case PROP_INHERIT:
       property->inherit = g_value_get_boolean (value);
       break;
@@ -88,6 +92,9 @@ gtk_css_style_property_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_ANIMATED:
+      g_value_set_boolean (value, property->animated);
+      break;
     case PROP_ID:
       g_value_set_boolean (value, property->id);
       break;
@@ -177,6 +184,13 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
   object_class->get_property = gtk_css_style_property_get_property;
 
   g_object_class_install_property (object_class,
+                                   PROP_ANIMATED,
+                                   g_param_spec_boolean ("animated",
+                                                         P_("Animated"),
+                                                         P_("Set if the value can be animated"),
+                                                         FALSE,
+                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
                                    PROP_ID,
                                    g_param_spec_uint ("id",
                                                       P_("ID"),
@@ -311,12 +325,30 @@ _gtk_css_style_property_lookup_by_id (guint id)
 gboolean
 _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property)
 {
-  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), 0);
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
 
   return property->inherit;
 }
 
 /**
+ * _gtk_css_style_property_is_animated:
+ * @property: the property
+ *
+ * Queries if the given @property can be is inherited. See
+ * <ulink url="http://www.w3.org/TR/css3-transitions/#animatable-css>
+ * the CSS documentation</ulink> for animatable properties.
+ *
+ * Returns: %TRUE if the property can be animated.
+ **/
+gboolean
+_gtk_css_style_property_is_animated (GtkCssStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
+
+  return property->animated;
+}
+
+/**
  * _gtk_css_style_property_get_id:
  * @property: the property
  *
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 878fd73..1f34a72 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -58,7 +58,8 @@
 /*** REGISTRATION ***/
 
 typedef enum {
-  GTK_STYLE_PROPERTY_INHERIT = (1 << 0)
+  GTK_STYLE_PROPERTY_INHERIT = (1 << 0),
+  GTK_STYLE_PROPERTY_ANIMATED = (1 << 1)
 } GtkStylePropertyFlags;
 
 static void
@@ -83,6 +84,7 @@ gtk_css_style_property_register (const char *                   name,
 
   node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
                        "value-type", value_type,
+                       "animated", (flags & GTK_STYLE_PROPERTY_ANIMATED) ? TRUE : FALSE,
                        "inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
                        "initial-value", initial_value,
                        "name", name,
diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h
index b17d2fa..f095dc1 100644
--- a/gtk/gtkcssstylepropertyprivate.h
+++ b/gtk/gtkcssstylepropertyprivate.h
@@ -58,6 +58,7 @@ struct _GtkCssStyleProperty
   GtkCssValue *initial_value;
   guint id;
   guint inherit :1;
+  guint animated :1;
 
   GtkCssStylePropertyParseFunc parse_value;
   GtkCssStylePropertyPrintFunc print_value;
@@ -82,6 +83,7 @@ guint                   _gtk_css_style_property_get_n_properties(void);
 GtkCssStyleProperty *   _gtk_css_style_property_lookup_by_id    (guint                   id);
 
 gboolean                _gtk_css_style_property_is_inherit      (GtkCssStyleProperty    *property);
+gboolean                _gtk_css_style_property_is_animated     (GtkCssStyleProperty    *property);
 guint                   _gtk_css_style_property_get_id          (GtkCssStyleProperty    *property);
 GtkCssValue  *          _gtk_css_style_property_get_initial_value
                                                                 (GtkCssStyleProperty    *property);



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