mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
css: Port margin properties to GtkCssNumber
This commit is contained in:
parent
cfebd1ec06
commit
3c4b8a676f
@ -81,10 +81,10 @@ parse_border_width (GtkCssShorthandProperty *shorthand,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_border_width_really (GtkCssShorthandProperty *shorthand,
|
||||
parse_four_numbers (GtkCssShorthandProperty *shorthand,
|
||||
GValue *values,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
GtkCssNumber numbers[4];
|
||||
guint i;
|
||||
@ -96,9 +96,7 @@ parse_border_width_really (GtkCssShorthandProperty *shorthand,
|
||||
|
||||
if (!_gtk_css_parser_read_number (parser,
|
||||
&numbers[i],
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_NUMBER_AS_PIXELS
|
||||
| GTK_CSS_PARSE_LENGTH))
|
||||
flags))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -122,6 +120,33 @@ parse_border_width_really (GtkCssShorthandProperty *shorthand,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_margin (GtkCssShorthandProperty *shorthand,
|
||||
GValue *values,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
return parse_four_numbers (shorthand,
|
||||
values,
|
||||
parser,
|
||||
GTK_CSS_NUMBER_AS_PIXELS
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_border_width_really (GtkCssShorthandProperty *shorthand,
|
||||
GValue *values,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
return parse_four_numbers (shorthand,
|
||||
values,
|
||||
parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_NUMBER_AS_PIXELS
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_border_radius (GtkCssShorthandProperty *shorthand,
|
||||
GValue *values,
|
||||
@ -892,7 +917,7 @@ _gtk_css_shorthand_property_init_properties (void)
|
||||
_gtk_css_shorthand_property_register ("margin",
|
||||
GTK_TYPE_BORDER,
|
||||
margin_subproperties,
|
||||
parse_border_width,
|
||||
parse_margin,
|
||||
unpack_border,
|
||||
pack_border);
|
||||
_gtk_css_shorthand_property_register ("padding",
|
||||
|
@ -411,6 +411,38 @@ css_image_value_compute (GtkCssStyleProperty *property,
|
||||
g_value_take_object (computed, image);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_margin (GtkCssStyleProperty *property,
|
||||
GValue *value,
|
||||
GtkCssParser *parser,
|
||||
GFile *base)
|
||||
{
|
||||
GtkCssNumber number;
|
||||
|
||||
if (!_gtk_css_parser_read_number (parser,
|
||||
&number,
|
||||
GTK_CSS_NUMBER_AS_PIXELS
|
||||
| GTK_CSS_PARSE_LENGTH))
|
||||
return FALSE;
|
||||
|
||||
g_value_set_boxed (value, &number);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
compute_margin (GtkCssStyleProperty *property,
|
||||
GValue *computed,
|
||||
GtkStyleContext *context,
|
||||
const GValue *specified)
|
||||
{
|
||||
GtkCssNumber number;
|
||||
|
||||
_gtk_css_number_compute (&number,
|
||||
g_value_get_boxed (specified),
|
||||
context);
|
||||
g_value_set_boxed (computed, &number);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_border_width (GtkCssStyleProperty *property,
|
||||
GValue *value,
|
||||
@ -745,42 +777,43 @@ _gtk_css_style_property_init_properties (void)
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
_gtk_css_number_init (&number, 0, GTK_CSS_PX);
|
||||
gtk_css_style_property_register ("margin-top",
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
G_TYPE_INT,
|
||||
0,
|
||||
parse_margin,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
compute_margin,
|
||||
&number);
|
||||
gtk_css_style_property_register ("margin-left",
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
G_TYPE_INT,
|
||||
0,
|
||||
parse_margin,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
compute_margin,
|
||||
&number);
|
||||
gtk_css_style_property_register ("margin-bottom",
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
G_TYPE_INT,
|
||||
0,
|
||||
parse_margin,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
compute_margin,
|
||||
&number);
|
||||
gtk_css_style_property_register ("margin-right",
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
GTK_TYPE_CSS_NUMBER,
|
||||
G_TYPE_INT,
|
||||
0,
|
||||
parse_margin,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
compute_margin,
|
||||
&number);
|
||||
gtk_css_style_property_register ("padding-top",
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
@ -817,7 +850,6 @@ _gtk_css_style_property_init_properties (void)
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
_gtk_css_number_init (&number, 0, GTK_CSS_PX);
|
||||
/* IMPORTANT: compute_border_width() requires that the border-width
|
||||
* properties be immeditaly followed by the border-style properties
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user