summaryrefslogtreecommitdiff
path: root/gtk/gtkcssshorthandpropertyimpl.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-01-15 06:26:08 +0100
committerBenjamin Otte <otte@redhat.com>2012-02-02 03:14:00 +0100
commita63ff724060c0a9ff9299d294e17b59aab46f81f (patch)
tree04a26d5c42745d63f05381da2bee291c1222c91b /gtk/gtkcssshorthandpropertyimpl.c
parent82c2dad178b918699372a1d2942753af25908438 (diff)
downloadgtk+-a63ff724060c0a9ff9299d294e17b59aab46f81f.tar.gz
css: Convert border-radius to GtkCssNumber
We can do % now, wohoo!
Diffstat (limited to 'gtk/gtkcssshorthandpropertyimpl.c')
-rw-r--r--gtk/gtkcssshorthandpropertyimpl.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index d0aa8acd0f..3f01074239 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -133,13 +133,15 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
for (i = 0; i < G_N_ELEMENTS (borders); i++)
{
- if (!_gtk_css_parser_try_double (parser, &borders[i].horizontal))
+ if (!_gtk_css_parser_has_number (parser))
break;
- if (borders[i].horizontal < 0)
- {
- _gtk_css_parser_error (parser, "Border radius values cannot be negative");
- return FALSE;
- }
+ if (!_gtk_css_parser_read_number (parser,
+ &borders[i].horizontal,
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_PARSE_PERCENT
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
}
if (i == 0)
@@ -157,13 +159,15 @@ parse_border_radius (GtkCssShorthandProperty *shorthand,
{
for (i = 0; i < G_N_ELEMENTS (borders); i++)
{
- if (!_gtk_css_parser_try_double (parser, &borders[i].vertical))
+ if (!_gtk_css_parser_has_number (parser))
break;
- if (borders[i].vertical < 0)
- {
- _gtk_css_parser_error (parser, "Border radius values cannot be negative");
- return FALSE;
- }
+ if (!_gtk_css_parser_read_number (parser,
+ &borders[i].vertical,
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_PARSE_PERCENT
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
}
if (i == 0)
@@ -638,7 +642,8 @@ unpack_border_radius (GtkCssShorthandProperty *shorthand,
GValue v = G_VALUE_INIT;
guint i;
- border.horizontal = border.vertical = g_value_get_int (value);
+ _gtk_css_number_init (&border.horizontal, g_value_get_int (value), GTK_CSS_PX);
+ border.vertical = border.horizontal;
g_value_init (&v, GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
g_value_set_boxed (&v, &border);
@@ -664,7 +669,7 @@ pack_border_radius (GtkCssShorthandProperty *shorthand,
{
top_left = g_value_get_boxed (v);
if (top_left)
- g_value_set_int (value, top_left->horizontal);
+ g_value_set_int (value, top_left->horizontal.value);
}
}