[orca] Automatically present details content upon expansion of controlling widget



commit d6917e0fd58b79f89e2328d73367dc9729fcf64e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Sep 5 13:46:29 2018 -0400

    Automatically present details content upon expansion of controlling widget

 src/orca/script_utilities.py | 34 ++++++++++++++++++++++++++++++++++
 src/orca/scripts/default.py  |  4 ++++
 2 files changed, 38 insertions(+)
---
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 064490768..1257ed1b4 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -451,6 +451,40 @@ class Utilities:
         relation = filter(describedBy, relations)
         return [r.getTarget(i) for r in relation for i in range(r.getNTargets())]
 
+    def detailsContentForObject(self, obj):
+        details = self.detailsForObject(obj)
+        return list(map(self.displayedText, details))
+
+    def detailsForObject(self, obj, textOnly=True):
+        """Return a list of objects containing details for obj."""
+
+        try:
+            relations = obj.getRelationSet()
+            role = obj.getRole()
+            state = obj.getState()
+        except (LookupError, RuntimeError):
+            msg = 'ERROR: Exception getting relationset, role, and state for %s' % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return []
+
+        if not state.contains(pyatspi.STATE_EXPANDED):
+            return []
+
+        hasDetails = lambda x: x.getRelationType() == pyatspi.RELATION_DETAILS
+        relation = filter(hasDetails, relations)
+        details = [r.getTarget(i) for r in relation for i in range(r.getNTargets())]
+        if not details and role == pyatspi.ROLE_TOGGLE_BUTTON:
+            details = [child for child in obj]
+
+        if not textOnly:
+            return details
+
+        textObjects = []
+        for detail in details:
+            textObjects.extend(pyatspi.findAllDescendants(detail, self.queryNonEmptyText))
+
+        return textObjects
+
     def displayedDescription(self, obj):
         """Returns the text being displayed for the object describing obj."""
 
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 06c02d86a..d1ee7242a 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -2316,6 +2316,10 @@ class Script(script.Script):
         speech.speak(self.speechGenerator.generateSpeech(obj, alreadyFocused=True))
         self.pointOfReference['expandedChange'] = hash(obj), event.detail1
 
+        details = self.utilities.detailsContentForObject(obj)
+        for detail in details:
+            self.speakMessage(detail, interrupt=False)
+
     def onIndeterminateChanged(self, event):
         """Callback for object:state-changed:indeterminate accessibility events."""
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]