buildertool: Supplant a requires

When we convert a ui file to GTK 4 syntax, we *know*
that it requires GTK 4, so put that in the output.
This commit is contained in:
Matthias Clasen 2020-11-10 19:19:40 -05:00
parent e4be785c6c
commit 7215c74933

View File

@ -62,6 +62,7 @@ typedef struct {
char *output_filename;
FILE *output;
gboolean convert3to4;
gboolean has_gtk_requires;
} MyParserData;
static void
@ -1640,7 +1641,10 @@ rewrite_requires (Element *element,
MyParserData *data)
{
if (has_attribute (element, "lib", "gtk+"))
set_attribute_value (element, "lib", "gtk");
{
set_attribute_value (element, "lib", "gtk");
set_attribute_value (element, "version", "4.0");
}
}
static void
@ -2050,6 +2054,12 @@ enhance_element (Element *element,
{
GList *l;
if (strcmp (element->element_name, "requires") == 0 &&
has_attribute (element, "lib", "gtk+"))
{
data->has_gtk_requires = TRUE;
}
add_old_default_properties (element, data);
for (l = element->children; l; l = l->next)
@ -2057,6 +2067,13 @@ enhance_element (Element *element,
Element *child = l->data;
enhance_element (child, data);
}
if (element == data->root && !data->has_gtk_requires)
{
Element *requires = add_element (element, "requires");
set_attribute_value (requires, "lib", "gtk+");
set_attribute_value (requires, "version", "3.0");
}
}
static void
@ -2144,6 +2161,7 @@ simplify_file (const char *filename,
data.input_filename = filename;
data.output_filename = NULL;
data.convert3to4 = convert3to4;
data.has_gtk_requires = FALSE;
if (replace)
{