[orca] Support checkable list items



commit d3890f6d1658123bed0134e4b419711a21cd92dc
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Mar 9 14:07:11 2020 -0400

    Support checkable list items
    
    List items in list boxes might have state checkable. We need to look for
    that condition and present it if found.

 src/orca/formatting.py       |  6 +++---
 src/orca/generator.py        |  7 +++++++
 src/orca/speech_generator.py | 10 ++++++++++
 3 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 8e193a50e..0b7b61489 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -307,8 +307,8 @@ formatting = {
             },
         pyatspi.ROLE_LIST_ITEM: {
             'focused': 'expandableState',
-            'unfocused': '(labelOrName or (displayedText + allTextSelection)) + pause + expandableState + 
pause + positionInList + pause + listBoxItemWidgets',
-            'basicWhereAmI': 'label + roleName + pause + (name or displayedText) + pause + positionInList + 
pause + expandableState + (nodeLevel or nestingLevel) + pause'
+            'unfocused': '(labelOrName or (displayedText + allTextSelection)) + checkedStateIfCheckable + 
pause + expandableState + pause + positionInList + pause + listBoxItemWidgets',
+            'basicWhereAmI': 'label + roleName + pause + (name or displayedText) + checkedStateIfCheckable + 
pause + positionInList + pause + expandableState + (nodeLevel or nestingLevel) + pause'
             },
         pyatspi.ROLE_MATH: {
             'unfocused': 'math',
@@ -673,7 +673,7 @@ formatting = {
         pyatspi.ROLE_LIST_ITEM: {
             'focused':   '((substring and ' + BRAILLE_TEXT + ')\
                           or ([Component(obj,\
-                                     asString(label + displayedText + expandableState + roleName + 
availability) + asString(accelerator))]\
+                                     asString(label + displayedText + expandableState + roleName + 
availability) + asString(accelerator), indicator=asString(checkedStateIfCheckable))] \
                           + (nestingLevel and [Region(" " + asString(nestingLevel))])\
                           + (listBoxItemWidgets and ([Region(" ")] + listBoxItemWidgets))))',
             'unfocused': '((substring and ' + BRAILLE_TEXT + ')\
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 3de6edc43..75569cfaf 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -675,6 +675,13 @@ class Generator:
             result.append(indicators[0])
         return result
 
+    def _generateCheckedStateIfCheckable(self, obj, **args):
+        if obj.getState().contains(pyatspi.STATE_CHECKABLE) \
+           or obj.getRole() == pyatspi.ROLE_CHECK_MENU_ITEM:
+            return self._generateCheckedState(obj, **args)
+
+        return []
+
     def _generateMenuItemCheckedState(self, obj, **args):
         """Returns an array of strings for use by speech and braille that
         represent the checked state of the menu item, only if it is
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 46d36ce89..acb917b4d 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -681,6 +681,16 @@ class SpeechGenerator(generator.Generator):
             result.extend(acss)
         return result
 
+    def _generateCheckedStateIfCheckable(self, obj, **args):
+        if _settingsManager.getSetting('onlySpeakDisplayedText'):
+            return []
+
+        acss = self.voice(STATE)
+        result = super()._generateCheckedStateIfCheckable(obj, **args)
+        if result:
+            result.extend(acss)
+        return result
+
     def _generateMenuItemCheckedState(self, obj, **args):
         """Returns an array of strings for use by speech and braille that
         represent the checked state of the menu item, only if it is


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