[gtk+/gtk-style-context: 243/251] GtkCssProvider: Transform custom colors to a @define-color rule.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 243/251] GtkCssProvider: Transform custom colors to a @define-color rule.
- Date: Tue, 12 Oct 2010 02:15:32 +0000 (UTC)
commit a031dbfeffdb5eceb61d99d5b0ce07d63587312e
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Oct 8 18:19:34 2010 +0200
GtkCssProvider: Transform custom colors to a @define-color rule.
Given there are other rules such as @import (which will be supported),
keep a sane namespace here, so for (re)defining a color name, in the CSS
file it will look like:
@define-color color-name #fff;
@define-color other-color mix (@color-name, #f00, 0.4);
gtk/gtkcssprovider.c | 68 ++++++++++++++++++++++++++++---------------------
1 files changed, 39 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 8236022..2dd42c0 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1905,40 +1905,50 @@ parse_rule (GtkCssProvider *css_provider,
css_provider_push_scope (css_provider, SCOPE_SELECTOR);
+ /* Handle directives */
if (scanner->token == G_TOKEN_IDENTIFIER &&
scanner->value.v_identifier[0] == '@')
{
- GtkSymbolicColor *color;
- gchar *color_name, *color_str;
+ gchar *directive;
- /* Rule is a color mapping */
- color_name = g_strdup (&scanner->value.v_identifier[1]);
- g_scanner_get_next_token (scanner);
+ directive = &scanner->value.v_identifier[1];
- if (scanner->token != ':')
- return ':';
+ if (strcmp (directive, "define-color") == 0)
+ {
+ GtkSymbolicColor *color;
+ gchar *color_name, *color_str;
- css_provider_push_scope (css_provider, SCOPE_VALUE);
- g_scanner_get_next_token (scanner);
+ /* Directive is a color mapping */
+ g_scanner_get_next_token (scanner);
- if (scanner->token != G_TOKEN_IDENTIFIER)
- return G_TOKEN_IDENTIFIER;
+ if (scanner->token != G_TOKEN_IDENTIFIER)
+ return G_TOKEN_IDENTIFIER;
- color_str = g_strstrip (scanner->value.v_identifier);
- color = symbolic_color_parse (color_str);
+ color_name = g_strdup (scanner->value.v_identifier);
+ css_provider_push_scope (css_provider, SCOPE_VALUE);
+ g_scanner_get_next_token (scanner);
- if (!color)
- return G_TOKEN_IDENTIFIER;
+ if (scanner->token != G_TOKEN_IDENTIFIER)
+ return G_TOKEN_IDENTIFIER;
- g_hash_table_insert (priv->symbolic_colors, color_name, color);
+ color_str = g_strstrip (scanner->value.v_identifier);
+ color = symbolic_color_parse (color_str);
- css_provider_pop_scope (css_provider);
- g_scanner_get_next_token (scanner);
+ if (!color)
+ return G_TOKEN_IDENTIFIER;
- if (scanner->token != ';')
- return ';';
+ g_hash_table_insert (priv->symbolic_colors, color_name, color);
- return G_TOKEN_NONE;
+ css_provider_pop_scope (css_provider);
+ g_scanner_get_next_token (scanner);
+
+ if (scanner->token != ';')
+ return ';';
+
+ return G_TOKEN_NONE;
+ }
+ else
+ return G_TOKEN_IDENTIFIER;
}
expected_token = parse_selector (css_provider, scanner, &selector);
@@ -2225,14 +2235,14 @@ gtk_css_provider_get_default (void)
if (G_UNLIKELY (!provider))
{
const gchar *str =
- "@fg_color: #000; \n"
- "@bg_color: #dcdad5; \n"
- "@text_color: #000; \n"
- "@base_color: #fff; \n"
- "@selected_bg_color: #4b6983; \n"
- "@selected_fg_color: #fff; \n"
- "@tooltip_bg_color: #eee1b3; \n"
- "@tooltip_fg_color: #000; \n"
+ "@define-color fg_color #000; \n"
+ "@define-color bg_color #dcdad5; \n"
+ "@define-color text_color #000; \n"
+ "@define-color base_color #fff; \n"
+ "@define-color selected_bg_color #4b6983; \n"
+ "@define-color selected_fg_color #fff; \n"
+ "@define-color tooltip_bg_color #eee1b3; \n"
+ "@define-color tooltip_fg_color #000; \n"
"\n"
"*,\n"
"GtkTreeView > GtkButton {\n"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]