diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-12-18 16:58:10 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-30 19:30:14 -0400 |
commit | f33df84eff9f72a05436abab523f17184d682024 (patch) | |
tree | 41d84710347ba3c3b8122157901a0336dd6ddb03 /gtk/tools | |
parent | 7910271b6c82f0168b94b225e62668af2b5cd895 (diff) | |
download | gtk+-f33df84eff9f72a05436abab523f17184d682024.tar.gz |
gtk-builder-tool: Minimally validate <binding>
Check that the toplevel property name is legit.
Diffstat (limited to 'gtk/tools')
-rw-r--r-- | gtk/tools/gtk-builder-tool-simplify.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c index 375702e72b..6bc65b5015 100644 --- a/gtk/tools/gtk-builder-tool-simplify.c +++ b/gtk/tools/gtk-builder-tool-simplify.c @@ -576,7 +576,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; @@ -609,6 +612,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) @@ -651,18 +667,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; } @@ -1592,6 +1599,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; } |