[gtk+/wip/css: 2/37] styleproperty: Introduce "specified type" and "computed type"



commit 8d70d9e2ca86ef67dbbd203a57811d73b26d8c43
Author: Benjamin Otte <otte redhat com>
Date:   Sat Jan 14 03:22:59 2012 +0100

    styleproperty: Introduce "specified type" and "computed type"
    
    Make the types explicit. This way, we can actually do useful stuff with
    them (like sanity checks, d'oh).

 gtk/gtkcsscustomproperty.c       |    2 +
 gtk/gtkcssstyleproperty.c        |   65 ++++++++++++++
 gtk/gtkcssstylepropertyimpl.c    |  172 ++++++++++++++++++++++++++++++--------
 gtk/gtkcssstylepropertyprivate.h |    3 +
 4 files changed, 208 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkcsscustomproperty.c b/gtk/gtkcsscustomproperty.c
index de7238c..266544b 100644
--- a/gtk/gtkcsscustomproperty.c
+++ b/gtk/gtkcsscustomproperty.c
@@ -162,6 +162,7 @@ gtk_theming_engine_register_property (const gchar            *name_space,
   node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
                        "initial-value", &initial,
                        "name", name,
+                       "computed-type", pspec->value_type,
                        "value-type", pspec->value_type,
                        NULL);
   node->pspec = pspec;
@@ -197,6 +198,7 @@ gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
   node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
                        "initial-value", &initial,
                        "name", pspec->name,
+                       "computed-type", pspec->value_type,
                        "value-type", pspec->value_type,
                        NULL);
   node->pspec = pspec;
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 2fb28d9..9468038 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -34,6 +34,8 @@
 enum {
   PROP_0,
   PROP_ID,
+  PROP_SPECIFIED_TYPE,
+  PROP_COMPUTED_TYPE,
   PROP_INHERIT,
   PROP_INITIAL
 };
