[PATCH 1/7] Specify a node id in check_accelerator exceptions
David Shea
dshea at redhat.com
Tue Oct 15 18:16:00 UTC 2013
Changed the format of check_accelerator exceptions to:
<!-- check_accelerators: <conflicting-node-id> -->
Removed the language-specific accelerator exception, since it isn't
useful. Whether widgets are displayed simultaneously or not is not
language dependent.
---
pyanaconda/ui/gui/spokes/source.glade | 2 +-
tests/accelerators/check_accelerators.py | 17 ++++++++++-------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/source.glade b/pyanaconda/ui/gui/spokes/source.glade
index 554d673..8644bc4 100644
--- a/pyanaconda/ui/gui/spokes/source.glade
+++ b/pyanaconda/ui/gui/spokes/source.glade
@@ -693,7 +693,7 @@
</child>
<child>
<object class="GtkButton" id="verifyIsoButton">
- <!-- check_accelerators: not active at same time as verifyMediaButton -->
+ <!-- check_accelerators: verifyMediaButton -->
<property name="label" translatable="yes">_Verify</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
diff --git a/tests/accelerators/check_accelerators.py b/tests/accelerators/check_accelerators.py
index 4361c64..eb990d0 100755
--- a/tests/accelerators/check_accelerators.py
+++ b/tests/accelerators/check_accelerators.py
@@ -59,13 +59,16 @@ class PODict(collections.Mapping):
def __len__(self):
return len(self._dict)
-def is_exception(node, language=None):
- if language:
- comment_str = "check_accelerators(%s)" % language
- else:
- comment_str = "check_accelerators"
+def is_exception(node, conflicting_node, language=None):
+ # Check for a comment of the form
+ # <!-- check_accelerators: <conflicting-node-id> -->
+ # The node passed in is the label property of the widget rather than the
+ # <object> node itself, so we actually want the id attribute of the parent node.
+ for comment in node.xpath("./preceding-sibling::comment()[contains(., 'check_accelerators:')]"):
+ if comment.text.split(":")[1].strip() == conflicting_node.getparent().attrib['id']:
+ return True
- return bool(node.xpath("./parent::*/comment()[contains(., '%s')]" % comment_str))
+ return False
def add_check_accel(glade_filename, accels, label, po_map):
"""Check whether an accelerator conflicts with existing accelerators.
@@ -85,7 +88,7 @@ def add_check_accel(glade_filename, accels, label, po_map):
accel = match.group('accel').lower()
if accel in accels:
# Check for an exception comment
- if is_exception(label, language):
+ if is_exception(label, accels[accel]):
return
if language:
--
1.8.3.1
More information about the anaconda-patches
mailing list