[gtk/matthiasc/for-master] buildertool: Improve GtkOverlay rewriting
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] buildertool: Improve GtkOverlay rewriting
- Date: Sun, 1 Nov 2020 19:55:06 +0000 (UTC)
commit 0d226e93f57c49dfaff1dc15cbd991bd4e2ca86f
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Nov 1 11:14:03 2020 -0500
buildertool: Improve GtkOverlay rewriting
Translate the GtkOverlay:pass-through child property to
the GtkWidget:measure property, and drop the :index
child property.
gtk/tools/gtk-builder-tool-simplify.c | 63 ++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 3b27833697..ec4e8d5129 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -1810,6 +1810,67 @@ rewrite_scale (Element *element,
}
}
+static void
+rewrite_overlay (Element *element,
+ MyParserData *data)
+{
+ GList *l, *ll;
+
+ for (l = element->children; l; l = l->next)
+ {
+ Element *child = l->data;
+
+ if (g_str_equal (child->element_name, "child"))
+ {
+ Element *object = NULL;
+ Element *packing = NULL;
+
+ for (ll = child->children; ll; ll = ll->next)
+ {
+ Element *elt2 = ll->data;
+
+ if (g_str_equal (elt2->element_name, "object"))
+ object = elt2;
+
+ if (g_str_equal (elt2->element_name, "packing"))
+ packing = elt2;
+ }
+
+ if (object && packing)
+ {
+ child->children = g_list_remove (child->children, packing);
+
+ for (ll = packing->children; ll; ll = ll->next)
+ {
+ Element *elt2 = ll->data;
+
+ if (g_str_equal (elt2->element_name, "property") &&
+ (has_attribute (elt2, "name", "pass-through") ||
+ has_attribute (elt2, "name", "pass_through")))
+ {
+ const char *b = canonical_boolean_value (data, elt2->data);
+ if (g_str_equal (b, "1"))
+ {
+ Element *new_prop = g_new0 (Element, 1);
+ new_prop->element_name = g_strdup ("property");
+ new_prop->attribute_names = g_new0 (char *, 2);
+ new_prop->attribute_names[0] = g_strdup ("name");
+ new_prop->attribute_values = g_new0 (char *, 2);
+ new_prop->attribute_values[0] = g_strdup ("can-target");
+ new_prop->data = g_strdup ("0");
+ new_prop->parent = object;
+ object->children = g_list_prepend (object->children, new_prop);
+ }
+ break;
+ }
+ }
+
+ free_element (packing);
+ }
+ }
+ }
+}
+
/* returns TRUE to remove the element from the parent */
static gboolean
simplify_element (Element *element,
@@ -1922,7 +1983,7 @@ rewrite_element (Element *element,
if (element_is_object_or_template (element) &&
g_str_equal (get_class_name (element), "GtkOverlay"))
- rewrite_layout_props (element, data);
+ rewrite_overlay (element, data);
if (element_is_object_or_template (element) &&
g_str_equal (get_class_name (element), "GtkGrid"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]