@@ -72,6 +74,10 @@ gtk_css_style_property_set_property (GObject      *object,
       g_value_init (&property->initial_value, G_VALUE_TYPE (initial));
       g_value_copy (initial, &property->initial_value);
       break;
+    case PROP_COMPUTED_TYPE:
+      property->computed_type = g_value_get_gtype (value);
+      g_assert (property->computed_type != G_TYPE_NONE);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -88,6 +94,12 @@ gtk_css_style_property_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_SPECIFIED_TYPE:
+      g_value_set_gtype (value, G_VALUE_TYPE (&property->initial_value));
+      break;
+    case PROP_COMPUTED_TYPE:
+      g_value_set_gtype (value, property->computed_type);
+      break;
     case PROP_ID:
       g_value_set_boolean (value, property->id);
       break;
@@ -217,6 +229,20 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
                                                       0, G_MAXUINT, 0,
                                                       G_PARAM_READABLE));
   g_object_class_install_property (object_class,
+                                   PROP_SPECIFIED_TYPE,
+                                   g_param_spec_gtype ("specified-type",
+                                                       P_("Specified type"),
+                                                       P_("The type of values after parsing"),
+                                                       G_TYPE_NONE,
+                                                       G_PARAM_READABLE));
+  g_object_class_install_property (object_class,
+                                   PROP_COMPUTED_TYPE,
+                                   g_param_spec_gtype ("computed-type",
+                                                       P_("Computed type"),
+                                                       P_("The type of values after style lookup"),
+                                                       G_TYPE_NONE,
+                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
                                    PROP_INHERIT,
                                    g_param_spec_boolean ("inherit",
                                                          P_("Inherit"),
@@ -378,6 +404,45 @@ _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
 }
 
 /**
+ * _gtk_css_style_property_get_computed_type:
+ * @property: the property to query
+ *
+ * Gets the #GType used for values for this property after a CSS lookup has
+ * happened. _gtk_css_style_property_compute_value() will convert values to
+ * this type.
+ *
+ * Returns: the #GType used for computed values.
+ **/
+GType
+_gtk_css_style_property_get_computed_type (GtkCssStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), G_TYPE_NONE);
+
+  return property->computed_type;
+}
+
+/**
+ * _gtk_css_style_property_get_specified_type:
+ * @property: the property to query
+ *
+ * Gets the #GType used for values for this property after CSS parsing if
+ * the value is not a special keyword. _gtk_css_style_property_compute_value()
+ * will convert values of this type to the computed type.
+ *
+ * The initial value returned by _gtk_css_style_property_get_initial_value()
+ * will be of this type.
+ *
+ * Returns: the #GType used for specified values.
+ **/
+GType
+_gtk_css_style_property_get_specified_type (GtkCssStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), G_TYPE_NONE);
+
+  return G_VALUE_TYPE (&property->initial_value);
+}
+
+/**
  * _gtk_css_style_property_compute_value:
  * @property: the property
  * @computed: (out): an uninitialized value to be filled with the result
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index f4b95fb..24e3d8e 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -103,6 +103,7 @@ restart:
 
 static void
 _gtk_style_property_register (const char *                   name,
+                              GType                          computed_type,
                               GType                          value_type,
                               GtkStylePropertyFlags          flags,
                               GtkCssStylePropertyParseFunc   parse_value,
@@ -113,10 +114,11 @@ _gtk_style_property_register (const char *                   name,
   GtkCssStyleProperty *node;
 
   node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
+                       "value-type", value_type,
+                       "computed-type", computed_type,
                        "inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
                        "initial-value", initial_value,
                        "name", name,
-                       "value-type", value_type,
                        NULL);
   
   if (parse_value)
@@ -129,6 +131,8 @@ _gtk_style_property_register (const char *                   name,
 
 static void
 gtk_style_property_register (const char *                   name,
+                             GType                          specified_type,
+                             GType                          computed_type,
                              GType                          value_type,
                              GtkStylePropertyFlags          flags,
                              GtkCssStylePropertyParseFunc   parse_value,
@@ -141,7 +145,7 @@ gtk_style_property_register (const char *                   name,
   va_list args;
 
   va_start (args, compute_value);
-  G_VALUE_COLLECT_INIT (&initial_value, value_type,
+  G_VALUE_COLLECT_INIT (&initial_value, specified_type,
                         args, 0, &error);
   if (error)
     {
@@ -153,6 +157,7 @@ gtk_style_property_register (const char *                   name,
   va_end (args);
 
   _gtk_style_property_register (name,
+                                computed_type,
                                 value_type,
                                 flags,
                                 parse_value,
@@ -538,18 +543,22 @@ background_repeat_value_print (GtkCssStyleProperty *property,
 
 /*** REGISTRATION ***/
 
