summaryrefslogtreecommitdiffstats
path: root/bin/ui-rules-enforcer.py
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-11-14 16:23:34 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-11-15 11:20:49 +0100
commitfcf0d983801603250aa7ce4539951c6b049ad079 (patch)
treee1c7ec93cd507af0eac563d71d4772e977d577e3 /bin/ui-rules-enforcer.py
parentResolves: tdf#140250 don't share adjustments between differerent spinbuttons (diff)
downloadcore-fcf0d983801603250aa7ce4539951c6b049ad079.tar.gz
core-fcf0d983801603250aa7ce4539951c6b049ad079.zip
add a rule to enforce always-show-image of True if an image is used
If not set, then gtk3 will show the image if there is no text, but only the text if there's an image. For simplicity sake just enforce it as true if an image is referenced. Change-Id: Id4bb9140ba83e7e07e0d8ec5e3c29aece49b9087 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125200 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'bin/ui-rules-enforcer.py')
-rwxr-xr-xbin/ui-rules-enforcer.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/ui-rules-enforcer.py b/bin/ui-rules-enforcer.py
index 718bb82bd35b..fe1709bf36da 100755
--- a/bin/ui-rules-enforcer.py
+++ b/bin/ui-rules-enforcer.py
@@ -486,6 +486,33 @@ def enforce_entry_text_column_id_column_for_gtkcombobox(current):
idcolumn.text = "1"
current.insert(insertpos, idcolumn)
+def enforce_button_always_show_image(current):
+ image = None
+ always_show_image = None
+ isbutton = current.get('class') == "GtkButton"
+ insertpos = 0
+ for child in current:
+ enforce_button_always_show_image(child)
+ if not isbutton:
+ continue
+ if child.tag == "property":
+ insertpos = insertpos + 1;
+ attributes = child.attrib
+ if attributes.get("name") == "always_show_image" or attributes.get("name") == "always-show-image":
+ always_show_image = child
+ elif attributes.get("name") == "image":
+ image = child
+
+ if isbutton and image is not None:
+ if always_show_image == None:
+ always_show_image = etree.Element("property")
+ attributes = always_show_image.attrib
+ attributes["name"] = "always-show-image"
+ always_show_image.text = "True"
+ current.insert(insertpos, always_show_image)
+ else:
+ always_show_image.text = "True"
+
with open(sys.argv[1], encoding="utf-8") as f:
header = f.readline()
f.seek(0)
@@ -521,6 +548,7 @@ remove_double_buffered(root)
remove_skip_pager_hint(root)
remove_toolbutton_focus(root)
enforce_toolbar_can_focus(root)
+enforce_button_always_show_image(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