[gtk/grid-api: 4/4] builder-tool: Rewrite top/left-attach




commit 71be1751c635cbe4ae65ca299d1b30f458981494
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 2 15:10:18 2020 -0400

    builder-tool: Rewrite top/left-attach
    
    Rewrite the GtkGrid:top/left-attach child properties
    to the GtkGridLayoutChild:row/column layout properties.
    
    Update expected test output to match.

 gtk/tools/gtk-builder-tool-simplify.c              | 16 +++++-----
 testsuite/tools/simplify-data-3to4/grid.expected   | 36 +++++++++++-----------
 .../simplify-data-3to4/office-runner.expected      | 28 ++++++++---------
 3 files changed, 41 insertions(+), 39 deletions(-)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index da234e0394..92a126ca33 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -1434,21 +1434,21 @@ rewrite_grid_layout_prop (Element *element,
                           const char *old_value,
                           const char *new_value)
 {
-  char *canonical_name;
-
-  canonical_name = g_strdup (old_value);
-  g_strdelimit (canonical_name, "_", '-');
-
   if (g_str_equal (element->element_name, "property"))
     {
+      char *canonical_name;
+
+      canonical_name = g_strdup (old_value);
+      g_strdelimit (canonical_name, "_", '-');
+
       if (has_attribute (element, attr_name, old_value) ||
           has_attribute (element, attr_name, canonical_name))
         {
           set_attribute_value (element, attr_name, new_value);
         }
-    }
 
-  g_free (canonical_name);
+      g_free (canonical_name);
+    }
 }
 
 static void
@@ -1460,6 +1460,8 @@ rewrite_grid_layout (Element *element,
     const char *old_value;
     const char *new_value;
   } props[] = {
+    { "name", "left_attach", "column", },
+    { "name", "top_attach", "row", },
     { "name", "width", "column-span", },
     { "name", "height", "row-span", },
   };
diff --git a/testsuite/tools/simplify-data-3to4/grid.expected 
b/testsuite/tools/simplify-data-3to4/grid.expected
index f14ad0d248..b832c4ba31 100644
--- a/testsuite/tools/simplify-data-3to4/grid.expected
+++ b/testsuite/tools/simplify-data-3to4/grid.expected
@@ -15,8 +15,8 @@
             <property name="margin-top">10</property>
             <property name="margin-bottom">10</property>
             <layout>
-              <property name="left_attach">0</property>
-              <property name="top_attach">0</property>
+              <property name="column">0</property>
+              <property name="row">0</property>
             </layout>
           </object>
         </child>
@@ -25,8 +25,8 @@
             <property name="label" translatable="yes">Hello World!</property>
             <property name="receives_default">1</property>
             <layout>
-              <property name="left_attach">1</property>
-              <property name="top_attach">0</property>
+              <property name="column">1</property>
+              <property name="row">0</property>
             </layout>
           </object>
         </child>
@@ -35,8 +35,8 @@
             <property name="label" translatable="yes">Hello World!</property>
             <property name="receives_default">1</property>
             <layout>
-              <property name="left_attach">2</property>
-              <property name="top_attach">0</property>
+              <property name="column">2</property>
+              <property name="row">0</property>
             </layout>
           </object>
         </child>
@@ -47,8 +47,8 @@
             <property name="group">button3</property>
             <property name="receives_default">1</property>
             <layout>
-              <property name="left_attach">3</property>
-              <property name="top_attach">0</property>
+              <property name="column">3</property>
+              <property name="row">0</property>
             </layout>
           </object>
         </child>
@@ -57,8 +57,8 @@
             <property name="active">1</property>
             <property name="receives_default">1</property>
             <layout>
-              <property name="left_attach">4</property>
-              <property name="top_attach">0</property>
+              <property name="column">4</property>
+              <property name="row">0</property>
             </layout>
           </object>
         </child>
@@ -66,8 +66,8 @@
           <object class="GtkSwitch" id="button6">
             <property name="receives_default">1</property>
             <layout>
