summaryrefslogtreecommitdiff
path: root/gtk/tools
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-05-19 23:53:15 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-05-28 20:25:15 +0000
commita65696fc9f298e652d6f8d53e1ed947879ccec3c (patch)
treeeb4c0b687b96ba278e92607319a20f1fa4188263 /gtk/tools
parent25aef96d5d32b52ae9e69fb5914f05b85cd79811 (diff)
downloadgtk+-a65696fc9f298e652d6f8d53e1ed947879ccec3c.tar.gz
builder tool: Handle modal->autohide rename
Add a facility for renamed properties, and use it for GtkPopover::modal.
Diffstat (limited to 'gtk/tools')
-rw-r--r--gtk/tools/gtk-builder-tool-simplify.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 3f4cff4286..776496ca4a 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -216,6 +216,7 @@ keep_for_rewrite (const char *class_name,
const char *property;
PropKind kind;
} props[] = {
+ { "GtkPopover", "modal", PROP_KIND_OBJECT },
{ "GtkActionBar", "pack-type", PROP_KIND_PACKING },
{ "GtkHeaderBar", "pack-type", PROP_KIND_PACKING },
{ "GtkPopoverMenu", "submenu", PROP_KIND_PACKING },
@@ -702,6 +703,59 @@ property_has_been_removed (Element *element,
return found;
}
+static void
+maybe_rename_property (Element *element, MyParserData *data)
+{
+ const gchar *class_name;
+ const gchar *property_name;
+ struct _Prop {
+ const char *class;
+ const char *property;
+ PropKind kind;
+ const char *new_name;
+ } props[] = {
+ { "GtkPopover", "modal", PROP_KIND_OBJECT, "autohide" },
+ };
+ char *canonical_name;
+ int i, k;
+ PropKind kind;
+ int prop_name_index = 0;
+
+ kind = get_prop_kind (element);
+
+ class_name = get_class_name (element);
+ property_name = NULL;
+
+ for (i = 0; element->attribute_names[i]; i++)
+ {
+ if (strcmp (element->attribute_names[i], "name") == 0)
+ {
+ prop_name_index = i;
+ property_name = (const gchar *)element->attribute_values[i];
+ }
+ }
+
+ if (property_name == NULL)
+ return;
+
+ canonical_name = g_strdup (property_name);
+ g_strdelimit (canonical_name, "_", '-');
+
+ for (k = 0; k < G_N_ELEMENTS (props); k++)
+ {
+ if (strcmp (class_name, props[k].class) == 0 &&
+ strcmp (canonical_name, props[k].property) == 0 &&
+ kind == props[k].kind)
+ {
+ g_free (element->attribute_values[prop_name_index]);
+ element->attribute_values[prop_name_index] = g_strdup (props[k].new_name);
+ break;
+ }
+ }
+
+ g_free (canonical_name);
+}
+
static Element *
rewrite_stack_child (Element *child, MyParserData *data)
{
@@ -1437,6 +1491,9 @@ rewrite_element (Element *element,
g_str_equal (get_class_name (element), "GtkFixed"))
rewrite_layout_props (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;