[gtk] css: Remove GtkCssSectionType



commit 2fb202187cc1185d854ee7229a12e3f1f31ecba4
Author: Benjamin Otte <otte redhat com>
Date:   Wed Apr 10 04:55:37 2019 +0200

    css: Remove GtkCssSectionType
    
    It's unused.

 docs/reference/gtk/gtk4-sections.txt |  2 -
 gtk/gtkcssprovider.c                 | 80 +++++++++++++++++-------------------
 gtk/gtkcsssection.c                  | 19 ---------
 gtk/gtkcsssection.h                  | 38 -----------------
 gtk/gtkcsssectionprivate.h           |  1 -
 5 files changed, 38 insertions(+), 102 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 28d7819b09..3b26ffe436 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5092,12 +5092,10 @@ GtkCssParserWarning
 <SUBSECTION>
 GtkCssLocation
 GtkCssSection
-GtkCssSectionType
 gtk_css_section_get_end_line
 gtk_css_section_get_end_position
 gtk_css_section_get_file
 gtk_css_section_get_parent
-gtk_css_section_get_section_type
 gtk_css_section_get_start_line
 gtk_css_section_get_start_position
 gtk_css_section_ref
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 37e8338531..7bc5893fff 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -391,13 +391,11 @@ gtk_css_scanner_would_recurse (GtkCssScanner *scanner,
 }
 
 static void
-gtk_css_scanner_push_section (GtkCssScanner     *scanner,
-                              GtkCssSectionType  section_type)
+gtk_css_scanner_push_section (GtkCssScanner *scanner)
 {
   GtkCssSection *section;
 
   section = gtk_css_section_new_for_parser (scanner->section,
-                                            section_type,
                                             scanner->parser);
 
   if (scanner->section)
@@ -406,13 +404,10 @@ gtk_css_scanner_push_section (GtkCssScanner     *scanner,
 }
 
 static void
-gtk_css_scanner_pop_section (GtkCssScanner *scanner,
-                             GtkCssSectionType check_type)
+gtk_css_scanner_pop_section (GtkCssScanner *scanner)
 {
   GtkCssSection *parent;
   
-  g_assert (gtk_css_section_get_section_type (scanner->section) == check_type);
-
   parent = gtk_css_section_get_parent (scanner->section);
   if (parent)
     gtk_css_section_ref (parent);
@@ -777,11 +772,11 @@ parse_import (GtkCssScanner *scanner)
 {
   GFile *file;
 
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_IMPORT);
+  gtk_css_scanner_push_section (scanner);
 
   if (!gtk_css_parser_try_at_keyword (scanner->parser, "import"))
     {
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_IMPORT);
+      gtk_css_scanner_pop_section (scanner);
       return FALSE;
     }
 
@@ -841,7 +836,7 @@ parse_import (GtkCssScanner *scanner)
 
   g_clear_object (&file);
 
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_IMPORT);
+  gtk_css_scanner_pop_section (scanner);
 
   return TRUE;
 }
@@ -853,18 +848,18 @@ parse_color_definition (GtkCssScanner *scanner)
   GtkCssValue *color;
   char *name;
 
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
+  gtk_css_scanner_push_section (scanner);
 
   if (!gtk_css_parser_try_at_keyword (scanner->parser, "define-color"))
     {
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
+      gtk_css_scanner_pop_section (scanner);
       return FALSE;
     }
 
   name = gtk_css_parser_consume_ident (scanner->parser);
   if (name == NULL)
     {
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
+      gtk_css_scanner_pop_section (scanner);
       return TRUE;
     }
 
@@ -872,7 +867,7 @@ parse_color_definition (GtkCssScanner *scanner)
   if (color == NULL)
     {
       g_free (name);
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
+      gtk_css_scanner_pop_section (scanner);
       return TRUE;
     }
 
@@ -886,13 +881,13 @@ parse_color_definition (GtkCssScanner *scanner)
                                       GTK_CSS_PARSER_ERROR_SYNTAX,
                                       "Missing semicolon at end of color definition");
 
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
+      gtk_css_scanner_pop_section (scanner);
       return TRUE;
     }
 
   g_hash_table_insert (priv->symbolic_colors, name, color);
 
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
+  gtk_css_scanner_pop_section (scanner);
   return TRUE;
 }
 
