diff options
author | Benjamin Otte <otte@redhat.com> | 2012-01-10 19:02:42 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-01-11 15:48:53 +0100 |
commit | e603992ac7fb7c96ac878bc36a40c82bcaba6aeb (patch) | |
tree | 17c789ac96115c70dd722313ab9e020982f9b46e /gtk | |
parent | aa98aca45f54df4dc59bbf542be0c712b24284be (diff) | |
download | gtk+-e603992ac7fb7c96ac878bc36a40c82bcaba6aeb.tar.gz |
shorthand: Move pack funcs from base class
Also make the vfuncs take the shorthand as an argument.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcssshorthandproperty.c | 7 | ||||
-rw-r--r-- | gtk/gtkcssshorthandpropertyimpl.c | 96 | ||||
-rw-r--r-- | gtk/gtkcssshorthandpropertyprivate.h | 10 | ||||
-rw-r--r-- | gtk/gtkstylepropertyprivate.h | 9 |
4 files changed, 70 insertions, 52 deletions
diff --git a/gtk/gtkcssshorthandproperty.c b/gtk/gtkcssshorthandproperty.c index 7352788122..dbe8216cc0 100644 --- a/gtk/gtkcssshorthandproperty.c +++ b/gtk/gtkcssshorthandproperty.c @@ -68,10 +68,11 @@ _gtk_css_shorthand_property_assign (GtkStyleProperty *property, GtkStateFlags state, const GValue *value) { + GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); GParameter *parameters; guint i, n_parameters; - parameters = property->unpack_func (value, &n_parameters); + parameters = shorthand->assign (shorthand, value, &n_parameters); for (i = 0; i < n_parameters; i++) { @@ -90,7 +91,9 @@ _gtk_css_shorthand_property_query (GtkStyleProperty *property, GtkStateFlags state, GValue *value) { - property->pack_func (value, props, state); + GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); + + shorthand->query (shorthand, value, props, state); } static gboolean diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c index e1b80b95a9..95fcbd9b1f 100644 --- a/gtk/gtkcssshorthandpropertyimpl.c +++ b/gtk/gtkcssshorthandpropertyimpl.c @@ -567,8 +567,9 @@ pack_border (GValue *value, } static GParameter * -unpack_border_width (const GValue *value, - guint *n_params) +unpack_border_width (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { return unpack_border (value, n_params, "border-top-width", "border-left-width", @@ -576,9 +577,10 @@ unpack_border_width (const GValue *value, } static void -pack_border_width (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_border_width (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { pack_border (value, props, state, "border-top-width", "border-left-width", @@ -586,8 +588,9 @@ pack_border_width (GValue *value, } static GParameter * -unpack_padding (const GValue *value, - guint *n_params) +unpack_padding (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { return unpack_border (value, n_params, "padding-top", "padding-left", @@ -595,9 +598,10 @@ unpack_padding (const GValue *value, } static void -pack_padding (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_padding (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { pack_border (value, props, state, "padding-top", "padding-left", @@ -605,8 +609,9 @@ pack_padding (GValue *value, } static GParameter * -unpack_margin (const GValue *value, - guint *n_params) +unpack_margin (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { return unpack_border (value, n_params, "margin-top", "margin-left", @@ -614,9 +619,10 @@ unpack_margin (const GValue *value, } static void -pack_margin (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_margin (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { pack_border (value, props, state, "margin-top", "margin-left", @@ -624,8 +630,9 @@ pack_margin (GValue *value, } static GParameter * -unpack_border_radius (const GValue *value, - guint *n_params) +unpack_border_radius (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { GParameter *parameter = g_new0 (GParameter, 4); GtkCssBorderCornerRadius border; @@ -650,9 +657,10 @@ unpack_border_radius (const GValue *value, } static void -pack_border_radius (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_border_radius (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { GtkCssBorderCornerRadius *top_left; @@ -672,8 +680,9 @@ pack_border_radius (GValue *value, } static GParameter * -unpack_font_description (const GValue *value, - guint *n_params) +unpack_font_description (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { GParameter *parameter = g_new0 (GParameter, 5); PangoFontDescription *description; @@ -750,9 +759,10 @@ unpack_font_description (const GValue *value, } static void -pack_font_description (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_font_description (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { PangoFontDescription *description; char **families; @@ -785,8 +795,9 @@ pack_font_description (GValue *value, } static GParameter * -unpack_border_color (const GValue *value, - guint *n_params) +unpack_border_color (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { GParameter *parameter = g_new0 (GParameter, 4); GType type; @@ -828,9 +839,10 @@ unpack_border_color (const GValue *value, } static void -pack_border_color (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_border_color (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { /* NB: We are a color property, so we have to resolve to a color here. * So we just resolve to a color. We pick one and stick to it. @@ -841,8 +853,9 @@ pack_border_color (GValue *value, } static GParameter * -unpack_border_style (const GValue *value, - guint *n_params) +unpack_border_style (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { GParameter *parameter = g_new0 (GParameter, 4); GtkBorderStyle style; @@ -867,9 +880,10 @@ unpack_border_style (const GValue *value, } static void -pack_border_style (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state) +pack_border_style (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state) { /* NB: We can just resolve to a style. We pick one and stick to it. * Lesson learned: Don't query border-style shorthand, query the @@ -883,10 +897,10 @@ _gtk_css_shorthand_property_register (const char *name, GType value_type, const char **subproperties, GtkCssShorthandPropertyParseFunc parse_func, - GtkStyleUnpackFunc unpack_func, - GtkStylePackFunc pack_func) + GtkCssShorthandPropertyAssignFunc assign_func, + GtkCssShorthandPropertyQueryFunc query_func) { - GtkStyleProperty *node; + GtkCssShorthandProperty *node; node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY, "name", name, @@ -894,9 +908,9 @@ _gtk_css_shorthand_property_register (const char *name, "subproperties", subproperties, NULL); - GTK_CSS_SHORTHAND_PROPERTY (node)->parse = parse_func; - node->pack_func = pack_func; - node->unpack_func = unpack_func; + node->parse = parse_func; + node->assign = assign_func; + node->query = query_func; } void diff --git a/gtk/gtkcssshorthandpropertyprivate.h b/gtk/gtkcssshorthandpropertyprivate.h index c07d36c0b6..a4d5b2bce3 100644 --- a/gtk/gtkcssshorthandpropertyprivate.h +++ b/gtk/gtkcssshorthandpropertyprivate.h @@ -43,6 +43,14 @@ typedef gboolean (* GtkCssShorthandPropertyParseFunc) (GtkCssS GValue *values, GtkCssParser *parser, GFile *base); +typedef GParameter * (* GtkCssShorthandPropertyAssignFunc) (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params); +typedef void (* GtkCssShorthandPropertyQueryFunc) (GtkCssShorthandProperty *shorthand, + GValue *value, + GtkStyleProperties *props, + GtkStateFlags state); + struct _GtkCssShorthandProperty { GtkStyleProperty parent; @@ -50,6 +58,8 @@ struct _GtkCssShorthandProperty GPtrArray *subproperties; GtkCssShorthandPropertyParseFunc parse; + GtkCssShorthandPropertyAssignFunc assign; + GtkCssShorthandPropertyQueryFunc query; }; struct _GtkCssShorthandPropertyClass diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h index 78cef8c4b1..58aaf2abc9 100644 --- a/gtk/gtkstylepropertyprivate.h +++ b/gtk/gtkstylepropertyprivate.h @@ -39,21 +39,12 @@ typedef enum { GTK_STYLE_PROPERTY_INHERIT = (1 << 0) } GtkStylePropertyFlags; -typedef GParameter * (* GtkStyleUnpackFunc) (const GValue *value, - guint *n_params); -typedef void (* GtkStylePackFunc) (GValue *value, - GtkStyleProperties *props, - GtkStateFlags state); - struct _GtkStyleProperty { GObject parent; char *name; GType value_type; - - GtkStyleUnpackFunc unpack_func; - GtkStylePackFunc pack_func; }; struct _GtkStylePropertyClass |