From 2d55fce23d3f39bc4488fff49cdf1b1b10d88b3f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 30 May 2019 09:20:52 +0200 Subject: [PATCH] builder-tool: Rewrite GtkBuilder templates too --- gtk/tools/gtk-builder-tool-simplify.c | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c index 776496ca4a..f302f0991a 100644 --- a/gtk/tools/gtk-builder-tool-simplify.c +++ b/gtk/tools/gtk-builder-tool-simplify.c @@ -528,12 +528,19 @@ set_attribute_value (Element *element, } } +static gboolean +element_is_object_or_template (Element *element) +{ + return g_str_equal (element->element_name, "object") || + g_str_equal (element->element_name, "template"); +} + static const char * get_class_name (Element *element) { Element *parent = element->parent; - if (g_str_equal (element->element_name, "object")) + if (element_is_object_or_template (element)) parent = element; if (g_str_equal (parent->element_name, "packing")) @@ -1446,48 +1453,48 @@ rewrite_element (Element *element, l = next; } - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkStack")) rewrite_stack (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkAssistant")) rewrite_assistant (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkNotebook")) rewrite_notebook (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && (g_str_equal (get_class_name (element), "GtkActionBar") || g_str_equal (get_class_name (element), "GtkHeaderBar"))) rewrite_pack_type (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkPopoverMenu")) rewrite_child_prop_to_prop (element, data, "submenu", "name"); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkToolbar")) rewrite_child_prop_to_prop (element, data, "expand", "expand-item"); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkToolbar")) rewrite_child_prop_to_prop (element, data, "homogeneous", "homogeneous"); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkPaned")) rewrite_paned (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkOverlay")) rewrite_layout_props (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkGrid")) rewrite_grid_layout (element, data); - if (g_str_equal (element->element_name, "object") && + if (element_is_object_or_template (element) && g_str_equal (get_class_name (element), "GtkFixed")) rewrite_layout_props (element, data);