@@ -903,18 +898,18 @@ parse_keyframes (GtkCssScanner *scanner)
   GtkCssKeyframes *keyframes;
   char *name;
 
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
+  gtk_css_scanner_push_section (scanner);
 
   if (!gtk_css_parser_try_at_keyword (scanner->parser, "keyframes"))
     {
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
+      gtk_css_scanner_pop_section (scanner);
       return FALSE;
     }
 
   name = gtk_css_parser_consume_ident (scanner->parser);
   if (name == NULL)
     {
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
+      gtk_css_scanner_pop_section (scanner);
       return FALSE;
     }
 
@@ -925,7 +920,7 @@ parse_keyframes (GtkCssScanner *scanner)
                                       GTK_CSS_PARSER_ERROR,
                                       GTK_CSS_PARSER_ERROR_SYNTAX,
                                       "Expected '{' for keyframes");
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
+      gtk_css_scanner_pop_section (scanner);
       return FALSE;
     }
 
@@ -944,7 +939,7 @@ parse_keyframes (GtkCssScanner *scanner)
                                       "expected '}' after declarations");
     }
 
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_KEYFRAMES);
+  gtk_css_scanner_pop_section (scanner);
 
   return TRUE;
 }
@@ -973,14 +968,14 @@ parse_selector_list (GtkCssScanner *scanner)
 {
   GSList *selectors = NULL;
 
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_SELECTOR);
+  gtk_css_scanner_push_section (scanner);
 
   do {
       GtkCssSelector *select = _gtk_css_selector_parse (scanner->parser);
 
       if (select == NULL)
         {
-          gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_SELECTOR);
+          gtk_css_scanner_pop_section (scanner);
           return NULL;
         }
 
@@ -988,7 +983,7 @@ parse_selector_list (GtkCssScanner *scanner)
     }
   while (gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COMMA));
 
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_SELECTOR);
+  gtk_css_scanner_pop_section (scanner);
 
   return selectors;
 }
@@ -1000,13 +995,14 @@ parse_declaration (GtkCssScanner *scanner,
   GtkStyleProperty *property;
   char *name;
 
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_DECLARATION);
+  gtk_css_scanner_push_section (scanner);
   gtk_css_parser_start_semicolon_block (scanner->parser, GTK_CSS_TOKEN_EOF);
 
   if (gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF))
     {
       gtk_css_parser_warn_syntax (scanner->parser, "Empty declaration");
       gtk_css_parser_end_block (scanner->parser);
+      gtk_css_scanner_pop_section (scanner);
       return;
     }
 
@@ -1014,7 +1010,7 @@ parse_declaration (GtkCssScanner *scanner,
   if (name == NULL)
     {
       gtk_css_parser_end_block (scanner->parser);
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
+      gtk_css_scanner_pop_section (scanner);
       return;
     }
 
@@ -1029,11 +1025,11 @@ parse_declaration (GtkCssScanner *scanner,
           gtk_css_parser_error_syntax (scanner->parser, "Expected ':'");
           g_free (name);
           gtk_css_parser_end_block (scanner->parser);
-          gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
+          gtk_css_scanner_pop_section (scanner);
           return;
         }
 
-      gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_VALUE);
+      gtk_css_scanner_push_section (scanner);
 
       value = _gtk_style_property_parse_value (property,
                                                scanner->parser);
@@ -1041,8 +1037,8 @@ parse_declaration (GtkCssScanner *scanner,
       if (value == NULL)
         {
           gtk_css_parser_end_block (scanner->parser);
-          gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
-          gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
+          gtk_css_scanner_pop_section (scanner);
+          gtk_css_scanner_pop_section (scanner);
           return;
         }
 
@@ -1054,8 +1050,8 @@ parse_declaration (GtkCssScanner *scanner,
                                   GTK_CSS_PARSER_ERROR_SYNTAX,
                                   "Junk at end of value for %s", property->name);
           gtk_css_parser_end_block (scanner->parser);
-          gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
-          gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
+          gtk_css_scanner_pop_section (scanner);
+          gtk_css_scanner_pop_section (scanner);
           return;
         }
 
