[gtk+/parser] cssprovider: Remove a bunch of commented-out code
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/parser] cssprovider: Remove a bunch of commented-out code
- Date: Sun, 15 May 2011 13:58:04 +0000 (UTC)
commit cbf499269c1042562f41a8f7fc2ea856cdcc94ef
Author: Benjamin Otte <otte redhat com>
Date: Fri May 13 16:21:20 2011 +0200
cssprovider: Remove a bunch of commented-out code
The code was only kept for reference while writing the new parser, it's
not necessary anhymore.
gtk/gtkcssprovider.c | 331 --------------------------------------------------
1 files changed, 0 insertions(+), 331 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 172993d..ff1ded4 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1742,337 +1742,6 @@ css_provider_commit (GtkCssProvider *css_provider,
}
}
-#if 0
-static GTokenType
-parse_nth_child (GtkCssProvider *css_provider,
- GScanner *scanner,
- GtkRegionFlags *flags)
-{
- ParserSymbol symbol;
-
- g_scanner_get_next_token (scanner);
-
- if (scanner->token != G_TOKEN_SYMBOL)
- return G_TOKEN_SYMBOL;
-
- symbol = GPOINTER_TO_INT (scanner->value.v_symbol);
-
- if (symbol == SYMBOL_NTH_CHILD)
- {
- g_scanner_get_next_token (scanner);
-
- if (scanner->token != G_TOKEN_LEFT_PAREN)
- return G_TOKEN_LEFT_PAREN;
-
- gtk_css_scanner_push_scope (scanner, SCOPE_NTH_CHILD);
- g_scanner_get_next_token (scanner);
-
- if (scanner->token != G_TOKEN_SYMBOL)
- return G_TOKEN_SYMBOL;
-
- symbol = GPOINTER_TO_INT (scanner->value.v_symbol);
-
- switch (symbol)
- {
- case SYMBOL_NTH_CHILD_EVEN:
- *flags = GTK_REGION_EVEN;
- break;
- case SYMBOL_NTH_CHILD_ODD:
- *flags = GTK_REGION_ODD;
- break;
- case SYMBOL_NTH_CHILD_FIRST:
- *flags = GTK_REGION_FIRST;
- break;
- case SYMBOL_NTH_CHILD_LAST:
- *flags = GTK_REGION_LAST;
- break;
- default:
- break;
- }
-
- g_scanner_get_next_token (scanner);
-
- if (scanner->token != G_TOKEN_RIGHT_PAREN)
- return G_TOKEN_RIGHT_PAREN;
-
- gtk_css_scanner_pop_scope (scanner);
- }
- else if (symbol == SYMBOL_FIRST_CHILD)
- *flags = GTK_REGION_FIRST;
- else if (symbol == SYMBOL_LAST_CHILD)
- *flags = GTK_REGION_LAST;
- else if (symbol == SYMBOL_SORTED_CHILD)
- *flags = GTK_REGION_SORTED;
- else
- {
- *flags = 0;
- return G_TOKEN_SYMBOL;
- }
-
- return G_TOKEN_NONE;
-}
-
-static GTokenType
-parse_pseudo_class (GtkCssProvider *css_provider,
- GScanner *scanner,
- SelectorPath *selector)
-{
- GtkStateType state;
-
- g_scanner_get_next_token (scanner);
-
- if (scanner->token != G_TOKEN_SYMBOL)
- return G_TOKEN_SYMBOL;
-
- state = GPOINTER_TO_INT (scanner->value.v_symbol);
-
- switch (state)
- {
- case GTK_STATE_ACTIVE:
- selector->state |= GTK_STATE_FLAG_ACTIVE;
- break;
- case GTK_STATE_PRELIGHT:
- selector->state |= GTK_STATE_FLAG_PRELIGHT;
- break;
- case GTK_STATE_SELECTED:
- selector->state |= GTK_STATE_FLAG_SELECTED;
- break;
- case GTK_STATE_INSENSITIVE:
- selector->state |= GTK_STATE_FLAG_INSENSITIVE;
- break;
- case GTK_STATE_INCONSISTENT:
- selector->state |= GTK_STATE_FLAG_INCONSISTENT;
- break;
- case GTK_STATE_FOCUSED:
- selector->state |= GTK_STATE_FLAG_FOCUSED;
- break;
- default:
- return G_TOKEN_SYMBOL;
- }
-
- return G_TOKEN_NONE;
-}
-
-/* Parses a number of concatenated classes */
-static void
-parse_classes (SelectorPath *path,
- const gchar *str)
-{
- gchar *pos;
-
- if ((pos = strchr (str, '.')) != NULL)
- {
- /* Leave the last class to the call after the loop */
- while (pos)
- {
- *pos = '\0';
- selector_path_prepend_class (path, str);
-
- str = pos + 1;
- pos = strchr (str, '.');
- }
- }
-
- selector_path_prepend_class (path, str);
-}
-
-static gboolean
-is_widget_class_name (const gchar *str)
-{
- /* Do a pretty lax check here, not all
- * widget class names contain only CamelCase
- * (gtkmm widgets don't), but at least part of
- * the name will be CamelCase, so check for
- * the first uppercase char
- */
- while (*str)
- {
- if (g_ascii_isupper (*str))
- return TRUE;
-
- str++;
- }
-
- return FALSE;
-}
-
-static GTokenType
-parse_selector (GtkCssProvider *css_provider,
- GScanner *scanner,
- SelectorPath **selector_out)
-{
- SelectorPath *path;
-
- path = selector_path_new ();
- *selector_out = path;
-
- if (scanner->token != ':' &&
- scanner->token != '#' &&
- scanner->token != '.' &&
- scanner->token != G_TOKEN_IDENTIFIER)
- return G_TOKEN_IDENTIFIER;
-
- while (scanner->token == '#' ||
- scanner->token == '.' ||
- scanner->token == G_TOKEN_IDENTIFIER)
- {
- if (scanner->token == '#' ||
- scanner->token == '.')
- {
- gboolean is_class;
- gchar *pos;
-
- is_class = (scanner->token == '.');
-
- g_scanner_get_next_token (scanner);
-
- if (scanner->token != G_TOKEN_IDENTIFIER)
- return G_TOKEN_IDENTIFIER;
-
- selector_path_prepend_glob (path);
- selector_path_prepend_combinator (path, COMBINATOR_CHILD);
-
- if (is_class)
- parse_classes (path, scanner->value.v_identifier);
- else
- {
- if ((pos = strchr (scanner->value.v_identifier, '.')) != NULL)
- *pos = '\0';
-
- selector_path_prepend_name (path, scanner->value.v_identifier);
-
- /* Parse any remaining classes */
- if (pos)
- parse_classes (path, pos + 1);
- }
- }
- else if (is_widget_class_name (scanner->value.v_identifier))
- {
- gchar *pos;
-
- if ((pos = strchr (scanner->value.v_identifier, '#')) != NULL ||
- (pos = strchr (scanner->value.v_identifier, '.')) != NULL)
- {
- gchar *type_name, *name;
- gboolean is_class;
-
- is_class = (*pos == '.');
-
- /* Widget type and name/class put together */
- name = pos + 1;
- *pos = '\0';
- type_name = scanner->value.v_identifier;
-
- selector_path_prepend_type (path, type_name);
-
- /* This is only so there is a direct relationship
- * between widget type and its name.
- */
- selector_path_prepend_combinator (path, COMBINATOR_CHILD);
-
- if (is_class)
- parse_classes (path, name);
- else
- {
- if ((pos = strchr (name, '.')) != NULL)
- *pos = '\0';
-
- selector_path_prepend_combinator (path, COMBINATOR_CHILD);
- selector_path_prepend_name (path, name);
-
- /* Parse any remaining classes */
- if (pos)
- parse_classes (path, pos + 1);
- }
- }
- else
- selector_path_prepend_type (path, scanner->value.v_identifier);
- }
- else if (_gtk_style_context_check_region_name (scanner->value.v_identifier))
- {
- GtkRegionFlags flags = 0;
- gchar *region_name;
-
- region_name = g_strdup (scanner->value.v_identifier);
-
- if (g_scanner_peek_next_token (scanner) == ':')
- {
- ParserSymbol symbol;
-
- g_scanner_get_next_token (scanner);
- gtk_css_scanner_push_scope (scanner, SCOPE_PSEUDO_CLASS);
-
- /* Check for the next token being nth-child, parse in that
- * case, and fallback into common state parsing if not.
- */
- if (g_scanner_peek_next_token (scanner) != G_TOKEN_SYMBOL)
- return G_TOKEN_SYMBOL;
-
- symbol = GPOINTER_TO_INT (scanner->next_value.v_symbol);
-
- if (symbol == SYMBOL_FIRST_CHILD ||
- symbol == SYMBOL_LAST_CHILD ||
- symbol == SYMBOL_NTH_CHILD ||
- symbol == SYMBOL_SORTED_CHILD)
- {
- GTokenType token;
-
- if ((token = parse_nth_child (css_provider, scanner, &flags)) != G_TOKEN_NONE)
- return token;
-
- gtk_css_scanner_pop_scope (scanner);
- }
- else
- {
- gtk_css_scanner_pop_scope (scanner);
- selector_path_prepend_region (path, region_name, 0);
- g_free (region_name);
- break;
- }
- }
-
- selector_path_prepend_region (path, region_name, flags);
- g_free (region_name);
- }
- else if (scanner->value.v_identifier[0] == '*')
- selector_path_prepend_glob (path);
- else
- return G_TOKEN_IDENTIFIER;
-
- g_scanner_get_next_token (scanner);
-
- if (scanner->token == '>')
- {
- selector_path_prepend_combinator (path, COMBINATOR_CHILD);
- g_scanner_get_next_token (scanner);
- }
- }
-
- if (scanner->token == ':')
- {
- /* Add glob selector if path is empty */
- if (selector_path_depth (path) == 0)
- selector_path_prepend_glob (path);
-
- gtk_css_scanner_push_scope (scanner, SCOPE_PSEUDO_CLASS);
-
- while (scanner->token == ':')
- {
- GTokenType token;
-
- if ((token = parse_pseudo_class (css_provider, scanner, path)) != G_TOKEN_NONE)
- return token;
-
- g_scanner_get_next_token (scanner);
- }
-
- gtk_css_scanner_pop_scope (scanner);
- }
-
- return G_TOKEN_NONE;
-}
-#endif
-
static void
resolve_binding_sets (const gchar *value_str,
GValue *value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]