[orca/gnome-3-36] Improve presentation of details-for



commit ea7b3a7471743beccb137190e9715dcf5ddb3c78
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Thu Feb 27 12:21:51 2020 +0100

    Improve presentation of details-for
    
    * Prefer displayed text, fall back on role
    * Limit displayed text to five words in case the object provides
      details for a large block of text
    * When an object provides details for multiple objects, separate
      each object out so that it's clear there are multiple objects

 src/orca/scripts/web/speech_generator.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/scripts/web/speech_generator.py b/src/orca/scripts/web/speech_generator.py
index 25a3f3060..1b29963d7 100644
--- a/src/orca/scripts/web/speech_generator.py
+++ b/src/orca/scripts/web/speech_generator.py
@@ -260,12 +260,18 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
             if text and args.get('endOffset') not in [None, text.characterCount]:
                 return []
 
-        objString = lambda x: "%s %s" % (x.name, self.getLocalizedRoleName(x))
-        toPresent = ", ".join(list(map(objString, objs)))
+        result = []
+        objArgs = {'stringType': 'detailsfor', 'mode': args.get('mode')}
+        for o in objs:
+            string = self._script.utilities.displayedText(o) or self.getLocalizedRoleName(o)
+            words = string.split()
+            if len(words) > 5:
+                words = words[0:5] + ['...']
+
+            result.append(self._script.formatting.getString(**objArgs) % " ".join(words))
+            result.extend(self.voice(speech_generator.SYSTEM))
+            result.extend(self._generatePause(o, **objArgs))
 
-        args['stringType'] = 'detailsfor'
-        result = [self._script.formatting.getString(**args) % toPresent]
-        result.extend(self.voice(speech_generator.SYSTEM))
         return result
 
     def _generateLabelOrName(self, obj, **args):


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