[gtk/matthiasc/builder-requires: 6/7] buildertool: Supplant a requires
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/builder-requires: 6/7] buildertool: Supplant a requires
- Date: Wed, 11 Nov 2020 00:26:33 +0000 (UTC)
commit 7215c7493380157aa4673cb0df2f38c82284c377
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 10 19:19:40 2020 -0500
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.
gtk/tools/gtk-builder-tool-simplify.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 9e3324306d..868d0dc49a 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]