[gtk/wip/otte/for-master] builder-tool: Don't simplify enums too much
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master] builder-tool: Don't simplify enums too much
- Date: Sun, 21 Nov 2021 01:20:36 +0000 (UTC)
commit 27965d5fdc56c91e6c252197d2497bf323b61e16
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 21 01:51:35 2021 +0100
builder-tool: Don't simplify enums too much
Store the enum nick, not the enum value. That way the file remains
human-readable.
Updated reftests to new expected output.
testsuite/tools/simplify-data-3to4/box.expected | 136 ++++++++++-----------
.../tools/simplify-data-3to4/checkbutton.expected | 2 +-
testsuite/tools/simplify-data-3to4/grid.expected | 8 +-
.../gtkfilechooserdialog.expected | 4 +-
.../simplify-data-3to4/office-runner.expected | 14 +--
.../tools/simplify-data-3to4/toolbar.expected | 2 +-
tools/gtk-builder-tool-simplify.c | 10 +-
7 files changed, 92 insertions(+), 84 deletions(-)
---
diff --git a/testsuite/tools/simplify-data-3to4/box.expected b/testsuite/tools/simplify-data-3to4/box.expected
index 54dde405b9..15b6f34c74 100644
--- a/testsuite/tools/simplify-data-3to4/box.expected
+++ b/testsuite/tools/simplify-data-3to4/box.expected
@@ -7,15 +7,15 @@
<child>
<object class="GtkBox">
<property name="hexpand">1</property>
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkBox">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="hexpand">1</property>
<property name="vexpand">0</property>
<child>
<object class="GtkButton">
- <property name="halign">3</property>
+ <property name="halign">center</property>
<property name="label" translatable="1">_</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -30,7 +30,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="halign">3</property>
+ <property name="halign">center</property>
<property name="hexpand">1</property>
<property name="label" translatable="1">E</property>
<property name="focusable">1</property>
@@ -50,12 +50,12 @@
<child>
<object class="GtkBox">
<property name="can_focus">0</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="hexpand">1</property>
<property name="vexpand">0</property>
<child>
<object class="GtkButton">
- <property name="halign">3</property>
+ <property name="halign">center</property>
<property name="label" translatable="1">_</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -70,7 +70,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="halign">3</property>
+ <property name="halign">center</property>
<property name="hexpand">1</property>
<property name="label" translatable="1">E</property>
<property name="focusable">1</property>
@@ -91,13 +91,13 @@
</child>
<child>
<object class="GtkBox">
- <property name="halign">3</property>
- <property name="orientation">1</property>
+ <property name="halign">center</property>
+ <property name="orientation">vertical</property>
<property name="can_focus">0</property>
<property name="vexpand">1</property>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="label" translatable="1">_</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -112,7 +112,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
<property name="label" translatable="1">E</property>
<property name="focusable">1</property>
@@ -133,10 +133,10 @@
<object class="GtkBox">
<property name="hexpand">0</property>
<property name="vexpand">1</property>
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="label" translatable="1">_I</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -151,7 +151,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
<property name="label" translatable="1">EI</property>
<property name="focusable">1</property>
@@ -171,7 +171,7 @@
<property name="label" translatable="1">_S</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -179,7 +179,7 @@
<property name="label" translatable="1">FS</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">1</property>
+ <property name="valign">start</property>
</object>
</child>
<child>
@@ -188,7 +188,7 @@
<property name="label" translatable="1">ES</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -197,7 +197,7 @@
<property name="label" translatable="1">FES</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">1</property>
+ <property name="valign">start</property>
</object>
</child>
<child>
@@ -205,7 +205,7 @@
<property name="label" translatable="1">_N</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -213,7 +213,7 @@
<property name="label" translatable="1">FN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">2</property>
+ <property name="valign">end</property>
</object>
</child>
<child>
@@ -222,7 +222,7 @@
<property name="label" translatable="1">EN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -231,7 +231,7 @@
<property name="label" translatable="1">FEN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">2</property>
+ <property name="valign">end</property>
</object>
</child>
<child>
@@ -239,7 +239,7 @@
<property name="label" translatable="1">_C</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -247,7 +247,7 @@
<property name="label" translatable="1">FC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -256,7 +256,7 @@
<property name="label" translatable="1">EC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -265,7 +265,7 @@
<property name="label" translatable="1">FEC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -273,7 +273,7 @@
<property name="label" translatable="1">_B</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -281,7 +281,7 @@
<property name="label" translatable="1">FB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">4</property>
+ <property name="valign">baseline</property>
</object>
</child>
<child>
@@ -290,7 +290,7 @@
<property name="label" translatable="1">EB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
</object>
</child>
<child>
@@ -299,7 +299,7 @@
<property name="label" translatable="1">FEB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">4</property>
+ <property name="valign">baseline</property>
</object>
</child>
</object>
@@ -308,10 +308,10 @@
<object class="GtkBox">
<property name="hexpand">0</property>
<property name="vexpand">1</property>
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="label" translatable="1">_I</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -328,7 +328,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="label" translatable="1">EI</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -348,7 +348,7 @@
<property name="label" translatable="1">_S</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -357,7 +357,7 @@
<property name="label" translatable="1">FS</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -366,7 +366,7 @@
<property name="label" translatable="1">ES</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -375,7 +375,7 @@
<property name="label" translatable="1">FES</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -384,7 +384,7 @@
<property name="label" translatable="1">_N</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -393,7 +393,7 @@
<property name="label" translatable="1">FN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">2</property>
+ <property name="valign">end</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -402,7 +402,7 @@
<property name="label" translatable="1">EN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -411,7 +411,7 @@
<property name="label" translatable="1">FEN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">2</property>
+ <property name="valign">end</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -420,7 +420,7 @@
<property name="label" translatable="1">_C</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -429,7 +429,7 @@
<property name="label" translatable="1">FC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -438,7 +438,7 @@
<property name="label" translatable="1">EC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -447,7 +447,7 @@
<property name="label" translatable="1">FEC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -456,7 +456,7 @@
<property name="label" translatable="1">_B</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -465,7 +465,7 @@
<property name="label" translatable="1">FB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">4</property>
+ <property name="valign">baseline</property>
<property name="vexpand">0</property>
</object>
</child>
@@ -474,7 +474,7 @@
<property name="label" translatable="1">EB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -483,7 +483,7 @@
<property name="label" translatable="1">FEB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">4</property>
+ <property name="valign">baseline</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -493,10 +493,10 @@
<object class="GtkBox">
<property name="hexpand">0</property>
<property name="vexpand">1</property>
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="label" translatable="1">_I</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -513,7 +513,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="label" translatable="1">EI</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
@@ -533,7 +533,7 @@
<property name="label" translatable="1">_S</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -542,7 +542,7 @@
<property name="label" translatable="1">FS</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -551,7 +551,7 @@
<property name="label" translatable="1">ES</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -560,7 +560,7 @@
<property name="label" translatable="1">FES</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -569,7 +569,7 @@
<property name="label" translatable="1">_N</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -578,7 +578,7 @@
<property name="label" translatable="1">FN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">2</property>
+ <property name="valign">end</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -587,7 +587,7 @@
<property name="label" translatable="1">EN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -596,7 +596,7 @@
<property name="label" translatable="1">FEN</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">2</property>
+ <property name="valign">end</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -605,7 +605,7 @@
<property name="label" translatable="1">_C</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -614,7 +614,7 @@
<property name="label" translatable="1">FC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -623,7 +623,7 @@
<property name="label" translatable="1">EC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -632,7 +632,7 @@
<property name="label" translatable="1">FEC</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -641,7 +641,7 @@
<property name="label" translatable="1">_B</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -650,7 +650,7 @@
<property name="label" translatable="1">FB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">4</property>
+ <property name="valign">baseline</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -659,7 +659,7 @@
<property name="label" translatable="1">EB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">3</property>
+ <property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
@@ -668,7 +668,7 @@
<property name="label" translatable="1">FEB</property>
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="valign">4</property>
+ <property name="valign">baseline</property>
<property name="vexpand">1</property>
</object>
</child>
diff --git a/testsuite/tools/simplify-data-3to4/checkbutton.expected
b/testsuite/tools/simplify-data-3to4/checkbutton.expected
index 24ef3bcd37..c5f8ed6361 100644
--- a/testsuite/tools/simplify-data-3to4/checkbutton.expected
+++ b/testsuite/tools/simplify-data-3to4/checkbutton.expected
@@ -4,7 +4,7 @@
<object class="GtkWindow" id="window1">
<property name="child">
<object class="GtkBox" id="box1">
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="checkbutton1">
<property name="hexpand">1</property>
diff --git a/testsuite/tools/simplify-data-3to4/grid.expected
b/testsuite/tools/simplify-data-3to4/grid.expected
index 60f2972846..2d040d0f19 100644
--- a/testsuite/tools/simplify-data-3to4/grid.expected
+++ b/testsuite/tools/simplify-data-3to4/grid.expected
@@ -100,8 +100,8 @@
<object class="GtkButton" id="button8">
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="halign">3</property>
- <property name="valign">3</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
@@ -112,8 +112,8 @@
<object class="GtkButton" id="button9">
<property name="focusable">1</property>
<property name="receives_default">1</property>
- <property name="halign">3</property>
- <property name="valign">3</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
diff --git a/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected
b/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected
index 9275810c54..b96ec784d8 100644
--- a/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected
+++ b/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected
@@ -9,7 +9,7 @@
<child internal-child="content_area">
<object class="GtkBox" id="dialog-vbox1">
<property name="visible">0</property>
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<property name="border-width">0</property>
<child>
<object class="GtkFileChooserWidget" id="widget">
@@ -31,6 +31,6 @@
</child>
</template>
<object class="GtkSizeGroup" id="buttons">
- <property name="mode">2</property>
+ <property name="mode">vertical</property>
</object>
</interface>
diff --git a/testsuite/tools/simplify-data-3to4/office-runner.expected
b/testsuite/tools/simplify-data-3to4/office-runner.expected
index b166475564..fa8453830d 100644
--- a/testsuite/tools/simplify-data-3to4/office-runner.expected
+++ b/testsuite/tools/simplify-data-3to4/office-runner.expected
@@ -11,7 +11,7 @@
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin_bottom">12</property>
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkNotebook" id="notebook1">
@@ -34,7 +34,7 @@
</child>
<child>
<object class="GtkLabel" id="label5">
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="hexpand">1</property>
<property name="xalign">0</property>
<property name="label" translatable="1"> • Click the "Run!" button, and
then dash to your desk or meeting.
@@ -129,11 +129,11 @@
</child>
<child>
<object class="GtkBox" id="box2">
- <property name="valign">3</property>
- <property name="orientation">1</property>
+ <property name="valign">center</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="result_label">
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="0">Silver Trophy!</property>
<property name="use_markup">1</property>
@@ -148,7 +148,7 @@
</child>
<child>
<object class="GtkLabel" id="current_time_label">
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="0">You managed to finish the route with the
2nd best time ever, <b>48.15 seconds!</b> </property>
<property name="use_markup">1</property>
@@ -157,7 +157,7 @@
</child>
<child>
<object class="GtkLabel" id="better_time_label">
- <property name="valign">1</property>
+ <property name="valign">start</property>
<property name="xalign">0</property>
<property name="label" translatable="0">Only <b>3.75 seconds</b>
separate you from the gold trophy!</property>
<property name="use_markup">1</property>
diff --git a/testsuite/tools/simplify-data-3to4/toolbar.expected
b/testsuite/tools/simplify-data-3to4/toolbar.expected
index d1bafefd5c..6b5db81054 100644
--- a/testsuite/tools/simplify-data-3to4/toolbar.expected
+++ b/testsuite/tools/simplify-data-3to4/toolbar.expected
@@ -12,7 +12,7 @@
</child>
<child>
<object class="GtkSeparator">
- <property name="orientation">1</property>
+ <property name="orientation">vertical</property>
</object>
</child>
<child>
diff --git a/tools/gtk-builder-tool-simplify.c b/tools/gtk-builder-tool-simplify.c
index 0f13bf7a6d..dfa4eb7097 100644
--- a/tools/gtk-builder-tool-simplify.c
+++ b/tools/gtk-builder-tool-simplify.c
@@ -621,7 +621,15 @@ canonical_enum_value (MyParserData *data,
GValue value = G_VALUE_INIT;
if (gtk_builder_value_from_string_type (data->builder, type, string, &value, NULL))
- return g_strdup_printf ("%d", g_value_get_enum (&value));
+ {
+ GEnumClass *eclass = g_type_class_ref (type);
+ GEnumValue *evalue = g_enum_get_value (eclass, g_value_get_enum (&value));
+
+ if (evalue)
+ return g_strdup (evalue->value_nick);
+ else
+ return g_strdup_printf ("%d", g_value_get_enum (&value));
+ }
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]