gtk4-builder-tool: Rewrite Gtk{H,V}Seperator

One less UI element to worry about when migrating from GTK3.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
This commit is contained in:
Guido Günther 2024-10-05 15:16:10 +02:00
parent 1ad5943cd8
commit c86e45c432
3 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GtkSeparator">
<property name="orientation">vertical</property>
</object>
<object class="GtkSeparator"/>
</interface>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkVSeparator">
<property name="visible">True</property>
</object>
<object class="GtkHSeparator">
<property name="visible">True</property>
</object>
</interface>

View File

@ -1935,6 +1935,36 @@ rewrite_scale (Element *element,
}
}
static Element *
write_separator_prop (Element *element,
Element *parent,
const char *name,
const char *value)
{
if (element)
g_free (element->data);
else
{
element = add_element (parent, "property");
set_attribute_value (element, "name", name);
}
element->data = g_strdup (value);
return element;
}
static void
rewrite_separator (Element *element,
MyParserData *data)
{
if (g_str_equal (get_class_name (element), "GtkVSeparator"))
write_separator_prop (NULL, element, "orientation", "vertical");
if (!g_str_equal (get_class_name (element), "GtkSeparator"))
set_attribute_value (element, "class", "GtkSeparator");
}
static void
rewrite_requires (Element *element,
MyParserData *data)
@ -2287,6 +2317,11 @@ rewrite_element_3to4 (Element *element,
g_str_equal (get_class_name (element), "GtkScale"))
rewrite_scale (element, data);
if (element_is_object_or_template (element) &&
(g_str_equal (get_class_name (element), "GtkHSeparator") ||
g_str_equal (get_class_name (element), "GtkVSeparator")))
rewrite_separator(element, data);
if (g_str_equal (element->element_name, "property"))
maybe_rename_property (element, data);