diff --git a/testsuite/tools/simplify-data-3to4/paned.expected b/testsuite/tools/simplify-data-3to4/paned.expected
index d767086ba8..117fd2d4b6 100644
--- a/testsuite/tools/simplify-data-3to4/paned.expected
+++ b/testsuite/tools/simplify-data-3to4/paned.expected
@@ -4,11 +4,11 @@
diff --git a/testsuite/tools/simplify-data/test10.expected b/testsuite/tools/simplify-data/test10.expected
new file mode 100644
index 0000000000..54dec91df8
--- /dev/null
+++ b/testsuite/tools/simplify-data/test10.expected
@@ -0,0 +1,10 @@
+
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test10.ui b/testsuite/tools/simplify-data/test10.ui
new file mode 100644
index 0000000000..3b5e171633
--- /dev/null
+++ b/testsuite/tools/simplify-data/test10.ui
@@ -0,0 +1,9 @@
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test11.expected b/testsuite/tools/simplify-data/test11.expected
new file mode 100644
index 0000000000..d54c185bd6
--- /dev/null
+++ b/testsuite/tools/simplify-data/test11.expected
@@ -0,0 +1,15 @@
+
+
+
+
+
+ start
+
+
+
+
+ end
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test11.ui b/testsuite/tools/simplify-data/test11.ui
new file mode 100644
index 0000000000..1f546a1d08
--- /dev/null
+++ b/testsuite/tools/simplify-data/test11.ui
@@ -0,0 +1,14 @@
+
+
+
+
+ start
+
+
+
+
+ end
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test12.expected b/testsuite/tools/simplify-data/test12.expected
new file mode 100644
index 0000000000..bc43c43753
--- /dev/null
+++ b/testsuite/tools/simplify-data/test12.expected
@@ -0,0 +1,15 @@
+
+
+
+
+
+ end
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test12.ui b/testsuite/tools/simplify-data/test12.ui
new file mode 100644
index 0000000000..865dfb41c4
--- /dev/null
+++ b/testsuite/tools/simplify-data/test12.ui
@@ -0,0 +1,14 @@
+
+
+
+
+ end
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test13.expected b/testsuite/tools/simplify-data/test13.expected
new file mode 100644
index 0000000000..ef4a037789
--- /dev/null
+++ b/testsuite/tools/simplify-data/test13.expected
@@ -0,0 +1,20 @@
+
+
+
+
+
+ end
+
+
+
+
+ center
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test13.ui b/testsuite/tools/simplify-data/test13.ui
new file mode 100644
index 0000000000..b8a1397938
--- /dev/null
+++ b/testsuite/tools/simplify-data/test13.ui
@@ -0,0 +1,19 @@
+
+
+
+
+ end
+
+
+
+
+ center
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test5.expected b/testsuite/tools/simplify-data/test5.expected
index 24b18f4a52..73d04161ec 100644
--- a/testsuite/tools/simplify-data/test5.expected
+++ b/testsuite/tools/simplify-data/test5.expected
@@ -1,12 +1,12 @@
-
+
-
+
diff --git a/testsuite/tools/simplify-data/test8.expected b/testsuite/tools/simplify-data/test8.expected
new file mode 100644
index 0000000000..8862b26584
--- /dev/null
+++ b/testsuite/tools/simplify-data/test8.expected
@@ -0,0 +1,10 @@
+
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test8.ui b/testsuite/tools/simplify-data/test8.ui
new file mode 100644
index 0000000000..ef4f5061a8
--- /dev/null
+++ b/testsuite/tools/simplify-data/test8.ui
@@ -0,0 +1,9 @@
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test9.expected b/testsuite/tools/simplify-data/test9.expected
new file mode 100644
index 0000000000..1eb645aa4c
--- /dev/null
+++ b/testsuite/tools/simplify-data/test9.expected
@@ -0,0 +1,10 @@
+
+
+
+
+
+ start
+
+
+
+
diff --git a/testsuite/tools/simplify-data/test9.ui b/testsuite/tools/simplify-data/test9.ui
new file mode 100644
index 0000000000..fa3ee56d95
--- /dev/null
+++ b/testsuite/tools/simplify-data/test9.ui
@@ -0,0 +1,9 @@
+
+
+
+
+ start
+
+
+
+
diff --git a/tools/gtk-builder-tool-simplify.c b/tools/gtk-builder-tool-simplify.c
index b66b4143ce..d279aa526f 100644
--- a/tools/gtk-builder-tool-simplify.c
+++ b/tools/gtk-builder-tool-simplify.c
@@ -1278,6 +1278,114 @@ rewrite_paned (Element *element,
rewrite_paned_child (element, data, child2, "end-child");
}
+static void
+replace_child_by_property (Element *element,
+ Element *child,
+ const char *property,
+ MyParserData *data)
+{
+ Element *obj, *elt;
+
+ obj = child->children->data;
+ g_assert (obj && g_str_equal (obj->element_name, "object"));
+ child->children = g_list_remove (child->children, obj);
+
+ elt = g_new0 (Element, 1);
+ elt->parent = element;
+ elt->element_name = g_strdup ("property");
+ elt->attribute_names = g_new0 (char *, 2);
+ elt->attribute_names[0] = g_strdup ("name");
+ elt->attribute_values = g_new0 (char *, 2);
+ elt->attribute_values[0] = g_strdup (property);
+ elt->children = g_list_prepend (NULL, obj);
+
+ for (GList *l = element->children; l; l = l->next)
+ {
+ if (l->data == child)
+ {
+ l->data = elt;
+ elt = NULL;
+ free_element (child);
+ break;
+ }
+ }
+
+ g_assert (elt == NULL);
+}
+
+static void
+rewrite_start_end_children (Element *element,
+ MyParserData *data)
+{
+ Element *start_child = NULL;
+ Element *end_child = NULL;
+ GList *l;
+
+ for (l = element->children; l; l = l->next)
+ {
+ Element *child = l->data;
+
+ if (!g_str_equal (child->element_name, "child"))
+ continue;
+
+ if (has_attribute (child, "type", "start"))
+ start_child = child;
+ else if (has_attribute (child, "type", "end"))
+ end_child = child;
+ else if (start_child == NULL)
+ start_child = child;
+ else if (end_child == NULL)
+ end_child = child;
+ else
+ g_warning ("%s only accepts two children", get_class_name (element));
+ }
+
+ if (start_child)
+ replace_child_by_property (element, start_child, "start-child", data);
+
+ if (end_child)
+ replace_child_by_property (element, end_child, "end-child", data);
+}
+
+static void
+rewrite_start_center_end_children (Element *element,
+ MyParserData *data)
+{
+ Element *start_child = NULL;
+ Element *center_child = NULL;
+ Element *end_child = NULL;
+ GList *l;
+
+ for (l = element->children; l; l = l->next)
+ {
+ Element *child = l->data;
+
+ if (has_attribute (child, "type", "start"))
+ start_child = child;
+ else if (has_attribute (child, "type", "center"))
+ center_child = child;
+ else if (has_attribute (child, "type", "end"))
+ end_child = child;
+ else if (start_child == NULL)
+ start_child = child;
+ else if (center_child == NULL)
+ center_child = child;
+ else if (end_child == NULL)
+ end_child = child;
+ else
+ g_warning ("%s only accepts three children", get_class_name (element));
+ }
+
+ if (start_child)
+ replace_child_by_property (element, start_child, "start-widget", data);
+
+ if (center_child)
+ replace_child_by_property (element, center_child, "center-widget", data);
+
+ if (end_child)
+ replace_child_by_property (element, end_child, "end-widget", data);
+}
+
static void
rewrite_dialog (Element *element,
MyParserData *data)
@@ -2004,8 +2112,8 @@ simplify_tree (MyParserData *data)
}
static gboolean
-rewrite_element (Element *element,
- MyParserData *data)
+rewrite_element_3to4 (Element *element,
+ MyParserData *data)
{
GList *l;
@@ -2014,7 +2122,7 @@ rewrite_element (Element *element,
{
GList *next = l->next;
Element *child = l->data;
- if (rewrite_element (child, data))
+ if (rewrite_element_3to4 (child, data))
{
element->children = g_list_remove (element->children, child);
free_element (child);
@@ -2069,6 +2177,52 @@ rewrite_element (Element *element,
g_str_equal (get_class_name (element), "GtkFixed"))
rewrite_fixed (element, data);
+ if (element_is_object_or_template (element) &&
+ g_str_equal (get_class_name (element), "GtkRadioButton"))
+ rewrite_radio_button (element, data);
+
+ if (element_is_object_or_template (element) &&
+ g_str_equal (get_class_name (element), "GtkScale"))
+ rewrite_scale (element, data);
+
+ if (g_str_equal (element->element_name, "property"))
+ maybe_rename_property (element, data);
+
+ if (g_str_equal (element->element_name, "property") &&
+ property_has_been_removed (element, data))
+ return TRUE;
+
+ if (g_str_equal (element->element_name, "requires"))
+ rewrite_requires (element, data);
+
+ return FALSE;
+}
+
+static void
+rewrite_tree_3to4 (MyParserData *data)
+{
+ rewrite_element_3to4 (data->root, data);
+}
+
+static gboolean
+rewrite_element (Element *element,
+ MyParserData *data)
+{
+ GList *l;
+
+ l = element->children;
+ while (l)
+ {
+ GList *next = l->next;
+ Element *child = l->data;
+ if (rewrite_element (child, data))
+ {
+ element->children = g_list_remove (element->children, child);
+ free_element (child);
+ }
+ l = next;
+ }
+
if (element_is_object_or_template (element) &&
(g_str_equal (get_class_name (element), "GtkAspectFrame") ||
g_str_equal (get_class_name (element), "GtkComboBox") ||
@@ -2087,22 +2241,12 @@ rewrite_element (Element *element,
rewrite_bin_child (element, data);
if (element_is_object_or_template (element) &&
- g_str_equal (get_class_name (element), "GtkRadioButton"))
- rewrite_radio_button (element, data);
+ g_str_equal (get_class_name (element), "GtkPaned"))
+ rewrite_start_end_children (element, data);
if (element_is_object_or_template (element) &&
- g_str_equal (get_class_name (element), "GtkScale"))
- rewrite_scale (element, data);
-
- if (g_str_equal (element->element_name, "property"))
- maybe_rename_property (element, data);
-
- if (g_str_equal (element->element_name, "property") &&
- property_has_been_removed (element, data))
- return TRUE;
-
- if (g_str_equal (element->element_name, "requires"))
- rewrite_requires (element, data);
+ g_str_equal (get_class_name (element), "GtkCenterBox"))
+ rewrite_start_center_end_children (element, data);
return FALSE;
}
@@ -2319,8 +2463,10 @@ simplify_file (const char *filename,
if (data.convert3to4)
{
enhance_tree (&data);
- rewrite_tree (&data);
+ rewrite_tree_3to4 (&data);
}
+
+ rewrite_tree (&data);
simplify_tree (&data);
dump_tree (&data);