Merge branch 'builder-tool-boxes' into 'master'

builder-tool: Rewrite GtkBox

See merge request GNOME/gtk!2447
This commit is contained in:
Matthias Clasen 2020-08-21 13:22:48 +00:00
commit 9770e064e8
5 changed files with 1906 additions and 23 deletions

View File

@ -1514,6 +1514,160 @@ rewrite_grid_layout (Element *element,
}
}
static Element *
write_box_prop (Element *element,
Element *parent,
const char *name,
const char *value)
{
if (element)
g_free (element->data);
else
{
element = g_new0 (Element, 1);
element->parent = parent;
element->element_name = g_strdup ("property");
element->attribute_names = g_new0 (char *, 2);
element->attribute_names[0] = g_strdup ("name");
element->attribute_values = g_new0 (char *, 2);
element->attribute_values[0] = g_strdup (name);
parent->children = g_list_prepend (parent->children, element);
}
element->data = g_strdup (value);
return element;
}
static void
rewrite_box (Element *element,
MyParserData *data)
{
GList *l, *ll;
GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
if (g_str_equal (get_class_name (element), "GtkVBox"))
write_box_prop (NULL, element, "orientation", "vertical");
if (!g_str_equal (get_class_name (element), "GtkBox"))
set_attribute_value (element, "class", "GtkBox");
for (l = element->children; l; l = l->next)
{
Element *child = l->data;
if (g_str_equal (child->element_name, "property"))
{
if (has_attribute (child, "name", "orientation"))
{
GValue value = G_VALUE_INIT;
if (gtk_builder_value_from_string_type (data->builder,
GTK_TYPE_ORIENTATION,
child->data,
&value,
NULL))
orientation = g_value_get_enum (&value);
}
}
}
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)
{
Element *halign = NULL;
Element *hexpand = NULL;
Element *valign = NULL;
Element *vexpand = NULL;
gboolean expand = FALSE;
gboolean fill = TRUE;
for (ll = object->children; ll; ll = ll->next)
{
Element *elt = ll->data;
if (g_str_equal (elt->element_name, "property"))
{
if (has_attribute (elt, "name", "halign"))
halign = elt;
else if (has_attribute (elt, "name", "hexpand"))
hexpand = elt;
else if (has_attribute (elt, "name", "valign"))
valign = elt;
else if (has_attribute (elt, "name", "vexpand"))
vexpand = elt;
}
}
for (ll = packing->children; ll; ll = ll->next)
{
Element *elt = ll->data;
if (has_attribute (elt, "name", "expand"))
{
GValue value = G_VALUE_INIT;
if (gtk_builder_value_from_string_type (data->builder,
G_TYPE_BOOLEAN,
elt->data,
&value,
NULL))
expand = g_value_get_boolean (&value);
}
if (has_attribute (elt, "name", "fill"))
{
GValue value = G_VALUE_INIT;
if (gtk_builder_value_from_string_type (data->builder,
G_TYPE_BOOLEAN,
elt->data,
&value,
NULL))
fill = g_value_get_boolean (&value);
}
}
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (expand)
hexpand = write_box_prop (hexpand, object, "hexpand", "1");
if (!fill)
halign = write_box_prop (halign, object, "halign", "center");
}
else if (orientation == GTK_ORIENTATION_VERTICAL)
{
if (expand)
vexpand = write_box_prop (vexpand, object, "vexpand", "1");
if (!fill)
valign = write_box_prop (valign, object, "valign", "center");
}
child->children = g_list_remove (child->children, packing);
free_element (packing);
}
}
}
}
static void
rewrite_bin_child (Element *element,
MyParserData *data)
@ -1682,6 +1836,12 @@ rewrite_element (Element *element,
g_str_equal (get_class_name (element), "GtkGrid"))
rewrite_grid_layout (element, data);
if (element_is_object_or_template (element) &&
(g_str_equal (get_class_name (element), "GtkHBox") ||
g_str_equal (get_class_name (element), "GtkVBox") ||
g_str_equal (get_class_name (element), "GtkBox")))
rewrite_box (element, data);
if (element_is_object_or_template (element) &&
g_str_equal (get_class_name (element), "GtkFixed"))
rewrite_layout_props (element, data);

View File

