[orca] Make it possible to specify an object and offset for sayAll() and textLines()



commit 83c83883ef1fa41ad1676a0d6f8aa0b92416d000
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sun Jan 18 16:47:31 2015 -0500

    Make it possible to specify an object and offset for sayAll() and textLines()

 src/orca/scripts/default.py                   |   20 +++++++++++---------
 src/orca/scripts/toolkits/Gecko/script.py     |   13 +++++++++----
 src/orca/scripts/toolkits/WebKitGtk/script.py |   11 ++++++-----
 3 files changed, 26 insertions(+), 18 deletions(-)
---
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 7eb57d8..10f1b90 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -1792,7 +1792,7 @@ class Script(script.Script):
 
         return True
 
-    def sayAll(self, inputEvent):
+    def sayAll(self, inputEvent, obj=None, offset=None):
         try:
             clickCount = inputEvent.getClickCount()
         except:
@@ -1822,18 +1822,19 @@ class Script(script.Script):
             speech.speak(utterances)
             return
 
+        obj = obj or orca_state.locusOfFocus
         try:
-            orca_state.locusOfFocus.queryText()
+            text = obj.queryText()
         except NotImplementedError:
-            utterances = self.speechGenerator.generateSpeech(
-                orca_state.locusOfFocus)
-            utterances.extend(self.tutorialGenerator.getTutorial(
-                orca_state.locusOfFocus, False))
+            utterances = self.speechGenerator.generateSpeech(obj)
+            utterances.extend(self.tutorialGenerator.getTutorial(obj, False))
             speech.speak(utterances)
         except AttributeError:
             pass
         else:
-            speech.sayAll(self.textLines(orca_state.locusOfFocus),
+            if offset == None:
+                offset = text.caretOffset
+            speech.sayAll(self.textLines(obj, offset),
                           self.__sayAllProgressCallback)
 
         return True
@@ -3797,7 +3798,7 @@ class Script(script.Script):
                 text = " ".join(utterances)
                 speech.speak(text)
 
-    def textLines(self, obj):
+    def textLines(self, obj, offset=None):
         """Creates a generator that can be used to iterate over each line
         of a text object, starting at the caret offset.
 
@@ -3815,7 +3816,8 @@ class Script(script.Script):
             return
 
         length = text.characterCount
-        offset = text.caretOffset
+        if offset == None:
+            offset = text.caretOffset
 
         # Determine the correct "say all by" mode to use.
         #
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index f58b7b2..9055ac6 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -709,7 +709,7 @@ class Script(default.Script):
                 self._lastCommandWasMouseButton = False
         return consumes
 
-    def textLines(self, obj):
+    def textLines(self, obj, offset=None):
         """Creates a generator that can be used to iterate over each line
         of a text object, starting at the caret offset.
 
@@ -724,6 +724,10 @@ class Script(default.Script):
         sayAllStyle = _settingsManager.getSetting('sayAllStyle')
         sayAllBySentence = sayAllStyle == settings.SAYALL_STYLE_SENTENCE
         [obj, characterOffset] = self.getCaretContext()
+        if offset == None:
+            [obj, characterOffset] = self.getCaretContext()
+        else:
+            characterOffset = offset
 
         done = False
         while not done:
@@ -811,17 +815,18 @@ class Script(default.Script):
                 self.presentLine(obj, offset)
                 self.madeFindAnnouncement = True
 
-    def sayAll(self, inputEvent):
+    def sayAll(self, inputEvent, obj=None, offset=None):
         """Speaks the contents of the document beginning with the present
         location.  Overridden in this script because the sayAll could have
         been started on an object without text (such as an image).
         """
 
         if not self.inDocumentContent():
-            return default.Script.sayAll(self, inputEvent)
+            return default.Script.sayAll(self, inputEvent, obj, offset)
 
         else:
-            speech.sayAll(self.textLines(orca_state.locusOfFocus),
+            obj = obj or orca_state.locusOfFocus
+            speech.sayAll(self.textLines(obj, offset),
                           self.__sayAllProgressCallback)
 
         return True
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 01ba504..99c7f4e 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -512,16 +512,17 @@ class Script(default.Script):
 
         return True
 
-    def sayAll(self, inputEvent):
+    def sayAll(self, inputEvent, obj=None, offset=None):
         """Speaks the contents of the document beginning with the present
         location.  Overridden in this script because the sayAll could have
         been started on an object without text (such as an image).
         """
 
-        if not self.utilities.isWebKitGtk(orca_state.locusOfFocus):
-            return default.Script.sayAll(self, inputEvent)
+        obj = obj or orca_state.locusOfFocus
+        if not self.utilities.isWebKitGtk(obj):
+            return default.Script.sayAll(self, inputEvent, obj, offset)
 
-        speech.sayAll(self.textLines(orca_state.locusOfFocus),
+        speech.sayAll(self.textLines(obj, offset),
                       self.__sayAllProgressCallback)
 
         return True
@@ -547,7 +548,7 @@ class Script(default.Script):
             string, start, end = text.getTextAtOffset(offset, boundary)
         return segments
 
-    def textLines(self, obj):
+    def textLines(self, obj, offset=None):
         """Creates a generator that can be used to iterate over each line
         of a text object, starting at the caret offset.
 


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