@@ -1085,7 +1081,7 @@ parse_declaration (GtkCssScanner *scanner,
         }
 
 
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
+      gtk_css_scanner_pop_section (scanner);
     }
   else
     {
@@ -1095,7 +1091,7 @@ parse_declaration (GtkCssScanner *scanner,
   g_free (name);
 
   gtk_css_parser_end_block (scanner->parser);
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DECLARATION);
+  gtk_css_scanner_pop_section (scanner);
 }
 
 static void
@@ -1114,14 +1110,14 @@ parse_ruleset (GtkCssScanner *scanner)
   GSList *selectors;
   GtkCssRuleset ruleset = { 0, };
 
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_RULESET);
+  gtk_css_scanner_push_section (scanner);
 
   selectors = parse_selector_list (scanner);
   if (selectors == NULL)
     {
       gtk_css_parser_skip_until (scanner->parser, GTK_CSS_TOKEN_OPEN_CURLY);
       gtk_css_parser_skip (scanner->parser);
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
+      gtk_css_scanner_pop_section (scanner);
       return;
     }
 
@@ -1135,7 +1131,7 @@ parse_ruleset (GtkCssScanner *scanner)
       g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
       gtk_css_parser_skip_until (scanner->parser, GTK_CSS_TOKEN_OPEN_CURLY);
       gtk_css_parser_skip (scanner->parser);
-      gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
+      gtk_css_scanner_pop_section (scanner);
       return;
     }
 
@@ -1147,7 +1143,7 @@ parse_ruleset (GtkCssScanner *scanner)
 
   css_provider_commit (scanner->provider, selectors, &ruleset);
   gtk_css_ruleset_clear (&ruleset);
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_RULESET);
+  gtk_css_scanner_pop_section (scanner);
 }
 
 static void
@@ -1162,7 +1158,7 @@ parse_statement (GtkCssScanner *scanner)
 static void
 parse_stylesheet (GtkCssScanner *scanner)
 {
-  gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_DOCUMENT);
+  gtk_css_scanner_push_section (scanner);
 
   while (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF))
     {
@@ -1176,7 +1172,7 @@ parse_stylesheet (GtkCssScanner *scanner)
       parse_statement (scanner);
     }
 
-  gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DOCUMENT);
+  gtk_css_scanner_pop_section (scanner);
 }
 
 static int
@@ -1258,7 +1254,7 @@ gtk_css_provider_load_internal (GtkCssProvider *css_provider,
                                              tmp_bytes);
               g_bytes_unref (tmp_bytes);
 
-              gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_DOCUMENT);
+              gtk_css_scanner_push_section (scanner);
             }
           else
             scanner = parent;
@@ -1272,7 +1268,7 @@ gtk_css_provider_load_internal (GtkCssProvider *css_provider,
 
           if (parent == NULL)
             {
-              gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_DOCUMENT);
+              gtk_css_scanner_pop_section (scanner);
 
               gtk_css_scanner_destroy (scanner);
             }