-              <property name="left_attach">5</property>
-              <property name="top_attach">0</property>
+              <property name="column">5</property>
+              <property name="row">0</property>
             </layout>
           </object>
         </child>
@@ -76,8 +76,8 @@
             <property name="receives_default">1</property>
             <property name="label">Text Button</property>
             <layout>
-              <property name="left_attach">0</property>
-              <property name="top_attach">1</property>
+              <property name="column">0</property>
+              <property name="row">1</property>
             </layout>
           </object>
         </child>
@@ -87,8 +87,8 @@
             <property name="halign">center</property>
             <property name="valign">center</property>
             <layout>
-              <property name="left_attach">1</property>
-              <property name="top_attach">1</property>
+              <property name="column">1</property>
+              <property name="row">1</property>
             </layout>
           </object>
         </child>
@@ -98,8 +98,8 @@
             <property name="halign">center</property>
             <property name="valign">center</property>
             <layout>
-              <property name="left_attach">2</property>
-              <property name="top_attach">1</property>
+              <property name="column">2</property>
+              <property name="row">1</property>
               <property name="column-span">2</property>
               <property name="row-span">2</property>
             </layout>
diff --git a/testsuite/tools/simplify-data-3to4/office-runner.expected 
b/testsuite/tools/simplify-data-3to4/office-runner.expected
index 11131a71e5..adeca878bf 100644
--- a/testsuite/tools/simplify-data-3to4/office-runner.expected
+++ b/testsuite/tools/simplify-data-3to4/office-runner.expected
@@ -26,8 +26,8 @@
                       <object class="GtkImage" id="run_image">
                         <property name="vexpand">1</property>
                         <layout>
-                          <property name="left_attach">0</property>
-                          <property name="top_attach">0</property>
+                          <property name="column">0</property>
+                          <property name="row">0</property>
                         </layout>
                       </object>
                     </child>
@@ -41,8 +41,8 @@
 </property>
                         <property name="use_markup">1</property>
                         <layout>
-                          <property name="left_attach">1</property>
-                          <property name="top_attach">1</property>
+                          <property name="column">1</property>
+                          <property name="row">1</property>
                         </layout>
                       </object>
                     </child>
@@ -53,8 +53,8 @@
                           <attribute name="scale" value="2"></attribute>
                         </attributes>
                         <layout>
-                          <property name="left_attach">1</property>
-                          <property name="top_attach">0</property>
+                          <property name="column">1</property>
+                          <property name="row">0</property>
                         </layout>
                       </object>
                     </child>
@@ -81,8 +81,8 @@
                       <object class="GtkImage" id="time_image">
                         <property name="vexpand">1</property>
                         <layout>
-                          <property name="left_attach">1</property>
-                          <property name="top_attach">0</property>
+                          <property name="column">1</property>
+                          <property name="row">0</property>
                         </layout>
                       </object>
                     </child>
@@ -96,8 +96,8 @@
                           <attribute name="font-features" value="tnum 1"></attribute>
                         </attributes>
                         <layout>
-                          <property name="left_attach">0</property>
-                          <property name="top_attach">0</property>
+                          <property name="column">0</property>
+                          <property name="row">0</property>
                         </layout>
                       </object>
                     </child>
@@ -121,8 +121,8 @@
                     <child>
                       <object class="GtkImage" id="trophy_image">
                         <layout>
-                          <property name="left_attach">0</property>
-                          <property name="top_attach">0</property>
+                          <property name="column">0</property>
+                          <property name="row">0</property>
                         </layout>
                       </object>
                     </child>
@@ -176,8 +176,8 @@
                           </packing>
                         </child>
                         <layout>
-                          <property name="left_attach">1</property>
-                          <property name="top_attach">0</property>
+                          <property name="column">1</property>
+                          <property name="row">0</property>
                         </layout>
                       </object>
                     </child>


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