Commit d584e22e authored by Benjamin Otte's avatar Benjamin Otte

win32: Add gtk_win32_theme_parse()

So all places can use this function instead of parsing things themselves.
parent 3b19db42
......@@ -70,7 +70,6 @@ gtk_css_image_win32_parse (GtkCssImage *image,
GtkCssParser *parser)
{
GtkCssImageWin32 *wimage = GTK_CSS_IMAGE_WIN32 (image);
char *class;
if (!_gtk_css_parser_try (parser, "-gtk-win32-theme-part", TRUE))
{
......@@ -85,15 +84,9 @@ gtk_css_image_win32_parse (GtkCssImage *image,
return FALSE;
}
class = _gtk_css_parser_try_name (parser, TRUE);
if (class == NULL)
{
_gtk_css_parser_error (parser,
"Expected name as first argument to '-gtk-win32-theme-part'");
return FALSE;
}
wimage->theme = gtk_win32_theme_lookup (class);
g_free (class);
wimage->theme = gtk_win32_theme_parse (parser);
if (wimage->theme == NULL)
return FALSE;
if (! _gtk_css_parser_try (parser, ",", TRUE))
{
......
......@@ -148,7 +148,6 @@ gtk_css_win32_size_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags)
{
GtkWin32Theme *theme;
char *theme_class;
GtkCssValue *result;
int id;
......@@ -158,37 +157,31 @@ gtk_css_win32_size_value_parse (GtkCssParser *parser,
return NULL;
}
theme_class = _gtk_css_parser_try_name (parser, TRUE);
if (theme_class == NULL)
{
_gtk_css_parser_error (parser, "Expected name as first argument to '-gtk-win32-size'");
return NULL;
}
theme = gtk_win32_theme_parse (parser);
if (theme == NULL)
return NULL;
if (! _gtk_css_parser_try (parser, ",", TRUE))
{
g_free (theme_class);
gtk_win32_theme_unref (theme);
_gtk_css_parser_error (parser, "Expected ','");
return NULL;
}
if (!_gtk_css_parser_try_int (parser, &id))
{
g_free (theme_class);
gtk_win32_theme_unref (theme);
_gtk_css_parser_error (parser, "Expected an integer ID");
return 0;
}
if (!_gtk_css_parser_try (parser, ")", TRUE))
{
g_free (theme_class);
gtk_win32_theme_unref (theme);
_gtk_css_parser_error (parser, "Expected ')'");
return NULL;
}
theme = gtk_win32_theme_lookup (theme_class);
g_free (theme_class);
result = gtk_css_win32_size_value_new (1.0, theme, id);
gtk_win32_theme_unref (theme);
......
......@@ -247,7 +247,7 @@ gtk_win32_theme_get_htheme (GtkWin32Theme *theme)
#endif /* G_OS_WIN32 */
GtkWin32Theme *
static GtkWin32Theme *
gtk_win32_theme_lookup (const char *classname)
{
GtkWin32Theme *theme;
......@@ -269,6 +269,25 @@ gtk_win32_theme_lookup (const char *classname)
return theme;
}
GtkWin32Theme *
gtk_win32_theme_parse (GtkCssParser *parser)
{
GtkWin32Theme *theme;
char *class_name;
class_name = _gtk_css_parser_try_name (parser, TRUE);
if (class_name == NULL)
{
_gtk_css_parser_error (parser, "Expected valid win32 theme name");
return NULL;
}
theme = gtk_win32_theme_lookup (class_name);
g_free (class_name);
return theme;
}
cairo_surface_t *
gtk_win32_theme_create_surface (GtkWin32Theme *theme,
int xp_part,
......
......@@ -28,7 +28,7 @@ typedef struct _GtkWin32Theme GtkWin32Theme;
#define GTK_WIN32_THEME_SYMBOLIC_COLOR_NAME "-gtk-win32-color"
GtkWin32Theme * gtk_win32_theme_lookup (const char *classname);
GtkWin32Theme * gtk_win32_theme_parse (GtkCssParser *parser);
GtkWin32Theme * gtk_win32_theme_ref (GtkWin32Theme *theme);
void gtk_win32_theme_unref (GtkWin32Theme *theme);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment