[gtk+/wip/css: 88/163] styleproperty: Stop using pspecs



commit 391b7003fec7c8bdd575cd682d7bf245973daddb
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jan 2 11:54:13 2012 +0100

    styleproperty: Stop using pspecs
    
    The pspec type is wrong most of the time anyway.

 gtk/gtkcssstylepropertyimpl.c |  276 ++++++++++++++---------------------------
 1 files changed, 93 insertions(+), 183 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 30ce05b..0c3b22d 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -45,7 +45,8 @@
 /*** REGISTRATION ***/
 
 static void
-_gtk_style_property_register (GParamSpec               *pspec,
+_gtk_style_property_register (const char *              name,
+                              GType                     value_type,
                               GtkStylePropertyFlags     flags,
                               GtkStyleParseFunc         parse_func,
                               GtkStylePrintFunc         print_func,
@@ -56,17 +57,16 @@ _gtk_style_property_register (GParamSpec               *pspec,
   node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
                        "inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
                        "initial-value", initial_value,
-                       "name", pspec->name,
-                       "value-type", pspec->value_type,
+                       "name", name,
+                       "value-type", value_type,
                        NULL);
-  g_assert (node->value_type == pspec->value_type);
-  GTK_CSS_STYLE_PROPERTY (node)->pspec = pspec;
   node->parse_func = parse_func;
   node->print_func = print_func;
 }
 
 static void
-gtk_style_property_register (GParamSpec               *pspec,
+gtk_style_property_register (const char *              name,
+                             GType                     value_type,
                              GtkStylePropertyFlags     flags,
                              GtkStyleParseFunc         parse_func,
                              GtkStylePrintFunc         print_func,
@@ -77,18 +77,18 @@ gtk_style_property_register (GParamSpec               *pspec,
   va_list args;
 
   va_start (args, print_func);
-  G_VALUE_COLLECT_INIT (&initial_value, pspec->value_type,
+  G_VALUE_COLLECT_INIT (&initial_value, value_type,
                         args, 0, &error);
   if (error)
     {
-      g_error ("property `%s' initial value is broken: %s", pspec->name, error);
+      g_error ("property `%s' initial value is broken: %s", name, error);
       g_value_unset (&initial_value);
       return;
     }
 
   va_end (args);
 
-  _gtk_style_property_register (pspec, flags, parse_func, print_func, &initial_value);
+  _gtk_style_property_register (name, value_type, flags, parse_func, print_func, &initial_value);
 
   g_value_unset (&initial_value);
 }
@@ -343,250 +343,186 @@ _gtk_css_style_property_init_properties (void)
    * so make sure we're sanely inited to avoid infloops */
 
   rgba_init (&rgba, 1, 1, 1, 1);
-  gtk_style_property_register            (g_param_spec_boxed ("color",
-                                          "Foreground color",
-                                          "Foreground color",
-                                          GDK_TYPE_RGBA, 0),
+  gtk_style_property_register            ("color",
+                                          GDK_TYPE_RGBA,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           &rgba);
   rgba_init (&rgba, 0, 0, 0, 0);
-  gtk_style_property_register            (g_param_spec_boxed ("background-color",
-                                          "Background color",
-                                          "Background color",
-                                          GDK_TYPE_RGBA, 0),
+  gtk_style_property_register            ("background-color",
+                                          GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           &rgba);
 
-  gtk_style_property_register            (g_param_spec_boxed ("font-family",
-                                                              "Font family",
-                                                              "Font family",
-                                                              G_TYPE_STRV, 0),
+  gtk_style_property_register            ("font-family",
+                                          G_TYPE_STRV,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           font_family_parse,
                                           font_family_value_print,
                                           default_font_family);
-  gtk_style_property_register            (g_param_spec_enum ("font-style",
-                                                             "Font style",
-                                                             "Font style",
-                                                             PANGO_TYPE_STYLE,
-                                                             PANGO_STYLE_NORMAL, 0),
+  gtk_style_property_register            ("font-style",
+                                          PANGO_TYPE_STYLE,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           PANGO_STYLE_NORMAL);
-  gtk_style_property_register            (g_param_spec_enum ("font-variant",
-                                                             "Font variant",
-                                                             "Font variant",
-                                                             PANGO_TYPE_VARIANT,
-                                                             PANGO_VARIANT_NORMAL, 0),
+  gtk_style_property_register            ("font-variant",
+                                          PANGO_TYPE_VARIANT,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           PANGO_VARIANT_NORMAL);
   /* xxx: need to parse this properly, ie parse the numbers */
-  gtk_style_property_register            (g_param_spec_enum ("font-weight",
-                                                             "Font weight",
-                                                             "Font weight",
-                                                             PANGO_TYPE_WEIGHT,
-                                                             PANGO_WEIGHT_NORMAL, 0),
+  gtk_style_property_register            ("font-weight",
+                                          PANGO_TYPE_WEIGHT,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           PANGO_WEIGHT_NORMAL);
-  gtk_style_property_register            (g_param_spec_double ("font-size",
-                                                               "Font size",
-                                                               "Font size",
-                                                               0, G_MAXDOUBLE, 0, 0),
+  gtk_style_property_register            ("font-size",
+                                          G_TYPE_DOUBLE,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           10.0);
 
-  gtk_style_property_register            (g_param_spec_boxed ("text-shadow",
-                                                              "Text shadow",
-                                                              "Text shadow",
-                                                              GTK_TYPE_SHADOW, 0),
+  gtk_style_property_register            ("text-shadow",
+                                          GTK_TYPE_SHADOW,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           NULL);
 
-  gtk_style_property_register            (g_param_spec_boxed ("icon-shadow",
-                                                              "Icon shadow",
-                                                              "Icon shadow",
-                                                              GTK_TYPE_SHADOW, 0),
+  gtk_style_property_register            ("icon-shadow",
+                                          GTK_TYPE_SHADOW,
                                           GTK_STYLE_PROPERTY_INHERIT,
                                           NULL,
                                           NULL,
                                           NULL);
 
-  gtk_style_property_register            (g_param_spec_boxed ("box-shadow",
-                                                              "Box shadow",
-                                                              "Box shadow",
-                                                              GTK_TYPE_SHADOW, 0),
+  gtk_style_property_register            ("box-shadow",
+                                          GTK_TYPE_SHADOW,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL);
 
-  gtk_style_property_register            (g_param_spec_int ("margin-top",
-                                                            "margin top",
-                                                            "Margin at top",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("margin-top",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("margin-left",
-                                                            "margin left",
-                                                            "Margin at left",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("margin-left",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("margin-bottom",
-                                                            "margin bottom",
-                                                            "Margin at bottom",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("margin-bottom",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("margin-right",
-                                                            "margin right",
-                                                            "Margin at right",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("margin-right",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("padding-top",
-                                                            "padding top",
-                                                            "Padding at top",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("padding-top",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("padding-left",
-                                                            "padding left",
-                                                            "Padding at left",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("padding-left",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("padding-bottom",
-                                                            "padding bottom",
-                                                            "Padding at bottom",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("padding-bottom",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("padding-right",
-                                                            "padding right",
-                                                            "Padding at right",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("padding-right",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("border-top-width",
-                                                            "border top width",
-                                                            "Border width at top",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("border-top-width",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("border-left-width",
-                                                            "border left width",
-                                                            "Border width at left",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("border-left-width",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("border-bottom-width",
-                                                            "border bottom width",
-                                                            "Border width at bottom",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("border-bottom-width",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
-  gtk_style_property_register            (g_param_spec_int ("border-right-width",
-                                                            "border right width",
-                                                            "Border width at right",
-                                                            0, G_MAXINT, 0, 0),
+  gtk_style_property_register            ("border-right-width",
+                                          G_TYPE_INT,
                                           0,
                                           NULL,
                                           NULL,
                                           0);
 
-  gtk_style_property_register            (g_param_spec_boxed ("border-top-left-radius",
-                                                              "Border top left radius",
-                                                              "Border radius of top left corner, in pixels",
-                                                              GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
+  gtk_style_property_register            ("border-top-left-radius",
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
                                           &no_corner_radius);
-  gtk_style_property_register            (g_param_spec_boxed ("border-top-right-radius",
-                                                              "Border top right radius",
-                                                              "Border radius of top right corner, in pixels",
-                                                              GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
+  gtk_style_property_register            ("border-top-right-radius",
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
                                           &no_corner_radius);
-  gtk_style_property_register            (g_param_spec_boxed ("border-bottom-right-radius",
-                                                              "Border bottom right radius",
-                                                              "Border radius of bottom right corner, in pixels",
-                                                              GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
+  gtk_style_property_register            ("border-bottom-right-radius",
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
                                           &no_corner_radius);
-  gtk_style_property_register            (g_param_spec_boxed ("border-bottom-left-radius",
-                                                              "Border bottom left radius",
-                                                              "Border radius of bottom left corner, in pixels",
-                                                              GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
+  gtk_style_property_register            ("border-bottom-left-radius",
+                                          GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
                                           0,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
                                           &no_corner_radius);
 
-  gtk_style_property_register            (g_param_spec_enum ("border-style",
-                                                             "Border style",
-                                                             "Border style",
-                                                             GTK_TYPE_BORDER_STYLE,
-                                                             GTK_BORDER_STYLE_NONE, 0),
+  gtk_style_property_register            ("border-style",
+                                          GTK_TYPE_BORDER_STYLE,
                                           0,
                                           NULL,
                                           NULL,
                                           GTK_BORDER_STYLE_NONE);
-  gtk_style_property_register            (g_param_spec_enum ("background-clip",
-                                                             "Background clip",
-                                                             "Background clip",
-                                                             GTK_TYPE_CSS_AREA,
-                                                             GTK_CSS_AREA_BORDER_BOX, 0),
+  gtk_style_property_register            ("background-clip",
+                                          GTK_TYPE_CSS_AREA,
                                           0,
                                           NULL,
                                           NULL,
                                           GTK_CSS_AREA_BORDER_BOX);
                                         
-  gtk_style_property_register            (g_param_spec_enum ("background-origin",
-                                                             "Background origin",
-                                                             "Background origin",
-                                                             GTK_TYPE_CSS_AREA,
-                                                             GTK_CSS_AREA_PADDING_BOX, 0),
+  gtk_style_property_register            ("background-origin",
+                                          GTK_TYPE_CSS_AREA,
                                           0,
                                           NULL,
                                           NULL,
@@ -594,113 +530,87 @@ _gtk_css_style_property_init_properties (void)
 
   g_value_init (&value, GTK_TYPE_CSS_SPECIAL_VALUE);
   g_value_set_enum (&value, GTK_CSS_CURRENT_COLOR);
-  _gtk_style_property_register           (g_param_spec_boxed ("border-top-color",
-                                                              "Border top color",
-                                                              "Border top color",
-                                                              GDK_TYPE_RGBA, 0),
+  _gtk_style_property_register           ("border-top-color",
+                                          GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           &value);
-  _gtk_style_property_register           (g_param_spec_boxed ("border-right-color",
-                                                              "Border right color",
-                                                              "Border right color",
-                                                              GDK_TYPE_RGBA, 0),
+  _gtk_style_property_register           ("border-right-color",
+                                          GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           &value);
-  _gtk_style_property_register           (g_param_spec_boxed ("border-bottom-color",
-                                                              "Border bottom color",
-                                                              "Border bottom color",
-                                                              GDK_TYPE_RGBA, 0),
+  _gtk_style_property_register           ("border-bottom-color",
+                                          GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           &value);
-  _gtk_style_property_register           (g_param_spec_boxed ("border-left-color",
-                                                              "Border left color",
-                                                              "Border left color",
-                                                              GDK_TYPE_RGBA, 0),
+  _gtk_style_property_register           ("border-left-color",
+                                          GDK_TYPE_RGBA,
                                           0,
                                           NULL,
                                           NULL,
                                           &value);
   g_value_unset (&value);
 
-  gtk_style_property_register            (g_param_spec_boxed ("background-image",
-                                                              "Background Image",
-                                                              "Background Image",
-                                                              CAIRO_GOBJECT_TYPE_PATTERN, 0),
+  gtk_style_property_register            ("background-image",
+                                          CAIRO_GOBJECT_TYPE_PATTERN,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL);
-  gtk_style_property_register            (g_param_spec_boxed ("background-repeat",
-                                                              "Background repeat",
-                                                              "Background repeat",
-                                                              GTK_TYPE_CSS_BACKGROUND_REPEAT, 0),
+  gtk_style_property_register            ("background-repeat",
+                                          GTK_TYPE_CSS_BACKGROUND_REPEAT,
                                           0,
                                           NULL,
                                           NULL,
                                           &background_repeat);
 
-  gtk_style_property_register            (g_param_spec_boxed ("border-image-source",
-                                                              "Border image source",
-                                                              "Border image source",
-                                                              CAIRO_GOBJECT_TYPE_PATTERN, 0),
+  gtk_style_property_register            ("border-image-source",
+                                          CAIRO_GOBJECT_TYPE_PATTERN,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL);
-  gtk_style_property_register            (g_param_spec_boxed ("border-image-repeat",
-                                                              "Border image repeat",
-                                                              "Border image repeat",
-                                                              GTK_TYPE_CSS_BORDER_IMAGE_REPEAT, 0),
+  gtk_style_property_register            ("border-image-repeat",
+                                          GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
                                           0,
                                           NULL,
                                           NULL,
                                           &border_image_repeat);
 
   /* XXX: The initial vaue is wrong, it should be 100% */
-  gtk_style_property_register            (g_param_spec_boxed ("border-image-slice",
-                                                              "Border image slice",
-                                                              "Border image slice",
-                                                              GTK_TYPE_BORDER, 0),
+  gtk_style_property_register            ("border-image-slice",
+                                          GTK_TYPE_BORDER,
                                           0,
                                           NULL,
                                           NULL,
                                           &border_of_ones);
-  gtk_style_property_register            (g_param_spec_boxed ("border-image-width",
-                                                              "Border image width",
-                                                              "Border image width",
-                                                              GTK_TYPE_BORDER, 0),
+  gtk_style_property_register            ("border-image-width",
+                                          GTK_TYPE_BORDER,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL);
-  gtk_style_property_register            (g_param_spec_object ("engine",
-                                                               "Theming Engine",
-                                                               "Theming Engine",
-                                                               GTK_TYPE_THEMING_ENGINE, 0),
+  gtk_style_property_register            ("engine",
+                                          GTK_TYPE_THEMING_ENGINE,
                                           0,
                                           NULL,
                                           NULL,
                                           gtk_theming_engine_load (NULL));
-  gtk_style_property_register            (g_param_spec_boxed ("transition",
-                                                              "Transition animation description",
-                                                              "Transition animation description",
-                                                              GTK_TYPE_ANIMATION_DESCRIPTION, 0),
+  gtk_style_property_register            ("transition",
+                                          GTK_TYPE_ANIMATION_DESCRIPTION,
                                           0,
                                           NULL,
                                           NULL,
                                           NULL);
 
   /* Private property holding the binding sets */
-  gtk_style_property_register            (g_param_spec_boxed ("gtk-key-bindings",
-                                                              "Key bindings",
-                                                              "Key bindings",
-                                                              G_TYPE_PTR_ARRAY, 0),
+  gtk_style_property_register            ("gtk-key-bindings",
+                                          G_TYPE_PTR_ARRAY,
                                           0,
                                           bindings_value_parse,
                                           bindings_value_print,



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