summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-06-14 09:14:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-06-14 13:37:45 +0200
commitaf8a4e83e316d8085f97c668f880f465d7067dcb (patch)
tree5a9fc8fcfc93e91cd1b44e775f5c1f0a741ff888 /bin
parent95e986d6fae4e99ac3f1c66911279ab59a7ac1df (diff)
enforce RadioButton active within group consistency
make group leader (the one without a group set) always active and make the group followers always not active Change-Id: I8a9ec45e93bf0786ab2895278521027b428c8403 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117143 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ui-rules-enforcer.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/ui-rules-enforcer.py b/bin/ui-rules-enforcer.py
index bc3561bab1e1..922631d739c3 100755
--- a/bin/ui-rules-enforcer.py
+++ b/bin/ui-rules-enforcer.py
@@ -254,6 +254,37 @@ def enforce_menubutton_indicator_consistency(current):
if status_elem.text != 'x-office-calendar':
status_elem.text = "open-menu-symbolic"
+def enforce_active_in_group_consistency(current):
+ group = None
+ active = None
+ isradiobutton = current.get('class') == "GtkRadioButton"
+ insertpos = 0
+ for child in current:
+ enforce_active_in_group_consistency(child)
+ if not isradiobutton:
+ continue
+ if child.tag == "property":
+ insertpos = insertpos + 1;
+ attributes = child.attrib
+ if attributes.get("name") == "group":
+ group = child
+ if attributes.get("name") == "active":
+ active = child
+
+ if isradiobutton:
+ if active != None and active.text != "True":
+ raise Exception(sys.argv[1] + ': non-standard active value', active.text)
+ if group != None and active != None:
+ # if there is a group then we are not the leader and should not be active
+ current.remove(active)
+ elif group == None and active == None:
+ # if there is no group then we are the leader and should be active
+ active = etree.Element("property")
+ attributes = active.attrib
+ attributes["name"] = "active"
+ active.text = "True"
+ current.insert(insertpos, active)
+
with open(sys.argv[1], encoding="utf-8") as f:
header = f.readline()
f.seek(0)
@@ -277,6 +308,7 @@ remove_check_button_align(root)
remove_track_visited_links(root)
remove_label_fill(root)
enforce_menubutton_indicator_consistency(root)
+enforce_active_in_group_consistency(root)
with open(sys.argv[1], 'wb') as o:
# without encoding='unicode' (and the matching encode("utf8")) we get &#XXXX replacements for non-ascii characters