mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
builder-tool: Convert former bin children
Convert from <child> elements to <property name="child"> for former GtkBin subclasses. Update test results to match.
This commit is contained in:
parent
0ec5a3f0d9
commit
dec5707ca9
@ -1491,6 +1491,56 @@ rewrite_grid_layout (Element *element,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rewrite_bin_child (Element *element,
|
||||
MyParserData *data)
|
||||
{
|
||||
GList *l, *ll;
|
||||
const char *class_name;
|
||||
GType type;
|
||||
|
||||
for (l = element->children; l; l = l->next)
|
||||
{
|
||||
Element *child = l->data;
|
||||
Element *object = NULL;
|
||||
|
||||
if (!g_str_equal (child->element_name, "child") ||
|
||||
has_attribute (child, "type", NULL))
|
||||
continue;
|
||||
|
||||
for (ll = child->children; ll; ll = ll->next)
|
||||
{
|
||||
Element *elem = ll->data;
|
||||
|
||||
if (!g_str_equal (elem->element_name, "object"))
|
||||
continue;
|
||||
|
||||
class_name = get_attribute_value (elem, "class");
|
||||
if (!class_name)
|
||||
continue;
|
||||
|
||||
type = g_type_from_name (class_name);
|
||||
if (!g_type_is_a (type, GTK_TYPE_WIDGET))
|
||||
continue;
|
||||
|
||||
object = elem;
|
||||
}
|
||||
|
||||
if (object)
|
||||
{
|
||||
g_free (child->element_name);
|
||||
g_strfreev (child->attribute_names);
|
||||
g_strfreev (child->attribute_values);
|
||||
child->element_name = g_strdup ("property");
|
||||
child->attribute_names = g_new0 (char *, 2);
|
||||
child->attribute_names[0] = g_strdup ("name");
|
||||
child->attribute_values = g_new0 (char *, 2);
|
||||
child->attribute_values[0] = g_strdup ("child");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* returns TRUE to remove the element from the parent */
|
||||
static gboolean
|
||||
simplify_element (Element *element,
|
||||
@ -1605,6 +1655,23 @@ rewrite_element (Element *element,
|
||||
g_str_equal (get_class_name (element), "GtkFixed"))
|
||||
rewrite_layout_props (element, data);
|
||||
|
||||
if (element_is_object_or_template (element) &&
|
||||
(g_str_equal (get_class_name (element), "GtkAspectFrame") ||
|
||||
g_str_equal (get_class_name (element), "GtkComboBox") ||
|
||||
g_str_equal (get_class_name (element), "GtkComboBoxText") ||
|
||||
g_str_equal (get_class_name (element), "GtkFlowBoxChild") ||
|
||||
g_str_equal (get_class_name (element), "GtkFrame") ||
|
||||
g_str_equal (get_class_name (element), "GtkListBoxRow") ||
|
||||
g_str_equal (get_class_name (element), "GtkOverlay") ||
|
||||
g_str_equal (get_class_name (element), "GtkPopover") ||
|
||||
g_str_equal (get_class_name (element), "GtkPopoverMenu") ||
|
||||
g_str_equal (get_class_name (element), "GtkRevealer") ||
|
||||
g_str_equal (get_class_name (element), "GtkScrolledWindow") ||
|
||||
g_str_equal (get_class_name (element), "GtkSearchBar") ||
|
||||
g_str_equal (get_class_name (element), "GtkViewport") ||
|
||||
g_str_equal (get_class_name (element), "GtkWindow")))
|
||||
rewrite_bin_child (element, data);
|
||||
|
||||
if (g_str_equal (element->element_name, "property"))
|
||||
maybe_rename_property (element, data);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<child>
|
||||
<property name="child">
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="button1">
|
||||
@ -111,6 +111,6 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<child>
|
||||
<property name="child">
|
||||
<object class="GtkNotebook" id="notebook1">
|
||||
<child>
|
||||
<object class="GtkNotebookPage">
|
||||
@ -32,6 +32,6 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<property name="title" translatable="yes">Office Runner</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="window_position">center</property>
|
||||
<child>
|
||||
<property name="child">
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
@ -217,6 +217,6 @@
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<child>
|
||||
<property name="child">
|
||||
<object class="GtkBox" id="box1">
|
||||
<child>
|
||||
<object class="GtkStackSwitcher" id="stackswitcher1">
|
||||
@ -39,6 +39,6 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
|
Loading…
Reference in New Issue
Block a user