[orca] Fix for bug #634642 - Orca can be very slow to find a position in a Gecko list



commit 508c1ae23a0d1ab385d6f6e6972fe28f0ce8cb86
Author: Trevor Saunders <trev saunders gmail com>
Date:   Fri Jan 21 07:58:29 2011 -0500

    Fix for bug #634642 - Orca can be very slow to find a position in a Gecko list

 .../scripts/toolkits/Gecko/speech_generator.py     |   32 ++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/speech_generator.py b/src/orca/scripts/toolkits/Gecko/speech_generator.py
index 4b004a8..b44f252 100644
--- a/src/orca/scripts/toolkits/Gecko/speech_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/speech_generator.py
@@ -549,3 +549,35 @@ class SpeechGenerator(speech_generator.SpeechGenerator):
                                            generateSpeech(self, obj, **args))
             del args['useDefaultFormatting']
         return result
+
+    def getAttribute(self, obj, attributeName):
+        attributes = obj.getAttributes()
+        for attribute in attributes:
+            if attribute.startswith(attributeName):
+                return attribute.split(":")[1]
+
+    def _generatePositionInList(self, obj, **args):
+        position = self.getAttribute(obj, "posinset")
+        total = self.getAttribute(obj, "setsize")
+        if position and total and not obj.getRole() in \
+                [pyatspi.ROLE_MENU_ITEM,
+                 pyatspi.ROLE_TEAROFF_MENU_ITEM,
+                 pyatspi.ROLE_CHECK_MENU_ITEM,
+                 pyatspi.ROLE_RADIO_MENU_ITEM,
+                 pyatspi.ROLE_MENU]:
+            position = int(position)
+            total = int(total)
+            result = []
+            if (_settingsManager.getSetting('enablePositionSpeaking') \
+                or args.get('forceList', False)) \
+                and position >= 0:
+                result.append(self._script.formatting.getString(
+                    mode='speech',
+                    stringType='groupindex') \
+                    % {"index" : position,
+                    "total" : total})
+                result.extend(self.voice(speech_generator.SYSTEM))
+            return result
+        else:
+            return speech_generator.SpeechGenerator._generatePositionInList(
+                self, obj, **args)



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