-#define rgba_init(rgba, r, g, b, a) G_STMT_START{ \
-  (rgba)->red = (r); \
-  (rgba)->green = (g); \
-  (rgba)->blue = (b); \
-  (rgba)->alpha = (a); \
-}G_STMT_END
+static GtkSymbolicColor *
+gtk_symbolic_color_new_rgba (double red,
+                             double green,
+                             double blue,
+                             double alpha)
+{
+  GdkRGBA rgba = { red, green, blue, alpha };
+
+  return gtk_symbolic_color_new_literal (&rgba);
+}
+
 void
 _gtk_css_style_property_init_properties (void)
 {
-  GValue value = { 0, };
   char *default_font_family[] = { "Sans", NULL };
-  GdkRGBA rgba;
+  GtkSymbolicColor *symbolic;
   GtkCssBorderCornerRadius no_corner_radius = { 0, };
   GtkBorder border_of_ones = { 1, 1, 1, 1 };
   GtkCssBorderImageRepeat border_image_repeat = { GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH };
@@ -558,16 +567,21 @@ _gtk_css_style_property_init_properties (void)
    * so that when computing values later they are
    * done first. That way, 'currentColor' and font
    * sizes in em can be looked up properly */
-  rgba_init (&rgba, 1, 1, 1, 1);
+  symbolic = gtk_symbolic_color_new_rgba (1, 1, 1, 1);
   gtk_style_property_register            ("color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &rgba);
+                                          symbolic);
+  gtk_symbolic_color_unref (symbolic);
   gtk_style_property_register            ("font-size",
                                           G_TYPE_DOUBLE,
+                                          G_TYPE_DOUBLE,
+                                          G_TYPE_DOUBLE,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
@@ -576,17 +590,22 @@ _gtk_css_style_property_init_properties (void)
 
   /* properties that aren't referenced when computing values
    * start here */
-  rgba_init (&rgba, 0, 0, 0, 0);
+  symbolic = gtk_symbolic_color_new_rgba (1, 1, 1, 1);
   gtk_style_property_register            ("background-color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &rgba);
+                                          symbolic);
+  gtk_symbolic_color_unref (symbolic);
 
   gtk_style_property_register            ("font-family",
                                           G_TYPE_STRV,
+                                          G_TYPE_STRV,
+                                          G_TYPE_STRV,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           font_family_parse,
                                           font_family_value_print,
@@ -594,6 +613,8 @@ _gtk_css_style_property_init_properties (void)
                                           default_font_family);
   gtk_style_property_register            ("font-style",
                                           PANGO_TYPE_STYLE,
+                                          PANGO_TYPE_STYLE,
+                                          PANGO_TYPE_STYLE,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
@@ -601,6 +622,8 @@ _gtk_css_style_property_init_properties (void)
                                           PANGO_STYLE_NORMAL);
   gtk_style_property_register            ("font-variant",
                                           PANGO_TYPE_VARIANT,
+                                          PANGO_TYPE_VARIANT,
+                                          PANGO_TYPE_VARIANT,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
@@ -609,6 +632,8 @@ _gtk_css_style_property_init_properties (void)
   /* xxx: need to parse this properly, ie parse the numbers */
   gtk_style_property_register            ("font-weight",
                                           PANGO_TYPE_WEIGHT,
+                                          PANGO_TYPE_WEIGHT,
+                                          PANGO_TYPE_WEIGHT,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
@@ -617,6 +642,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("text-shadow",
                                           GTK_TYPE_SHADOW,
+                                          GTK_TYPE_SHADOW,
+                                          GTK_TYPE_SHADOW,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
@@ -625,6 +652,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("icon-shadow",
                                           GTK_TYPE_SHADOW,
+                                          GTK_TYPE_SHADOW,
+                                          GTK_TYPE_SHADOW,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
@@ -633,6 +662,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("box-shadow",
                                           GTK_TYPE_SHADOW,
+                                          GTK_TYPE_SHADOW,
+                                          GTK_TYPE_SHADOW,
                                           0,
                                           NULL,
                                           NULL,
@@ -641,6 +672,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("margin-top",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -648,6 +681,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("margin-left",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -655,6 +690,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("margin-bottom",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -662,6 +699,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("margin-right",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -669,6 +708,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("padding-top",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -676,6 +717,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("padding-left",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -683,6 +726,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("padding-bottom",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -690,6 +735,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("padding-right",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -700,6 +747,8 @@ _gtk_css_style_property_init_properties (void)
    */
   gtk_style_property_register            ("border-top-style",
                                           GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
                                           0,
                                           NULL,
                                           NULL,
@@ -707,6 +756,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_BORDER_STYLE_NONE);
   gtk_style_property_register            ("border-top-width",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -714,6 +765,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("border-left-style",
                                           GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
                                           0,
                                           NULL,
                                           NULL,
@@ -721,6 +774,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_BORDER_STYLE_NONE);
   gtk_style_property_register            ("border-left-width",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -728,6 +783,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("border-bottom-style",
                                           GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
                                           0,
                                           NULL,
                                           NULL,
@@ -735,6 +792,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_BORDER_STYLE_NONE);
   gtk_style_property_register            ("border-bottom-width",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -742,6 +801,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("border-right-style",
                                           GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
                                           0,
                                           NULL,
                                           NULL,
@@ -749,6 +810,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_BORDER_STYLE_NONE);
   gtk_style_property_register            ("border-right-width",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -757,6 +820,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("border-top-left-radius",
                                           GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
@@ -764,6 +829,8 @@ _gtk_css_style_property_init_properties (void)
                                           &no_corner_radius);
   gtk_style_property_register            ("border-top-right-radius",
                                           GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
@@ -771,6 +838,8 @@ _gtk_css_style_property_init_properties (void)
                                           &no_corner_radius);
   gtk_style_property_register            ("border-bottom-right-radius",
                                           GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
@@ -778,6 +847,8 @@ _gtk_css_style_property_init_properties (void)
                                           &no_corner_radius);
   gtk_style_property_register            ("border-bottom-left-radius",
                                           GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
@@ -786,6 +857,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("outline-style",
                                           GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
+                                          GTK_TYPE_BORDER_STYLE,
                                           0,
                                           NULL,
                                           NULL,
@@ -793,6 +866,8 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_BORDER_STYLE_NONE);
   gtk_style_property_register            ("outline-width",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -800,6 +875,8 @@ _gtk_css_style_property_init_properties (void)
                                           0);
   gtk_style_property_register            ("outline-offset",
                                           G_TYPE_INT,
+                                          G_TYPE_INT,
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
@@ -808,6 +885,8 @@ _gtk_css_style_property_init_properties (void)
 
   gtk_style_property_register            ("background-clip",
                                           GTK_TYPE_CSS_AREA,
+                                          GTK_TYPE_CSS_AREA,
+                                          GTK_TYPE_CSS_AREA,
                                           0,
                                           NULL,
                                           NULL,
@@ -816,86 +895,103 @@ _gtk_css_style_property_init_properties (void)
                                         
   gtk_style_property_register            ("background-origin",
                                           GTK_TYPE_CSS_AREA,
+                                          GTK_TYPE_CSS_AREA,
+                                          GTK_TYPE_CSS_AREA,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL,
                                           GTK_CSS_AREA_PADDING_BOX);
 
-  g_value_init (&value, GTK_TYPE_SYMBOLIC_COLOR);
-  g_value_set_boxed (&value, _gtk_symbolic_color_get_current_color ());
-  _gtk_style_property_register           ("border-top-color",
+  gtk_style_property_register            ("border-top-color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &value);
-  _gtk_style_property_register           ("border-right-color",
+                                          _gtk_symbolic_color_get_current_color ());
+  gtk_style_property_register            ("border-right-color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &value);
-  _gtk_style_property_register           ("border-bottom-color",
+                                          _gtk_symbolic_color_get_current_color ());
+  gtk_style_property_register            ("border-bottom-color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &value);
-  _gtk_style_property_register           ("border-left-color",
+                                          _gtk_symbolic_color_get_current_color ());
+  gtk_style_property_register            ("border-left-color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &value);
-  _gtk_style_property_register           ("outline-color",
+                                          _gtk_symbolic_color_get_current_color ());
+  gtk_style_property_register            ("outline-color",
+                                          GTK_TYPE_SYMBOLIC_COLOR,
+                                          GDK_TYPE_RGBA,
                                           GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           color_compute,
-                                          &value);
-  g_value_unset (&value);
+                                          _gtk_symbolic_color_get_current_color ());
 
   gtk_style_property_register            ("background-repeat",
                                           GTK_TYPE_CSS_BACKGROUND_REPEAT,
+                                          GTK_TYPE_CSS_BACKGROUND_REPEAT,
+                                          GTK_TYPE_CSS_BACKGROUND_REPEAT,
                                           0,
                                           background_repeat_value_parse,
                                           background_repeat_value_print,
                                           NULL,
                                           GTK_CSS_BACKGROUND_REPEAT | (GTK_CSS_BACKGROUND_REPEAT << GTK_CSS_BACKGROUND_REPEAT_SHIFT));
-  g_value_init (&value, GTK_TYPE_CSS_IMAGE);
-  _gtk_style_property_register           ("background-image",
+  gtk_style_property_register            ("background-image",
+                                          GTK_TYPE_CSS_IMAGE,
+                                          GTK_TYPE_CSS_IMAGE,
                                           CAIRO_GOBJECT_TYPE_PATTERN,
                                           0,
                                           css_image_value_parse,
                                           css_image_value_print,
                                           css_image_value_compute,
-                                          &value);
+                                          NULL);
 
-  _gtk_style_property_register           ("border-image-source",
+  gtk_style_property_register            ("border-image-source",
+                                          GTK_TYPE_CSS_IMAGE,
+                                          GTK_TYPE_CSS_IMAGE,
                                           CAIRO_GOBJECT_TYPE_PATTERN,
                                           0,
                                           css_image_value_parse,
                                           css_image_value_print,
                                           css_image_value_compute,
-                                          &value);
-  g_value_unset (&value);
+                                          NULL);
   gtk_style_property_register            ("border-image-repeat",
                                           GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
+                                          GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
+                                          GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL,
                                           &border_image_repeat);
 
-  /* XXX: The initial vaue is wrong, it should be 100% */
+  /* XXX: The initial value is wrong, it should be 100% */
   gtk_style_property_register            ("border-image-slice",
                                           GTK_TYPE_BORDER,
+                                          GTK_TYPE_BORDER,
+                                          GTK_TYPE_BORDER,
                                           0,
                                           NULL,
                                           NULL,
@@ -903,6 +999,8 @@ _gtk_css_style_property_init_properties (void)
                                           &border_of_ones);
   gtk_style_property_register            ("border-image-width",
                                           GTK_TYPE_BORDER,
+                                          GTK_TYPE_BORDER,
+                                          GTK_TYPE_BORDER,
                                           0,
                                           NULL,
                                           NULL,
@@ -910,6 +1008,8 @@ _gtk_css_style_property_init_properties (void)
                                           NULL);
   gtk_style_property_register            ("engine",
                                           GTK_TYPE_THEMING_ENGINE,
+                                          GTK_TYPE_THEMING_ENGINE,
+                                          GTK_TYPE_THEMING_ENGINE,
                                           0,
                                           NULL,
                                           NULL,
@@ -917,6 +1017,8 @@ _gtk_css_style_property_init_properties (void)
                                           gtk_theming_engine_load (NULL));
   gtk_style_property_register            ("transition",
                                           GTK_TYPE_ANIMATION_DESCRIPTION,
+                                          GTK_TYPE_ANIMATION_DESCRIPTION,
+                                          GTK_TYPE_ANIMATION_DESCRIPTION,
                                           0,
                                           NULL,
                                           NULL,
@@ -926,6 +1028,8 @@ _gtk_css_style_property_init_properties (void)
   /* Private property holding the binding sets */
   gtk_style_property_register            ("gtk-key-bindings",
                                           G_TYPE_PTR_ARRAY,
+                                          G_TYPE_PTR_ARRAY,
+                                          G_TYPE_PTR_ARRAY,
                                           0,
                                           bindings_value_parse,
                                           bindings_value_print,
diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h
index ca86bc8..84cb1d2 100644
--- a/gtk/gtkcssstylepropertyprivate.h
+++ b/gtk/gtkcssstylepropertyprivate.h
@@ -50,6 +50,7 @@ struct _GtkCssStyleProperty
 {
   GtkStyleProperty parent;
 
+  GType computed_type;
   GValue initial_value;
   guint id;
   guint inherit :1;
@@ -77,6 +78,8 @@ gboolean                _gtk_css_style_property_is_inherit      (GtkCssStyleProp
 guint                   _gtk_css_style_property_get_id          (GtkCssStyleProperty    *property);
 const GValue *          _gtk_css_style_property_get_initial_value
                                                                 (GtkCssStyleProperty    *property);
+GType                   _gtk_css_style_property_get_computed_type (GtkCssStyleProperty *property);
+GType                   _gtk_css_style_property_get_specified_type (GtkCssStyleProperty *property);
 
 void                    _gtk_css_style_property_compute_value   (GtkCssStyleProperty    *property,
                                                                  GValue                 *computed,



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