]> Pileus Git - ~andy/gtk/commitdiff
cssstyleproperty: Add _gtk_css_style_property_is_animated()
authorBenjamin Otte <otte@redhat.com>
Mon, 2 Apr 2012 06:53:51 +0000 (08:53 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Apr 2012 06:59:17 +0000 (08:59 +0200)
gtk/gtkcssstyleproperty.c
gtk/gtkcssstylepropertyimpl.c
gtk/gtkcssstylepropertyprivate.h

index 05a80f08abdf5ed72a4d474b61b06a75ea6d7992..d03fd53bdd6d2df0ce535ff39151c362e41cace0 100644 (file)
@@ -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;
@@ -176,6 +183,13 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
   object_class->set_property = gtk_css_style_property_set_property;
   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",
@@ -311,11 +325,29 @@ _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 animated. 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
index adf1d8ce31476e6eec9ee1a14b2161d76629bbf0..5a0733c8107ecb2594e21f8a82b2bb0a7aee7c00 100644 (file)
@@ -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,
index b17d2fa27a088bbcaf56058956b2fd2a93315a4e..f095dc1280c8e877692ad4bdc584b2d2f484f358 100644 (file)
@@ -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);