css: Stop parsing GdkColor values

This commit is contained in:
Timm Bäder 2016-10-22 16:49:42 +02:00
parent 5cadbc7084
commit 145387add5
2 changed files with 4 additions and 77 deletions

View File

@ -170,60 +170,6 @@ rgba_value_print (const GValue *value,
}
}
static gboolean
color_value_parse (GtkCssParser *parser,
GValue *value)
{
GtkSymbolicColor *symbolic;
GdkRGBA rgba;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
symbolic = _gtk_css_symbolic_value_new (parser);
if (symbolic == NULL)
return FALSE;
if (gtk_symbolic_color_resolve (symbolic, &rgba))
{
GdkColor color;
color.red = rgba.red * 65535. + 0.5;
color.green = rgba.green * 65535. + 0.5;
color.blue = rgba.blue * 65535. + 0.5;
g_value_set_boxed (value, &color);
gtk_symbolic_color_unref (symbolic);
}
else
{
g_value_unset (value);
g_value_init (value, GTK_TYPE_SYMBOLIC_COLOR);
g_value_take_boxed (value, symbolic);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
return TRUE;
}
static void
color_value_print (const GValue *value,
GString *string)
{
const GdkColor *color = g_value_get_boxed (value);
if (color == NULL)
g_string_append (string, "none");
else
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
char *s = gdk_color_to_string (color);
G_GNUC_END_IGNORE_DEPRECATIONS
g_string_append (string, s);
g_free (s);
}
}
static gboolean
symbolic_color_value_parse (GtkCssParser *parser,
GValue *value)
@ -802,10 +748,6 @@ gtk_css_style_funcs_init (void)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
register_conversion_function (GDK_TYPE_COLOR,
color_value_parse,
color_value_print);
register_conversion_function (GTK_TYPE_SYMBOLIC_COLOR,
symbolic_color_value_parse,
symbolic_color_value_print);

View File

@ -1410,7 +1410,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
/* Resolve symbolic colors to GdkColor/GdkRGBA */
/* Resolve symbolic colors to GdkRGBA */
if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR)
{
GtkSymbolicColor *color;
@ -1420,26 +1420,11 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
g_value_unset (&pcache->value);
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
g_value_init (&pcache->value, GDK_TYPE_RGBA);
else
g_value_init (&pcache->value, GDK_TYPE_COLOR);
g_assert (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA);
g_value_init (&pcache->value, GDK_TYPE_RGBA);
if (_gtk_style_context_resolve_color (context, _gtk_symbolic_color_get_css_value (color), &rgba))
{
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
g_value_set_boxed (&pcache->value, &rgba);
else
{
GdkColor rgb;
rgb.red = rgba.red * 65535. + 0.5;
rgb.green = rgba.green * 65535. + 0.5;
rgb.blue = rgba.blue * 65535. + 0.5;
g_value_set_boxed (&pcache->value, &rgb);
}
}
g_value_set_boxed (&pcache->value, &rgba);
else
g_param_value_set_default (pspec, &pcache->value);