[orca] Don't calculate a percent for indeterminate progress bars



commit 37d75c16b6a2c53f5c777ccde69def9b3a83e8c7
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Oct 29 13:55:10 2021 +0200

    Don't calculate a percent for indeterminate progress bars
    
    Progress bars implement the value interface which does not allow for
    valuelessness. But a progressbar used as a busy indicator might not
    have a real/known value. Therefore check for the presence of the
    indeterminate state and if found, don't calculate and report a value.

 src/orca/braille_generator.py | 6 +++++-
 src/orca/formatting.py        | 4 ++--
 src/orca/script_utilities.py  | 5 +++++
 3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index 4e5921e7a..65e8efd50 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -397,7 +397,11 @@ class BrailleGenerator(generator.Generator):
            and not self._shouldPresentProgressBarUpdate(obj, **args):
             return []
 
-        return self._generatePercentage(obj, **args)
+        result = self._generatePercentage(obj, **args)
+        if obj == orca_state.locusOfFocus and not result:
+            return ['']
+
+        return result
 
     def _generatePercentage(self, obj, **args):
         percent = self._script.utilities.getValueAsPercent(obj)
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 823e9b4d2..17f87ee37 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -386,8 +386,8 @@ formatting = {
             'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection 
+ ' + MNEMONIC
             },
         pyatspi.ROLE_PROGRESS_BAR: {
-            'focused': 'progressBarIndex + progressBarValue',
-            'unfocused': 'progressBarIndex + labelAndName + progressBarValue'
+            'focused': 'progressBarIndex + (progressBarValue or roleName)',
+            'unfocused': 'progressBarIndex + labelAndName + (progressBarValue or roleName)'
             },
         pyatspi.ROLE_PUSH_BUTTON: {
             'focused': 'expandableState',
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index caa984fa7..a4b16a00b 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1173,6 +1173,11 @@ class Utilities:
         return True, "Not handled by any other case"
 
     def getValueAsPercent(self, obj):
+        if obj.getState().contains(pyatspi.STATE_INDETERMINATE):
+            msg = "INFO: Not calculating value: %s has state indeterminate" % obj
+            debug.println(debug.LEVEL_INFO, msg, True)
+            return None
+
         try:
             value = obj.queryValue()
             minval, val, maxval =  value.minimumValue, value.currentValue, value.maximumValue


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