mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-19 00:20:09 +00:00
win32-theme: Support -gtk-win32-size CSS value
This commit is contained in:
parent
abe6598a13
commit
bc38cf1ff8
@ -385,6 +385,17 @@ int_value_parse (GtkCssParser *parser,
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (_gtk_css_parser_begins_with (parser, '-'))
|
||||
{
|
||||
int res = _gtk_win32_theme_int_parse (parser, base, &i);
|
||||
if (res >= 0)
|
||||
{
|
||||
g_value_set_int (value, i);
|
||||
return res > 0;
|
||||
}
|
||||
/* < 0 => continue */
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &i))
|
||||
{
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
@ -589,11 +600,26 @@ border_value_parse (GtkCssParser *parser,
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (numbers); i++)
|
||||
{
|
||||
if (!_gtk_css_parser_try_uint (parser, &numbers[i]))
|
||||
break;
|
||||
if (_gtk_css_parser_begins_with (parser, '-'))
|
||||
{
|
||||
/* These are strictly speaking signed, but we want to be able to use them
|
||||
for unsigned types too, as the actual ranges of values make this safe */
|
||||
int res = _gtk_win32_theme_int_parse (parser, base, (int *)&numbers[i]);
|
||||
|
||||
/* XXX: shouldn't allow spaces here? */
|
||||
_gtk_css_parser_try (parser, "px", TRUE);
|
||||
if (res == 0) /* Parse error, report */
|
||||
return FALSE;
|
||||
|
||||
if (res < 0) /* Nothing known to expand */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_gtk_css_parser_try_uint (parser, &numbers[i]))
|
||||
break;
|
||||
|
||||
/* XXX: shouldn't allow spaces here? */
|
||||
_gtk_css_parser_try (parser, "px", TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
|
@ -365,3 +365,74 @@ _gtk_win32_theme_part_render (GtkWin32ThemePart *part,
|
||||
return cairo_pattern_create_rgb (color.red, color.green, color.blue);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_gtk_win32_theme_int_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
int *value)
|
||||
{
|
||||
char *class;
|
||||
int arg;
|
||||
|
||||
if (_gtk_css_parser_try (parser,
|
||||
"-gtk-win32-size",
|
||||
TRUE))
|
||||
{
|
||||
if (!_gtk_css_parser_try (parser, "(", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected '(' after '-gtk-win32-size'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
class = _gtk_css_parser_try_name (parser, TRUE);
|
||||
if (class == NULL)
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected name as first argument to '-gtk-win32-size'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! _gtk_css_parser_try (parser, ",", TRUE))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ','");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try_int (parser, &arg))
|
||||
{
|
||||
g_free (class);
|
||||
_gtk_css_parser_error (parser, "Expected a valid integer value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_gtk_css_parser_try (parser, ")", TRUE))
|
||||
{
|
||||
_gtk_css_parser_error (parser,
|
||||
"Expected ')'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (use_xp_theme && get_theme_sys_metric != NULL)
|
||||
{
|
||||
HTHEME theme = lookup_htheme_by_classname (class);
|
||||
|
||||
/* If theme is NULL it will just return the GetSystemMetrics value */
|
||||
*value = get_theme_sys_metric (theme, arg);
|
||||
}
|
||||
else
|
||||
*value = GetSystemMetrics (arg);
|
||||
#else
|
||||
*value = 1;
|
||||
#endif
|
||||
|
||||
g_free (class);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ int _gtk_win32_theme_part_parse (GtkCssParser *parser,
|
||||
cairo_pattern_t *_gtk_win32_theme_part_render (GtkWin32ThemePart *part,
|
||||
int width,
|
||||
int height);
|
||||
int _gtk_win32_theme_int_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
int *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user