[gtk/bin-removal: 23/28] builder-tool: Convert former bin children
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/bin-removal: 23/28] builder-tool: Convert former bin children
- Date: Mon, 4 May 2020 05:07:38 +0000 (UTC)
commit 4c0ce8b5f5b83e0ea3c8888432301a989ec24aff
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 1 18:02:46 2020 -0400
builder-tool: Convert former bin children
Convert from <child> elements to <property name="child">
for former GtkBin subclasses. Update test results
to match.
gtk/tools/gtk-builder-tool-simplify.c | 66 ++++++++++++++++++++++
testsuite/tools/simplify-data-3to4/grid.expected | 4 +-
.../tools/simplify-data-3to4/notebook.expected | 4 +-
.../simplify-data-3to4/office-runner.expected | 4 +-
testsuite/tools/simplify-data-3to4/stack.expected | 4 +-
5 files changed, 74 insertions(+), 8 deletions(-)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 06a31fb2b9..b41f4ec9d9 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -1490,6 +1490,55 @@ rewrite_grid_layout (Element *element,
}
}
+static void
+rewrite_bin_child (Element *element,
+ MyParserData *data)
+{
+ GList *l, *ll;
+ const char *class_name;
+ GType type;
+
+ for (l = element->children; l; l = l->next)
+ {
+ Element *child = l->data;
+ Element *object = NULL;
+
+ if (!g_str_equal (child->element_name, "child"))
+ continue;
+
+ for (ll = child->children; ll; ll = ll->next)
+ {
+ Element *elem = ll->data;
+
+ if (!g_str_equal (elem->element_name, "object"))
+ continue;
+
+ class_name = get_attribute_value (elem, "class");
+ if (!class_name)
+ continue;
+
+ type = g_type_from_name (class_name);
+ if (!g_type_is_a (type, GTK_TYPE_WIDGET))
+ continue;
+
+ object = elem;
+ }
+
+ if (object)
+ {
+ g_free (child->element_name);
+ g_strfreev (child->attribute_names);
+ g_strfreev (child->attribute_values);
+ child->element_name = g_strdup ("property");
+ child->attribute_names = g_new0 (char *, 2);
+ child->attribute_names[0] = g_strdup ("name");
+ child->attribute_values = g_new0 (char *, 2);
+ child->attribute_values[0] = g_strdup ("child");
+ break;
+ }
+ }
+}
+
/* returns TRUE to remove the element from the parent */
static gboolean
simplify_element (Element *element,
@@ -1604,6 +1653,23 @@ rewrite_element (Element *element,
g_str_equal (get_class_name (element), "GtkFixed"))
rewrite_layout_props (element, data);
+ if (element_is_object_or_template (element) &&
+ (g_str_equal (get_class_name (element), "GtkAspectFrame") ||
+ g_str_equal (get_class_name (element), "GtkComboBox") ||
+ g_str_equal (get_class_name (element), "GtkComboBoxText") ||
+ g_str_equal (get_class_name (element), "GtkFlowBoxChild") ||
+ g_str_equal (get_class_name (element), "GtkFrame") ||
+ g_str_equal (get_class_name (element), "GtkListBoxRow") ||
+ g_str_equal (get_class_name (element), "GtkOverlay") ||
+ g_str_equal (get_class_name (element), "GtkPopover") ||
+ g_str_equal (get_class_name (element), "GtkPopoverMenu") ||
+ g_str_equal (get_class_name (element), "GtkRevealer") ||
+ g_str_equal (get_class_name (element), "GtkScrolledWindow") ||
+ g_str_equal (get_class_name (element), "GtkSearchBar") ||
+ g_str_equal (get_class_name (element), "GtkViewport") ||
+ g_str_equal (get_class_name (element), "GtkWindow")))
+ rewrite_bin_child (element, data);
+
if (g_str_equal (element->element_name, "property"))
maybe_rename_property (element, data);
diff --git a/testsuite/tools/simplify-data-3to4/grid.expected
b/testsuite/tools/simplify-data-3to4/grid.expected
index 61989d49f8..5005cc0725 100644
--- a/testsuite/tools/simplify-data-3to4/grid.expected
+++ b/testsuite/tools/simplify-data-3to4/grid.expected
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
- <child>
+ <property name="child">
<object class="GtkGrid" id="grid1">
<child>
<object class="GtkToggleButton" id="button1">
@@ -111,6 +111,6 @@
</object>
</child>
</object>
- </child>
+ </property>
</object>
</interface>
diff --git a/testsuite/tools/simplify-data-3to4/notebook.expected
b/testsuite/tools/simplify-data-3to4/notebook.expected
index c0f84f57f2..f0bc7f9e82 100644
--- a/testsuite/tools/simplify-data-3to4/notebook.expected
+++ b/testsuite/tools/simplify-data-3to4/notebook.expected
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
- <child>
+ <property name="child">
<object class="GtkNotebook" id="notebook1">
<child>
<object class="GtkNotebookPage">
@@ -32,6 +32,6 @@
</object>
</child>
</object>
- </child>
+ </property>
</object>
</interface>
diff --git a/testsuite/tools/simplify-data-3to4/office-runner.expected
b/testsuite/tools/simplify-data-3to4/office-runner.expected
index 9c0189733d..11131a71e5 100644
--- a/testsuite/tools/simplify-data-3to4/office-runner.expected
+++ b/testsuite/tools/simplify-data-3to4/office-runner.expected
@@ -5,7 +5,7 @@
<property name="title" translatable="yes">Office Runner</property>
<property name="resizable">0</property>
<property name="window_position">center</property>
- <child>
+ <property name="child">
<object class="GtkBox" id="box1">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
@@ -217,6 +217,6 @@
</packing>
</child>
</object>
- </child>
+ </property>
</object>
</interface>
diff --git a/testsuite/tools/simplify-data-3to4/stack.expected
b/testsuite/tools/simplify-data-3to4/stack.expected
index 1c5c0beb56..611d20edf8 100644
--- a/testsuite/tools/simplify-data-3to4/stack.expected
+++ b/testsuite/tools/simplify-data-3to4/stack.expected
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
- <child>
+ <property name="child">
<object class="GtkBox" id="box1">
<child>
<object class="GtkStackSwitcher" id="stackswitcher1">
@@ -39,6 +39,6 @@
</object>
</child>
</object>
- </child>
+ </property>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]