diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-05 10:58:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-05 18:33:18 +0200 |
commit | c9e3952e76a9c06d5a1d2f583829ce9eb5b9df64 (patch) | |
tree | 5836f1536e46207f036c97635cd632ae9dbea455 /bin | |
parent | 96fa2f494560bcc90584a458438db688b7f0aa88 (diff) |
lint-ui: check that we only have one has_default==True
Change-Id: Ic61e14c3b98a85a5f05b448db9805ac296c041ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103953
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/lint-ui.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/bin/lint-ui.py b/bin/lint-ui.py index 124e1bf58316..c3344c3a3b51 100755 --- a/bin/lint-ui.py +++ b/bin/lint-ui.py @@ -76,16 +76,23 @@ def check_top_level_widget(element): # lint_assert(border_width.text == BORDER_WIDTH, # "Top level 'border_width' property should be " + BORDER_WIDTH, border_width) - # check that any widget which has 'has-default' also has 'can-default' + # check that + # (*) any widget which has 'has-default' also has 'can-default' + # (*) we have at most one has-default widget + # 'has-default' means that when ENTER is pressed, this widget is triggered, normally the OK button + has_default_count = 0 for widget in element.findall('.//object'): if not widget.attrib['class']: continue - widget_type = widget.attrib['class'] + child_widget_type = widget.attrib['class'] has_defaults = widget.findall("./property[@name='has_default']") if len(has_defaults) > 0 and has_defaults[0].text == "True": + has_default_count += 1 can_defaults = widget.findall("./property[@name='can_default']") lint_assert(len(can_defaults)>0 and can_defaults[0].text == "True", - "has_default without can_default in " + widget_type + " with id = '" + widget.attrib['id'] + "'", widget) + "has_default without can_default in " + child_widget_type + " with id = '" + widget.attrib['id'] + "'", widget) + lint_assert(has_default_count <= 1, + "more than one child with has_default=='True' in top-level widget " + widget_type, element) def check_button_box_spacing(element): spacing = element.findall("property[@name='spacing']") |