[Libreoffice-commits] core.git: bin/ui-rules-enforcer.py
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 14 11:38:29 UTC 2021
bin/ui-rules-enforcer.py | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
New commits:
commit af8a4e83e316d8085f97c668f880f465d7067dcb
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jun 14 09:14:56 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 14 13:37:45 2021 +0200
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 at redhat.com>
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
More information about the Libreoffice-commits
mailing list