[gtk/matthiasc/for-master: 2/2] builder-tool: Avoid <style> when converting




commit 5bc3923bae211780715714e559b24398f6a385b8
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Sep 28 15:59:24 2021 -0400

    builder-tool: Avoid <style> when converting
    
    We can just set the css-classes property instead.
    
    Update affected tests.

 testsuite/tools/simplify-data-3to4/toolbar.expected |  4 +---
 tools/gtk-builder-tool-simplify.c                   | 13 ++++++-------
 2 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/testsuite/tools/simplify-data-3to4/toolbar.expected 
b/testsuite/tools/simplify-data-3to4/toolbar.expected
index 558022d325..c9568b0605 100644
--- a/testsuite/tools/simplify-data-3to4/toolbar.expected
+++ b/testsuite/tools/simplify-data-3to4/toolbar.expected
@@ -2,9 +2,7 @@
 <interface>
   <requires lib="gtk" version="4.0"/>
   <object class="GtkBox">
-    <style>
-      <class name="toolbar"/>
-    </style>
+    <property name="css-classes">toolbar</property>
     <child>
       <object class="GtkButton">
         <property name="label" translatable="yes">New</property>
diff --git a/tools/gtk-builder-tool-simplify.c b/tools/gtk-builder-tool-simplify.c
index ff1f72a482..3eb5a21f78 100644
--- a/tools/gtk-builder-tool-simplify.c
+++ b/tools/gtk-builder-tool-simplify.c
@@ -1723,7 +1723,6 @@ rewrite_toolbar (Element      *element,
                  MyParserData *data)
 {
   GList *l, *ll;
-  Element *style = NULL;
 
   set_attribute_value (element, "class", "GtkBox");
 
@@ -1747,9 +1746,6 @@ rewrite_toolbar (Element      *element,
       Element *object = NULL;
       Element *packing = NULL;
 
-      if (g_str_equal (child->element_name, "style"))
-        style = child;
-
       if (!g_str_equal (child->element_name, "child"))
         continue;
 
@@ -1794,10 +1790,13 @@ rewrite_toolbar (Element      *element,
         child->children = g_list_remove (child->children, packing);
     }
 
-  if (!style)
-    style = add_element (element, "style");
+  {
+    Element *child;
 
-  set_attribute_value (add_element (style, "class"), "name", "toolbar");
+    child = add_element (element, "property");
+    set_attribute_value (child, "name", "css-classes");
+    child->data = g_strdup ("toolbar");
+  }
 }
 
 static void


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