Add an auxiliary ident parsing function

This lets us conveniently create ident values from
multiple candidates.
This commit is contained in:
Matthias Clasen 2017-09-18 10:55:36 -04:00
parent edaaefcb74
commit 6420dd934f
2 changed files with 31 additions and 0 deletions

View File

@ -203,6 +203,34 @@ _gtk_css_ident_value_try_parse (GtkCssParser *parser)
return _gtk_css_ident_value_new_take (ident);
}
GtkCssValue *
_gtk_css_ident_value_try (GtkCssParser *parser,
const char *ident,
...)
{
va_list args;
const char *name;
GtkCssValue *value = NULL;
name = ident;
va_start (args, ident);
while (name)
{
if (_gtk_css_parser_try (parser, name, TRUE))
{
value = _gtk_css_ident_value_new (name);
break;
}
ident = va_arg (args, const char *);
}
va_end (args);
return value;
}
const char *
_gtk_css_ident_value_get (const GtkCssValue *value)
{

View File

@ -29,6 +29,9 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_ident_value_new (const char *ident);
GtkCssValue * _gtk_css_ident_value_new_take (char *ident);
GtkCssValue * _gtk_css_ident_value_try_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_ident_value_try (GtkCssParser *parser,
const char *ident,
...);
const char * _gtk_css_ident_value_get (const GtkCssValue *ident);