[orca] Temporary, private convenience methods for structural navigation



commit b89ca03e308738b2245c6aa95c845c8db5bbe2b0
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Feb 4 23:23:13 2013 -0500

    Temporary, private convenience methods for structural navigation
    
    These are here today and will hopefully be gone soon. Finishing the
    object presentation refactor will otherwise delay the list of element
    navigation feature.

 src/orca/structural_navigation.py |   75 +++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 4 deletions(-)
---
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index 6bdf651..9980474 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -1766,10 +1766,6 @@ class StructuralNavigation:
         """
 
         self._script.updateBraille(obj)
-
-        # [[[TODO: WDW - move the voice selection to formatting.py
-        # at some point.]]]
-        #
         voices = self._script.voices
         if obj.getRole() == pyatspi.ROLE_LINK:
             voice = voices[settings.HYPERLINK_VOICE]
@@ -1779,6 +1775,77 @@ class StructuralNavigation:
         utterances = self._script.speechGenerator.generateSpeech(obj)
         speech.speak(utterances, voice)
 
+    def _getRoleName(self, obj):
+        # Another case where we'll do this for now, and clean it up when
+        # object presentation is refactored.
+        return self._script.speechGenerator.getLocalizedRoleName(obj)
+
+    def _getSelectedItem(self, obj):
+        # Another case where we'll do this for now, and clean it up when
+        # object presentation is refactored.
+        if obj.getRole() == pyatspi.ROLE_COMBO_BOX:
+            obj = obj[0]
+        try:
+            selection = obj.querySelection()
+        except NotImplementedError:
+            return None
+
+        return selection.getSelectedChild(0)
+
+    def _getText(self, obj):
+        # Another case where we'll do this for now, and clean it up when
+        # object presentation is refactored.
+        text = self._script.utilities.displayedText(obj)
+        if not text:
+            text = self._script.utilities.expandEOCs(obj)
+        if not text:
+            item = self._getSelectedItem(obj)
+            if item:
+                text = item.name
+
+        return text
+
+    def _getLabel(self, obj):
+        # Another case where we'll do this for now, and clean it up when
+        # object presentation is refactored.
+        label = self._script.utilities.displayedLabel(obj)
+        if not label:
+            label = self._script.labelInference.infer(obj, focusedOnly=False)
+
+        return label
+
+    def _getState(self, obj):
+        # Another case where we'll do this for now, and clean it up when
+        # object presentation is refactored.
+        try:
+            state = obj.getState()
+            role = obj.getRole()
+        except RuntimeError:
+            return ''
+
+        # For now, we'll just grab the spoken indicator from settings.
+        # When object presentation is refactored, we can clean this up.
+        if role == pyatspi.ROLE_CHECK_BOX:
+            unchecked, checked, partially = settings.speechCheckboxIndicators
+            if state.contains(pyatspi.STATE_INDETERMINATE):
+                return partially
+            if state.contains(pyatspi.STATE_CHECKED):
+                return checked
+            return unchecked
+
+        if role == pyatspi.ROLE_RADIO_BUTTON:
+            unselected, selected = settings.speechRadioButtonIndicators
+            if state.contains(pyatspi.STATE_CHECKED):
+                return selected
+            return unselected
+
+        return ''
+
+    def _getValue(self, obj):
+        # Another case where we'll do this for now, and clean it up when
+        # object presentation is refactored.
+        return self._getState(obj) or self._getText(obj)
+
     #########################################################################
     #                                                                       #
     # Objects                                                               #



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