[orca] Exclude ancestors when getting the labels for an object
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Exclude ancestors when getting the labels for an object
- Date: Thu, 7 May 2020 15:35:51 +0000 (UTC)
commit 4f71223e0ae86404010864dbebbe4b46972a47a5
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Thu May 7 11:32:23 2020 -0400
Exclude ancestors when getting the labels for an object
In some applications/toolkits (e.g. Qt), the group/panel containing
the widgets claims to be labelling its child widgets. If we don't
filter this out, we are in danger of repeating the group label or
even replacing the widget's label with the group label. We already
present the ancestor group as part of the context of widgets, so we
can eliminate it here.
src/orca/script_utilities.py | 45 +++++++++++++++-----------------------------
1 file changed, 15 insertions(+), 30 deletions(-)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 4f814e662..373036f6e 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1713,42 +1713,27 @@ class Utilities:
return [x for x in Utilities._desktop if x is not None]
def labelsForObject(self, obj):
- """Return a list of the objects that are labelling this object.
+ """Return a list of the labels for this object."""
- Argument:
- - obj: the object in question
-
- Returns a list of the objects that are labelling this object.
- """
-
- # For some reason, some objects are labelled by the same thing
- # more than once. Go figure, but we need to check for this.
- #
- label = []
try:
relations = obj.getRelationSet()
except (LookupError, RuntimeError):
msg = 'ERROR: Exception getting relationset for %s' % obj
debug.println(debug.LEVEL_INFO, msg, True)
- return label
-
- allTargets = []
- for relation in relations:
- if relation.getRelationType() == pyatspi.RELATION_LABELLED_BY:
-
- # The object can be labelled by more than one thing, so we just
- # get all the labels (from unique objects) and append them
- # together. An example of such objects live in the "Basic"
- # page of the gnome-accessibility-keyboard-properties app.
- # The "Delay" and "Speed" objects are labelled both by
- # their names and units.
- #
- for i in range(0, relation.getNTargets()):
- target = relation.getTarget(i)
- if not target in allTargets:
- allTargets.append(target)
- label.append(target)
- return label
+ return []
+
+ pred = lambda r: r.getRelationType() == pyatspi.RELATION_LABELLED_BY
+ relations = list(filter(pred, obj.getRelationSet()))
+ if not relations:
+ return []
+
+ r = relations[0]
+ result = set([r.getTarget(i) for i in range(r.getNTargets())])
+
+ def isNotAncestor(acc):
+ return not pyatspi.findAncestor(obj, lambda x: x == acc)
+
+ return list(filter(isNotAncestor, result))
@staticmethod
def linkBasename(obj):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]