shorthand: Move pack funcs from base class
Also make the vfuncs take the shorthand as an argument.
This commit is contained in:
@ -68,10 +68,11 @@ _gtk_css_shorthand_property_assign (GtkStyleProperty *property,
|
|||||||
GtkStateFlags state,
|
GtkStateFlags state,
|
||||||
const GValue *value)
|
const GValue *value)
|
||||||
{
|
{
|
||||||
|
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
|
||||||
GParameter *parameters;
|
GParameter *parameters;
|
||||||
guint i, n_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++)
|
for (i = 0; i < n_parameters; i++)
|
||||||
{
|
{
|
||||||
@ -90,7 +91,9 @@ _gtk_css_shorthand_property_query (GtkStyleProperty *property,
|
|||||||
GtkStateFlags state,
|
GtkStateFlags state,
|
||||||
GValue *value)
|
GValue *value)
|
||||||
{
|
{
|
||||||
property->pack_func (value, props, state);
|
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
|
||||||
|
|
||||||
|
shorthand->query (shorthand, value, props, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|||||||
@ -567,8 +567,9 @@ pack_border (GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GParameter *
|
static GParameter *
|
||||||
unpack_border_width (const GValue *value,
|
unpack_border_width (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
return unpack_border (value, n_params,
|
return unpack_border (value, n_params,
|
||||||
"border-top-width", "border-left-width",
|
"border-top-width", "border-left-width",
|
||||||
@ -576,9 +577,10 @@ unpack_border_width (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_border_width (GValue *value,
|
pack_border_width (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
pack_border (value, props, state,
|
pack_border (value, props, state,
|
||||||
"border-top-width", "border-left-width",
|
"border-top-width", "border-left-width",
|
||||||
@ -586,8 +588,9 @@ pack_border_width (GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GParameter *
|
static GParameter *
|
||||||
unpack_padding (const GValue *value,
|
unpack_padding (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
return unpack_border (value, n_params,
|
return unpack_border (value, n_params,
|
||||||
"padding-top", "padding-left",
|
"padding-top", "padding-left",
|
||||||
@ -595,9 +598,10 @@ unpack_padding (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_padding (GValue *value,
|
pack_padding (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
pack_border (value, props, state,
|
pack_border (value, props, state,
|
||||||
"padding-top", "padding-left",
|
"padding-top", "padding-left",
|
||||||
@ -605,8 +609,9 @@ pack_padding (GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GParameter *
|
static GParameter *
|
||||||
unpack_margin (const GValue *value,
|
unpack_margin (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
return unpack_border (value, n_params,
|
return unpack_border (value, n_params,
|
||||||
"margin-top", "margin-left",
|
"margin-top", "margin-left",
|
||||||
@ -614,9 +619,10 @@ unpack_margin (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_margin (GValue *value,
|
pack_margin (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
pack_border (value, props, state,
|
pack_border (value, props, state,
|
||||||
"margin-top", "margin-left",
|
"margin-top", "margin-left",
|
||||||
@ -624,8 +630,9 @@ pack_margin (GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GParameter *
|
static GParameter *
|
||||||
unpack_border_radius (const GValue *value,
|
unpack_border_radius (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
GParameter *parameter = g_new0 (GParameter, 4);
|
GParameter *parameter = g_new0 (GParameter, 4);
|
||||||
GtkCssBorderCornerRadius border;
|
GtkCssBorderCornerRadius border;
|
||||||
@ -650,9 +657,10 @@ unpack_border_radius (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_border_radius (GValue *value,
|
pack_border_radius (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
GtkCssBorderCornerRadius *top_left;
|
GtkCssBorderCornerRadius *top_left;
|
||||||
|
|
||||||
@ -672,8 +680,9 @@ pack_border_radius (GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GParameter *
|
static GParameter *
|
||||||
unpack_font_description (const GValue *value,
|
unpack_font_description (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
GParameter *parameter = g_new0 (GParameter, 5);
|
GParameter *parameter = g_new0 (GParameter, 5);
|
||||||
PangoFontDescription *description;
|
PangoFontDescription *description;
|
||||||
@ -750,9 +759,10 @@ unpack_font_description (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_font_description (GValue *value,
|
pack_font_description (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
PangoFontDescription *description;
|
PangoFontDescription *description;
|
||||||
char **families;
|
char **families;
|
||||||
@ -785,8 +795,9 @@ pack_font_description (GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GParameter *
|
static GParameter *
|
||||||
unpack_border_color (const GValue *value,
|
unpack_border_color (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
GParameter *parameter = g_new0 (GParameter, 4);
|
GParameter *parameter = g_new0 (GParameter, 4);
|
||||||
GType type;
|
GType type;
|
||||||
@ -828,9 +839,10 @@ unpack_border_color (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_border_color (GValue *value,
|
pack_border_color (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
/* NB: We are a color property, so we have to resolve to a color here.
|
/* 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.
|
* 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 *
|
static GParameter *
|
||||||
unpack_border_style (const GValue *value,
|
unpack_border_style (GtkCssShorthandProperty *shorthand,
|
||||||
guint *n_params)
|
const GValue *value,
|
||||||
|
guint *n_params)
|
||||||
{
|
{
|
||||||
GParameter *parameter = g_new0 (GParameter, 4);
|
GParameter *parameter = g_new0 (GParameter, 4);
|
||||||
GtkBorderStyle style;
|
GtkBorderStyle style;
|
||||||
@ -867,9 +880,10 @@ unpack_border_style (const GValue *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pack_border_style (GValue *value,
|
pack_border_style (GtkCssShorthandProperty *shorthand,
|
||||||
GtkStyleProperties *props,
|
GValue *value,
|
||||||
GtkStateFlags state)
|
GtkStyleProperties *props,
|
||||||
|
GtkStateFlags state)
|
||||||
{
|
{
|
||||||
/* NB: We can just resolve to a style. We pick one and stick to it.
|
/* 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
|
* 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,
|
GType value_type,
|
||||||
const char **subproperties,
|
const char **subproperties,
|
||||||
GtkCssShorthandPropertyParseFunc parse_func,
|
GtkCssShorthandPropertyParseFunc parse_func,
|
||||||
GtkStyleUnpackFunc unpack_func,
|
GtkCssShorthandPropertyAssignFunc assign_func,
|
||||||
GtkStylePackFunc pack_func)
|
GtkCssShorthandPropertyQueryFunc query_func)
|
||||||
{
|
{
|
||||||
GtkStyleProperty *node;
|
GtkCssShorthandProperty *node;
|
||||||
|
|
||||||
node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
|
node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
|
||||||
"name", name,
|
"name", name,
|
||||||
@ -894,9 +908,9 @@ _gtk_css_shorthand_property_register (const char *name,
|
|||||||
"subproperties", subproperties,
|
"subproperties", subproperties,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
GTK_CSS_SHORTHAND_PROPERTY (node)->parse = parse_func;
|
node->parse = parse_func;
|
||||||
node->pack_func = pack_func;
|
node->assign = assign_func;
|
||||||
node->unpack_func = unpack_func;
|
node->query = query_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -43,6 +43,14 @@ typedef gboolean (* GtkCssShorthandPropertyParseFunc) (GtkCssS
|
|||||||
GValue *values,
|
GValue *values,
|
||||||
GtkCssParser *parser,
|
GtkCssParser *parser,
|
||||||
GFile *base);
|
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
|
struct _GtkCssShorthandProperty
|
||||||
{
|
{
|
||||||
GtkStyleProperty parent;
|
GtkStyleProperty parent;
|
||||||
@ -50,6 +58,8 @@ struct _GtkCssShorthandProperty
|
|||||||
GPtrArray *subproperties;
|
GPtrArray *subproperties;
|
||||||
|
|
||||||
GtkCssShorthandPropertyParseFunc parse;
|
GtkCssShorthandPropertyParseFunc parse;
|
||||||
|
GtkCssShorthandPropertyAssignFunc assign;
|
||||||
|
GtkCssShorthandPropertyQueryFunc query;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkCssShorthandPropertyClass
|
struct _GtkCssShorthandPropertyClass
|
||||||
|
|||||||
@ -39,21 +39,12 @@ typedef enum {
|
|||||||
GTK_STYLE_PROPERTY_INHERIT = (1 << 0)
|
GTK_STYLE_PROPERTY_INHERIT = (1 << 0)
|
||||||
} GtkStylePropertyFlags;
|
} GtkStylePropertyFlags;
|
||||||
|
|
||||||
typedef GParameter * (* GtkStyleUnpackFunc) (const GValue *value,
|
|
||||||
guint *n_params);
|
|
||||||
typedef void (* GtkStylePackFunc) (GValue *value,
|
|
||||||
GtkStyleProperties *props,
|
|
||||||
GtkStateFlags state);
|
|
||||||
|
|
||||||
struct _GtkStyleProperty
|
struct _GtkStyleProperty
|
||||||
{
|
{
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
GType value_type;
|
GType value_type;
|
||||||
|
|
||||||
GtkStyleUnpackFunc unpack_func;
|
|
||||||
GtkStylePackFunc pack_func;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkStylePropertyClass
|
struct _GtkStylePropertyClass
|
||||||
|
|||||||
Reference in New Issue
Block a user