X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkcsspositionvalue.c;h=8f09db72f2517cb11675c62614b45e2443330bcb;hb=320613c439c6c7eeb5bc64685522195e0a6adc4e;hp=6f33de73a1e2a2c7881fb1d4fd9fcc402ebd84ab;hpb=1454ba15baa2e3378c48566746de3f41da6cde95;p=~andy%2Fgtk diff --git a/gtk/gtkcsspositionvalue.c b/gtk/gtkcsspositionvalue.c index 6f33de73a..8f09db72f 100644 --- a/gtk/gtkcsspositionvalue.c +++ b/gtk/gtkcsspositionvalue.c @@ -173,8 +173,8 @@ _gtk_css_position_value_new (GtkCssValue *x, return result; } -GtkCssValue * -_gtk_css_position_value_parse (GtkCssParser *parser) +static GtkCssValue * +position_value_parse (GtkCssParser *parser, gboolean try) { static const struct { const char *name; @@ -224,7 +224,11 @@ _gtk_css_position_value_parse (GtkCssParser *parser) return NULL; } else - return NULL; + { + if (!try) + _gtk_css_parser_error (parser, "Unrecognized position value"); + return NULL; + } } for (second = 0; names[second].name != NULL; second++) @@ -242,7 +246,8 @@ _gtk_css_position_value_parse (GtkCssParser *parser) { if (missing != &y) { - _gtk_css_parser_error (parser, "Invalid combination of values"); + if (!try) + _gtk_css_parser_error (parser, "Invalid combination of values"); _gtk_css_value_unref (y); return NULL; } @@ -266,7 +271,8 @@ _gtk_css_position_value_parse (GtkCssParser *parser) if ((names[first].horizontal && !names[second].vertical) || (!names[first].horizontal && !names[second].horizontal)) { - _gtk_css_parser_error (parser, "Invalid combination of values"); + if (!try) + _gtk_css_parser_error (parser, "Invalid combination of values"); _gtk_css_value_unref (x); _gtk_css_value_unref (y); return NULL; @@ -276,6 +282,18 @@ _gtk_css_position_value_parse (GtkCssParser *parser) return _gtk_css_position_value_new (x, y); } +GtkCssValue * +_gtk_css_position_value_parse (GtkCssParser *parser) +{ + return position_value_parse (parser, FALSE); +} + +GtkCssValue * +_gtk_css_position_value_try_parse (GtkCssParser *parser) +{ + return position_value_parse (parser, TRUE); +} + double _gtk_css_position_value_get_x (const GtkCssValue *position, double one_hundred_percent)