[gtk+/parser] xxx: cssprovider: (re)add support for binding sets



commit 5002e5ef4e1785fc933f50e05d209f4fdda745b7
Author: Benjamin Otte <otte redhat com>
Date:   Wed May 18 17:53:00 2011 +0200

    xxx: cssprovider: (re)add support for binding sets
    
    This part of the code was lost in the parser rewrite. Ooops.

 gtk/gtkcssprovider.c |   87 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index c7b44d3..7a1bfc0 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1521,12 +1521,99 @@ parse_color_definition (GtkCssScanner *scanner)
 }
 
 static void
+parse_binding_set (GtkCssScanner *scanner)
+{
+  GtkBindingSet *binding_set;
+  char *name;
+
+  name = _gtk_css_parser_try_ident (scanner->parser, TRUE);
+  if (name == NULL)
+    {
+      gtk_css_provider_error_literal (scanner->provider,
+                                      scanner,
+                                      GTK_CSS_PROVIDER_ERROR,
+                                      GTK_CSS_PROVIDER_ERROR_SYNTAX,
+                                      "Expected name for binding set");
+      _gtk_css_parser_resync (scanner->parser, TRUE, 0);
+      goto skip_semicolon;
+    }
+
+  binding_set = gtk_binding_set_find (name);
+  if (!binding_set)
+    {
+      binding_set = gtk_binding_set_new (name);
+      binding_set->parsed = TRUE;
+    }
+  g_free (name);
+
+  if (!_gtk_css_parser_try (scanner->parser, "{", TRUE))
+    {
+      gtk_css_provider_error_literal (scanner->provider,
+                                      scanner,
+                                      GTK_CSS_PROVIDER_ERROR,
+                                      GTK_CSS_PROVIDER_ERROR_SYNTAX,
+                                      "Expected '{' for binding set");
+      _gtk_css_parser_resync (scanner->parser, TRUE, 0);
+      goto skip_semicolon;
+    }
+
+  while (!_gtk_css_parser_is_eof (scanner->parser) &&
+         !_gtk_css_parser_begins_with (scanner->parser, '}'))
+    {
+      name = _gtk_css_parser_read_value (scanner->parser);
+      if (name == NULL)
+        {
+          _gtk_css_parser_resync (scanner->parser, TRUE, '}');
+          continue;
+        }
+
+      gtk_binding_entry_add_signal_from_string (binding_set, name);
+      g_free (name);
+
+      if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
+        {
+          if (!_gtk_css_parser_begins_with (scanner->parser, '}') &&
+              !_gtk_css_parser_is_eof (scanner->parser))
+            {
+              gtk_css_provider_error_literal (scanner->provider,
+                                              scanner,
+                                              GTK_CSS_PROVIDER_ERROR,
+                                              GTK_CSS_PROVIDER_ERROR_SYNTAX,
+                                              "Expected semicolon");
+              _gtk_css_parser_resync (scanner->parser, TRUE, '}');
+            }
+        }
+    }
+
+  if (!_gtk_css_parser_try (scanner->parser, "}", TRUE))
+    {
+      gtk_css_provider_error_literal (scanner->provider,
+                                      scanner,
+                                      GTK_CSS_PROVIDER_ERROR,
+                                      GTK_CSS_PROVIDER_ERROR_SYNTAX,
+                                      "expected '}' after declarations");
+      if (!_gtk_css_parser_is_eof (scanner->parser))
+        _gtk_css_parser_resync (scanner->parser, FALSE, 0);
+    }
+
+skip_semicolon:
+  if (_gtk_css_parser_try (scanner->parser, ";", TRUE))
+    gtk_css_provider_error_literal (scanner->provider,
+                                    scanner,
+                                    GTK_CSS_PROVIDER_ERROR,
+                                    GTK_CSS_PROVIDER_ERROR_DEPRECATED,
+                                    "Nonstandard semicolon at end of binding set");
+}
+
+static void
 parse_at_keyword (GtkCssScanner *scanner)
 {
   if (_gtk_css_parser_try (scanner->parser, "@import", TRUE))
     parse_import (scanner);
   else if (_gtk_css_parser_try (scanner->parser, "@define-color", TRUE))
     parse_color_definition (scanner);
+  else if (_gtk_css_parser_try (scanner->parser, "@binding-set", TRUE))
+    parse_binding_set (scanner);
   else
     {
       gtk_css_provider_error_literal (scanner->provider,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]