[gtk+] styleproperties: Add an unset vfunc to style properties



commit 68ebc77a9a64b8bd92dd620b5f14e592dbcc55d2
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jul 19 11:11:12 2011 +0200

    styleproperties: Add an unset vfunc to style properties
    
    This makes unsetting work for shorthands.

 gtk/gtkstyleproperties.c      |    7 +++++++
 gtk/gtkstyleproperty.c        |   39 +++++++++++++++++++++++++++++++++------
 gtk/gtkstylepropertyprivate.h |    6 +++++-
 3 files changed, 45 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 458fcaa..24837d5 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -319,6 +319,7 @@ gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
                                 NULL,
                                 NULL,
                                 NULL,
+                                NULL,
                                 NULL);
 }
 
@@ -839,6 +840,12 @@ gtk_style_properties_unset_property (GtkStyleProperties *props,
       return;
     }
 
+  if (node->unset_func)
+    {
+      node->unset_func (props, state);
+      return;
+    }
+
   priv = props->priv;
   prop = g_hash_table_lookup (priv->properties, node);
 
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 69b493e..82e2c49 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -2394,6 +2394,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
 
   gtk_style_properties_register_property (NULL,
@@ -2412,6 +2413,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           font_family_parse,
                                           font_family_value_print,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_enum ("font-style",
                                                              "Font style",
@@ -2424,6 +2426,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_enum ("font-variant",
                                                              "Font variant",
@@ -2436,6 +2439,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   /* xxx: need to parse this properly, ie parse the numbers */
   _gtk_style_property_register           (g_param_spec_enum ("font-weight",
@@ -2449,6 +2453,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_double ("font-size",
                                                                "Font size",
@@ -2460,6 +2465,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("font",
                                                               "Font Description",
@@ -2471,6 +2477,7 @@ gtk_style_property_init (void)
                                           pack_font_description,
                                           font_description_value_parse,
                                           font_description_value_print,
+                                          NULL,
                                           NULL);
 
   _gtk_style_property_register           (g_param_spec_boxed ("text-shadow",
@@ -2483,6 +2490,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
 
   _gtk_style_property_register           (g_param_spec_boxed ("icon-shadow",
@@ -2495,6 +2503,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
 
   gtk_style_properties_register_property (NULL,
@@ -2532,6 +2541,7 @@ gtk_style_property_init (void)
                                           pack_margin,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   gtk_style_properties_register_property (NULL,
                                           g_param_spec_int ("padding-top",
@@ -2563,6 +2573,7 @@ gtk_style_property_init (void)
                                           pack_padding,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   gtk_style_properties_register_property (NULL,
                                           g_param_spec_int ("border-top-width",
@@ -2594,6 +2605,7 @@ gtk_style_property_init (void)
                                           pack_border_width,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
 
   _gtk_style_property_register           (g_param_spec_boxed ("border-top-left-radius",
@@ -2606,6 +2618,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-top-right-radius",
                                                               "Border top right radius",
@@ -2617,6 +2630,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-bottom-right-radius",
                                                               "Border bottom right radius",
@@ -2628,6 +2642,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-bottom-left-radius",
                                                               "Border bottom left radius",
@@ -2639,6 +2654,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_corner_radius_value_parse,
                                           border_corner_radius_value_print,
+                                          NULL,
                                           NULL);
   _gtk_style_property_register           (g_param_spec_int ("border-radius",
                                                             "Border radius",
@@ -2650,6 +2666,7 @@ gtk_style_property_init (void)
                                           pack_border_radius,
                                           border_radius_value_parse,
                                           border_radius_value_print,
+                                          NULL,
                                           NULL);
 
   gtk_style_properties_register_property (NULL,
@@ -2668,7 +2685,8 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_color_value_parse,
                                           NULL,
-                                          border_color_default_value);
+                                          border_color_default_value,
+                                          NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-right-color",
                                                               "Border right color",
                                                               "Border right color",
@@ -2679,7 +2697,8 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_color_value_parse,
                                           NULL,
-                                          border_color_default_value);
+                                          border_color_default_value,
+                                          NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-bottom-color",
                                                               "Border bottom color",
                                                               "Border bottom color",
@@ -2690,7 +2709,8 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_color_value_parse,
                                           NULL,
-                                          border_color_default_value);
+                                          border_color_default_value,
+                                          NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-left-color",
                                                               "Border left color",
                                                               "Border left color",
@@ -2701,7 +2721,8 @@ gtk_style_property_init (void)
                                           NULL,
                                           border_color_value_parse,
                                           NULL,
-                                          border_color_default_value);
+                                          border_color_default_value,
+                                          NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-color",
                                                               "Border color",
                                                               "Border color",
@@ -2712,6 +2733,7 @@ gtk_style_property_init (void)
                                           pack_border_color,
                                           border_color_shorthand_value_parse,
                                           NULL,
+                                          NULL,
                                           NULL);
 
   gtk_style_properties_register_property (NULL,
@@ -2744,7 +2766,8 @@ gtk_style_property_init (void)
                                           NULL,
                                           NULL,
                                           NULL,
-                                          border_image_width_default_value);
+                                          border_image_width_default_value,
+                                          NULL);
   _gtk_style_property_register           (g_param_spec_boxed ("border-image",
                                                               "Border Image",
                                                               "Border Image",
@@ -2755,6 +2778,7 @@ gtk_style_property_init (void)
                                           _gtk_border_image_pack,
                                           NULL,
                                           NULL,
+                                          NULL,
                                           NULL);
   gtk_style_properties_register_property (NULL,
                                           g_param_spec_object ("engine",
@@ -2778,6 +2802,7 @@ gtk_style_property_init (void)
                                           NULL,
                                           bindings_value_parse,
                                           bindings_value_print,
+                                          NULL,
                                           NULL);
 }
 
@@ -2797,7 +2822,8 @@ _gtk_style_property_register (GParamSpec               *pspec,
                               GtkStylePackFunc          pack_func,
                               GtkStyleParseFunc         parse_func,
                               GtkStylePrintFunc         print_func,
-                              GtkStyleDefaultValueFunc  default_value_func)
+                              GtkStyleDefaultValueFunc  default_value_func,
+                              GtkStyleUnsetFunc         unset_func)
 {
   const GtkStyleProperty *existing;
   GtkStyleProperty *node;
@@ -2823,6 +2849,7 @@ _gtk_style_property_register (GParamSpec               *pspec,
   node->parse_func = parse_func;
   node->print_func = print_func;
   node->default_value_func = default_value_func;
+  node->unset_func = unset_func;
 
   g_hash_table_insert (properties, pspec->name, node);
 }
diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h
index db87068..aef18b8 100644
--- a/gtk/gtkstylepropertyprivate.h
+++ b/gtk/gtkstylepropertyprivate.h
@@ -42,6 +42,8 @@ typedef void             (* GtkStylePrintFunc)             (const GValue
 typedef void             (* GtkStyleDefaultValueFunc)      (GtkStyleProperties     *props,
                                                             GtkStateFlags           state,
                                                             GValue                 *value);
+typedef void             (* GtkStyleUnsetFunc)             (GtkStyleProperties     *props,
+                                                            GtkStateFlags           state);
 
 
 struct _GtkStyleProperty
@@ -55,6 +57,7 @@ struct _GtkStyleProperty
   GtkStyleParseFunc         parse_func;
   GtkStylePrintFunc         print_func;
   GtkStyleDefaultValueFunc  default_value_func;
+  GtkStyleUnsetFunc         unset_func;
 };
 
 const GtkStyleProperty * _gtk_style_property_lookup        (const char             *name);
@@ -66,7 +69,8 @@ void                     _gtk_style_property_register      (GParamSpec
                                                             GtkStylePackFunc        pack_func,
                                                             GtkStyleParseFunc       parse_func,
                                                             GtkStylePrintFunc       print_func,
-                                                            GtkStyleDefaultValueFunc default_value_func);
+                                                            GtkStyleDefaultValueFunc default_value_func,
+                                                            GtkStyleUnsetFunc       unset_func);
 
 gboolean                 _gtk_style_property_is_inherit    (const GtkStyleProperty *property);
 



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