@ -0,0 +1,614 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkWindow">
<property name="child">
<object class="GtkBox">
<property name="can_focus">0</property>
<child>
<object class="GtkBox">
<property name="hexpand">1</property>
<property name="can_focus">0</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="can_focus">0</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
<property name="vexpand">0</property>
<child>
<object class="GtkButton">
<property name="halign">center</property>
<property name="label" translatable="yes">_</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">F</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="halign">center</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">E</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="hexpand">1</property>
<property name="label" translatable="yes">FE</property>
<property name="receives_default">1</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="can_focus">0</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
<property name="vexpand">0</property>
<child>
<object class="GtkButton">
<property name="halign">center</property>
<property name="label" translatable="yes">_</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">F</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="halign">center</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">E</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="hexpand">1</property>
<property name="label" translatable="yes">FE</property>
<property name="receives_default">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="can_focus">0</property>
<property name="vexpand">1</property>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">_</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">F</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="vexpand">1</property>
<property name="label" translatable="yes">E</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">FE</property>
<property name="receives_default">1</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="can_focus">0</property>
<property name="hexpand">0</property>
<property name="vexpand">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">_I</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FI</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="vexpand">1</property>
<property name="label" translatable="yes">EI</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">FEI</property>
<property name="receives_default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_S</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FS</property>
<property name="receives_default">1</property>
<property name="valign">start</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">ES</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">FES</property>
<property name="receives_default">1</property>
<property name="valign">start</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_N</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FN</property>
<property name="receives_default">1</property>
<property name="valign">end</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">EN</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">FEN</property>
<property name="receives_default">1</property>
<property name="valign">end</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_C</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">EC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">FEC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_B</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FB</property>
<property name="receives_default">1</property>
<property name="valign">baseline</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">EB</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="vexpand">1</property>
<property name="label" translatable="yes">FEB</property>
<property name="receives_default">1</property>
<property name="valign">baseline</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="can_focus">0</property>
<property name="hexpand">0</property>
<property name="vexpand">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">_I</property>
<property name="receives_default">1</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FI</property>
<property name="receives_default">1</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">EI</property>
<property name="receives_default">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEI</property>
<property name="receives_default">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_S</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FS</property>
<property name="receives_default">1</property>
<property name="valign">start</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">ES</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FES</property>
<property name="receives_default">1</property>
<property name="valign">start</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_N</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FN</property>
<property name="receives_default">1</property>
<property name="valign">end</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">EN</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEN</property>
<property name="receives_default">1</property>
<property name="valign">end</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_C</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">EC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_B</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FB</property>
<property name="receives_default">1</property>
<property name="valign">baseline</property>
<property name="vexpand">0</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">EB</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEB</property>
<property name="receives_default">1</property>
<property name="valign">baseline</property>
<property name="vexpand">1</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="can_focus">0</property>
<property name="hexpand">0</property>
<property name="vexpand">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">_I</property>
<property name="receives_default">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FI</property>
<property name="receives_default">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">EI</property>
<property name="receives_default">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEI</property>
<property name="receives_default">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_S</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FS</property>
<property name="receives_default">1</property>
<property name="valign">start</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">ES</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FES</property>
<property name="receives_default">1</property>
<property name="valign">start</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_N</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FN</property>
<property name="receives_default">1</property>
<property name="valign">end</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">EN</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEN</property>
<property name="receives_default">1</property>
<property name="valign">end</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_C</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">EC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEC</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_B</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FB</property>
<property name="receives_default">1</property>
<property name="valign">baseline</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">EB</property>
<property name="receives_default">1</property>
<property name="valign">center</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">FEB</property>
<property name="receives_default">1</property>
<property name="valign">baseline</property>
<property name="vexpand">1</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</interface>

File diff suppressed because it is too large Load Diff

View File

@ -12,15 +12,13 @@
<property name="border-width">0</property>
<child>
<object class="GtkFileChooserWidget" id="widget">
<property name="vexpand">1</property>
<property name="orientation">vertical</property>
<signal name="default-size-changed" handler="file_chooser_widget_default_size_changed" swapped="no"/>
<signal name="file-activated" handler="file_chooser_widget_file_activated" swapped="no"/>
<signal name="response-requested" handler="file_chooser_widget_response_requested" swapped="no"/>
<signal name="selection-changed" handler="file_chooser_widget_selection_changed" swapped="no"/>
</object>
<packing>
<property name="expand">1</property>
</packing>
</child>
</object>
</child>

View File

@ -144,10 +144,6 @@
<attribute name="scale" value="1.5"></attribute>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="current_time_label">
@ -157,10 +153,6 @@
<property name="use_markup">1</property>
<property name="wrap">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="better_time_label">
@ -170,10 +162,6 @@
<property name="use_markup">1</property>
<property name="wrap">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<layout>
<property name="column">1</property>
@ -191,10 +179,6 @@
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="run_button">
@ -211,10 +195,6 @@
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</property>