diff --git a/gtk/gtkcsssection.c b/gtk/gtkcsssection.c
index bb5a711625..c514f27651 100644
--- a/gtk/gtkcsssection.c
+++ b/gtk/gtkcsssection.c
@@ -25,7 +25,6 @@
 struct _GtkCssSection
 {
   gint                ref_count;
-  GtkCssSectionType   section_type;
   GtkCssSection      *parent;
   GFile              *file;
   GtkCssLocation      start_location;
@@ -37,7 +36,6 @@ G_DEFINE_BOXED_TYPE (GtkCssSection, gtk_css_section, gtk_css_section_ref, gtk_cs
 
 GtkCssSection *
 gtk_css_section_new_for_parser (GtkCssSection     *parent,
-                                GtkCssSectionType  type,
                                 GtkCssParser      *parser)
 {
   GtkCssSection *section;
@@ -47,7 +45,6 @@ gtk_css_section_new_for_parser (GtkCssSection     *parent,
   section = g_slice_new0 (GtkCssSection);
 
   section->ref_count = 1;
-  section->section_type = type;
   if (parent)
     section->parent = gtk_css_section_ref (parent);
   section->file = gtk_css_parser_get_file (parser);
@@ -111,22 +108,6 @@ gtk_css_section_unref (GtkCssSection *section)
   g_slice_free (GtkCssSection, section);
 }
 
-/**
- * gtk_css_section_get_section_type:
- * @section: the section
- *
- * Gets the type of information that @section describes.
- *
- * Returns: the type of @section
- **/
-GtkCssSectionType
-gtk_css_section_get_section_type (const GtkCssSection *section)
-{
-  gtk_internal_return_val_if_fail (section != NULL, GTK_CSS_SECTION_DOCUMENT);
-
-  return section->section_type;
-}
-
 /**
  * gtk_css_section_get_parent:
  * @section: the section
diff --git a/gtk/gtkcsssection.h b/gtk/gtkcsssection.h
index 2bcf3db213..4927cd1cc0 100644
--- a/gtk/gtkcsssection.h
+++ b/gtk/gtkcsssection.h
@@ -25,42 +25,6 @@ G_BEGIN_DECLS
 
 #define GTK_TYPE_CSS_SECTION         (gtk_css_section_get_type ())
 
-/**
- * GtkCssSectionType:
- * @GTK_CSS_SECTION_DOCUMENT: The section describes a complete document.
- *   This section time is the only one where gtk_css_section_get_parent()
- *   might return %NULL.
- * @GTK_CSS_SECTION_IMPORT: The section defines an import rule.
- * @GTK_CSS_SECTION_COLOR_DEFINITION: The section defines a color. This
- *   is a GTK extension to CSS.
- * @GTK_CSS_SECTION_RULESET: The section defines a CSS ruleset.
- * @GTK_CSS_SECTION_SELECTOR: The section defines a CSS selector.
- * @GTK_CSS_SECTION_DECLARATION: The section defines the declaration of
- *   a CSS variable.
- * @GTK_CSS_SECTION_VALUE: The section defines the value of a CSS declaration.
- * @GTK_CSS_SECTION_KEYFRAMES: The section defines keyframes. See [CSS
- *   Animations](http://dev.w3.org/csswg/css3-animations/#keyframes) for details
- *
- * The different types of sections indicate parts of a CSS document as
- * parsed by GTK’s CSS parser. They are oriented towards the
- * [CSS Grammar](http://www.w3.org/TR/CSS21/grammar.html),
- * but may contain extensions.
- *
- * More types might be added in the future as the parser incorporates
- * more features.
- */
-typedef enum
-{
-  GTK_CSS_SECTION_DOCUMENT,
-  GTK_CSS_SECTION_IMPORT,
-  GTK_CSS_SECTION_COLOR_DEFINITION,
-  GTK_CSS_SECTION_RULESET,
-  GTK_CSS_SECTION_SELECTOR,
-  GTK_CSS_SECTION_DECLARATION,
-  GTK_CSS_SECTION_VALUE,
-  GTK_CSS_SECTION_KEYFRAMES
-} GtkCssSectionType;
-
 /**
  * GtkCssSection:
  *
@@ -78,8 +42,6 @@ GtkCssSection *    gtk_css_section_ref                 (GtkCssSection        *se
 GDK_AVAILABLE_IN_ALL
 void               gtk_css_section_unref               (GtkCssSection        *section);
 
-GDK_AVAILABLE_IN_ALL
-GtkCssSectionType  gtk_css_section_get_section_type    (const GtkCssSection  *section);
 GDK_AVAILABLE_IN_ALL
 GtkCssSection *    gtk_css_section_get_parent          (const GtkCssSection  *section);
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkcsssectionprivate.h b/gtk/gtkcsssectionprivate.h
index a028f20ecd..39ec70266b 100644
--- a/gtk/gtkcsssectionprivate.h
+++ b/gtk/gtkcsssectionprivate.h
@@ -25,7 +25,6 @@
 G_BEGIN_DECLS
 
 GtkCssSection *    gtk_css_section_new_for_parser      (GtkCssSection        *parent,
-                                                        GtkCssSectionType     type,
                                                         GtkCssParser         *parser);
 
 void               _gtk_css_section_end                (GtkCssSection        *section);


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