[orca] Fall back on described-by relation to get description
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fall back on described-by relation to get description
- Date: Sat, 28 Apr 2018 14:42:55 +0000 (UTC)
commit 29cf83f731e73fa3a31710c47361f0f604ded4a7
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Apr 28 10:42:19 2018 -0400
Fall back on described-by relation to get description
src/orca/generator.py | 6 ++++++
src/orca/script_utilities.py | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 2d38f97..bcc565b 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -414,6 +414,12 @@ class Generator:
desc = obj.description.lower()
if not (desc in name.lower() or desc in label.lower()):
result.append(obj.description)
+
+ if not result:
+ desc = self._script.utilities.displayedDescription(obj)
+ if desc:
+ result.append(desc)
+
return result
def _generateLabel(self, obj, **args):
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index b930e88..12c124a 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -82,6 +82,7 @@ class Utilities:
# generatorCache
#
+ DISPLAYED_DESCRIPTION = 'displayedDescription'
DISPLAYED_LABEL = 'displayedLabel'
DISPLAYED_TEXT = 'displayedText'
KEY_BINDING = 'keyBinding'
@@ -436,6 +437,33 @@ class Utilities:
self._script.generatorCache[self.DISPLAYED_LABEL][obj] = labelString
return self._script.generatorCache[self.DISPLAYED_LABEL][obj]
+ def descriptionsForObject(self, obj):
+ """Return a list of objects describing obj."""
+
+ try:
+ relations = obj.getRelationSet()
+ except (LookupError, RuntimeError):
+ msg = 'ERROR: Exception getting relationset for %s' % obj
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return []
+
+ describedBy = lambda x: x.getRelationType() == pyatspi.RELATION_DESCRIBED_BY
+ relation = filter(describedBy, relations)
+ return [r.getTarget(i) for r in relation for i in range(r.getNTargets())]
+
+ def displayedDescription(self, obj):
+ """Returns the text being displayed for the object describing obj."""
+
+ try:
+ return self._script.generatorCache[self.DISPLAYED_DESCRIPTION][obj]
+ except:
+ if self.DISPLAYED_DESCRIPTION not in self._script.generatorCache:
+ self._script.generatorCache[self.DISPLAYED_DESCRIPTION] = {}
+
+ string = " ".join(map(self.displayedText, self.descriptionsForObject(obj)))
+ self._script.generatorCache[self.DISPLAYED_DESCRIPTION][obj] = string
+ return self._script.generatorCache[self.DISPLAYED_DESCRIPTION][obj]
+
def displayedText(self, obj):
"""Returns the text being displayed for an object.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]