Commit dc1e191d authored by Benjamin Otte's avatar Benjamin Otte

csssizevalue: Allow using the name for a win32 metric

... instead of just the ID.
parent 98216867
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "gtkcsswin32sizevalueprivate.h" #include "gtkcsswin32sizevalueprivate.h"
#include "gtkwin32drawprivate.h"
#include "gtkwin32themeprivate.h" #include "gtkwin32themeprivate.h"
typedef enum { typedef enum {
...@@ -164,7 +165,13 @@ gtk_css_value_win32_size_print (const GtkCssValue *value, ...@@ -164,7 +165,13 @@ gtk_css_value_win32_size_print (const GtkCssValue *value,
switch (value->type) switch (value->type)
{ {
case GTK_WIN32_SIZE: case GTK_WIN32_SIZE:
{
const char *name = gtk_win32_get_sys_metric_name_for_id (value->val.size.id);
if (name)
g_string_append (string, name);
else
g_string_append_printf (string, ", %d", value->val.size.id); g_string_append_printf (string, ", %d", value->val.size.id);
}
break; break;
case GTK_WIN32_PART_WIDTH: case GTK_WIN32_PART_WIDTH:
...@@ -271,7 +278,22 @@ static GtkCssValue * ...@@ -271,7 +278,22 @@ static GtkCssValue *
gtk_css_win32_size_value_parse_size (GtkCssValue *value, gtk_css_win32_size_value_parse_size (GtkCssValue *value,
GtkCssParser *parser) GtkCssParser *parser)
{ {
if (!_gtk_css_parser_try_int (parser, &value->val.size.id)) char *name;
name = _gtk_css_parser_try_ident (parser, TRUE);
if (name)
{
value->val.size.id = gtk_win32_get_sys_metric_id_for_name (name);
if (value->val.size.id == -1)
{
_gtk_css_parser_error (parser, "'%s' is not a name for a win32 metric.", name);
_gtk_css_value_unref (value);
g_free (name);
return NULL;
}
g_free (name);
}
else if (!_gtk_css_parser_try_int (parser, &value->val.size.id))
{ {
_gtk_css_value_unref (value); _gtk_css_value_unref (value);
_gtk_css_parser_error (parser, "Expected an integer ID"); _gtk_css_parser_error (parser, "Expected an integer ID");
......
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