[gtk/wip/otte/listview: 158/158] gtk-builder-tool: Minimally validate <binding>
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 158/158] gtk-builder-tool: Minimally validate <binding>
- Date: Tue, 4 Feb 2020 22:33:45 +0000 (UTC)
commit 6f4228b05ad60c33b2079913e23e3431caf280b2
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 18 16:58:10 2019 -0500
gtk-builder-tool: Minimally validate <binding>
Check that the toplevel property name is legit.
gtk/tools/gtk-builder-tool-simplify.c | 37 ++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 4a2229c378..c23d15787f 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -575,7 +575,10 @@ get_class_name (Element *element)
}
else if (g_str_equal (parent->element_name, "template"))
{
- return get_attribute_value (parent, "parent");
+ if (get_attribute_value (parent, "parent"))
+ return get_attribute_value (parent, "parent");
+ else
+ return get_attribute_value (parent, "class");
}
return NULL;
@@ -608,6 +611,19 @@ property_is_boolean (Element *element,
return FALSE;
}
+static void
+warn_missing_property (Element *element,
+ MyParserData *data,
+ const char *class_name,
+ const char *property_name,
+ PropKind kind)
+{
+ const char *kind_str[] = { "", "Packing ", "Cell ", "Layout " };
+
+ g_printerr (_("%s:%d: %sproperty %s::%s not found\n"),
+ data->input_filename, element->line_number, kind_str[kind], class_name, property_name);
+}
+
static gboolean
property_can_be_omitted (Element *element,
MyParserData *data)
@@ -650,18 +666,9 @@ property_can_be_omitted (Element *element,
return FALSE;
pspec = get_property_pspec (data, class_name, property_name, kind);
-
if (pspec == NULL)
{
- const char *kind_str[] = {
- "",
- "Packing ",
- "Cell ",
- "Layout "
- };
-
- g_printerr (_("%s:%d: %sproperty %s::%s not found\n"),
- data->input_filename, element->line_number, kind_str[kind], class_name, property_name);
+ warn_missing_property (element, data, class_name, property_name, kind);
return FALSE;
}
@@ -1508,6 +1515,14 @@ simplify_element (Element *element,
property_can_be_omitted (element, data))
return TRUE;
+ if (g_str_equal (element->element_name, "binding"))
+ {
+ const char *property_name = get_attribute_value (element, "name");
+ const char *class_name = get_class_name (element);
+ if (!get_property_pspec (data, class_name, property_name, PROP_KIND_OBJECT))
+ warn_missing_property (element, data, class_name, property_name, PROP_KIND_OBJECT);
+ }
+
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]