GtkCssProvider: Parse alpha() symbolic colors.

The "alpha" symbolic color modifies a passed color's alpha by a factor,
the syntax would accept things like:

background-color: alpha (@bg_color, 0.8);
foreground-color: alpha (shade (@fg_color, 0.8), 0.5);
This commit is contained in:
Carlos Garnacho 2010-10-25 20:44:15 +02:00
parent ca44965f33
commit 51b742044a

View File

@ -1583,12 +1583,19 @@ symbolic_color_parse_str (const gchar *string,
*end_ptr = (gchar *) end;
}
else if (g_str_has_prefix (str, "shade"))
else if (g_str_has_prefix (str, "shade") ||
g_str_has_prefix (str, "alpha"))
{
GtkSymbolicColor *param_color;
gboolean is_shade = FALSE;
gdouble factor;
str += strlen ("shade");
is_shade = g_str_has_prefix (str, "shade");
if (is_shade)
str += strlen ("shade");
else
str += strlen ("alpha");
SKIP_SPACES (str);
@ -1629,7 +1636,11 @@ symbolic_color_parse_str (const gchar *string,
return NULL;
}
symbolic_color = gtk_symbolic_color_new_shade (param_color, factor);
if (is_shade)
symbolic_color = gtk_symbolic_color_new_shade (param_color, factor);
else
symbolic_color = gtk_symbolic_color_new_alpha (param_color, factor);
gtk_symbolic_color_unref (param_color);
(*end_ptr)++;
}