[orca] Implement ability to use structural navigation commands during SayAll
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Implement ability to use structural navigation commands during SayAll
- Date: Tue, 20 Jan 2015 01:15:27 +0000 (UTC)
commit 2c2260c535917957f28a797d014a9b0d008c723c
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Jan 19 20:09:00 2015 -0500
Implement ability to use structural navigation commands during SayAll
Note: This feature is current disabled by default. To enable it,
edit your orca-customizations.py file adding:
import orca.settings
orca.settings.structNavInSayAll = True
src/orca/script.py | 10 ++++++++--
src/orca/scripts/default.py | 11 +++++++++++
src/orca/scripts/toolkits/Gecko/script.py | 10 ++++++++--
.../toolkits/Gecko/structural_navigation.py | 6 ++++++
src/orca/scripts/toolkits/WebKitGtk/script.py | 5 ++++-
src/orca/settings.py | 1 +
src/orca/structural_navigation.py | 16 ++++++++++++++++
7 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/script.py b/src/orca/script.py
index 737cd48..6cc15d0 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -121,6 +121,7 @@ class Script:
self.flatReviewContextClass = flat_review.Context
self.findCommandRun = False
+ self._lastCommandWasStructNav = False
debug.println(debug.LEVEL_FINE, "NEW SCRIPT: %s" % self.name)
@@ -455,18 +456,23 @@ class Script:
user_bindings = user_bindings_map["default"]
consumes = False
+ self._lastCommandWasStructNav = False
if user_bindings:
handler = user_bindings.getInputHandler(keyboardEvent)
if handler \
and handler.function in self.structuralNavigation.functions:
- return self.useStructuralNavigationModel()
+ consumes = self.useStructuralNavigationModel()
+ if consumes:
+ self._lastCommandWasStructNav = True
else:
consumes = handler != None
if not consumes:
handler = self.keyBindings.getInputHandler(keyboardEvent)
if handler \
and handler.function in self.structuralNavigation.functions:
- return self.useStructuralNavigationModel()
+ consumes = self.useStructuralNavigationModel()
+ if consumes:
+ self._lastCommandWasStructNav = True
else:
consumes = handler != None
return consumes
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index e4cb0ff..77e3b78 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -139,6 +139,7 @@ class Script(script.Script):
self._lastWordCheckedForSpelling = ""
self._inSayAll = False
+ self._sayAllIsInterrupted = False
self._sayAllContexts = []
def setupInputEventHandlers(self):
@@ -699,6 +700,8 @@ class Script(script.Script):
def deactivate(self):
"""Called when this script is deactivated."""
+ self._inSayAll = False
+ self._sayAllIsInterrupted = False
self.pointOfReference = {}
def processKeyboardEvent(self, keyboardEvent):
@@ -3065,6 +3068,7 @@ class Script(script.Script):
return
elif progressType == speechserver.SayAllContext.INTERRUPTED:
if isinstance(orca_state.lastInputEvent, input_event.KeyboardEvent):
+ self._sayAllIsInterrupted = True
lastKey = orca_state.lastInputEvent.event_string
if lastKey == "Down" and self._fastForwardSayAll(context):
return
@@ -3083,6 +3087,9 @@ class Script(script.Script):
if text.getNSelections():
text.setSelection(0, context.currentOffset, context.currentOffset)
+ def inSayAll(self):
+ return self._inSayAll or self._sayAllIsInterrupted
+
def echoPreviousSentence(self, obj):
"""Speaks the sentence prior to the caret, as long as there is
a sentence prior to the caret and there is no intervening sentence
@@ -3861,6 +3868,7 @@ class Script(script.Script):
spoken and acss is an ACSS instance for speaking the text.
"""
+ self._sayAllIsInterrupted = False
try:
text = obj.queryText()
except:
@@ -4198,6 +4206,9 @@ class Script(script.Script):
"""Convenience method to present the KeyboardEvent event. Returns True
if we fully present the event; False otherwise."""
+ if not event.isPressedKey():
+ self._sayAllIsInterrupted = False
+
if not orca_state.learnModeEnabled:
if event.shouldEcho == False or event.isOrcaModified():
return False
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index ed02c8d..814d730 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -244,6 +244,8 @@ class Script(default.Script):
def deactivate(self):
"""Called when this script is deactivated."""
+ self._inSayAll = False
+ self._sayAllIsInterrupted = False
self._loadingDocumentContent = False
self._loadingDocumentTime = 0.0
@@ -723,6 +725,8 @@ class Script(default.Script):
spoken and acss is an ACSS instance for speaking the text.
"""
+ self._sayAllIsInterrupted = False
+
sayAllStyle = _settingsManager.getSetting('sayAllStyle')
sayAllBySentence = sayAllStyle == settings.SAYALL_STYLE_SENTENCE
if offset == None:
@@ -876,6 +880,7 @@ class Script(default.Script):
if progressType == speechserver.SayAllContext.INTERRUPTED:
if isinstance(orca_state.lastInputEvent, input_event.KeyboardEvent):
+ self._sayAllIsInterrupted = True
lastKey = orca_state.lastInputEvent.event_string
if lastKey == "Down" and self._fastForwardSayAll(context):
return
@@ -886,8 +891,9 @@ class Script(default.Script):
self._sayAllContents = []
self._sayAllContexts = []
- orca.setLocusOfFocus(None, context.obj, notifyScript=False)
- self.setCaretContext(context.obj, context.currentOffset)
+ if not self._lastCommandWasStructNav:
+ orca.setLocusOfFocus(None, context.obj, notifyScript=False)
+ self.setCaretContext(context.obj, context.currentOffset)
def onCaretMoved(self, event):
"""Callback for object:text-caret-moved accessibility events."""
diff --git a/src/orca/scripts/toolkits/Gecko/structural_navigation.py
b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
index 7bea027..bc7b6ed 100644
--- a/src/orca/scripts/toolkits/Gecko/structural_navigation.py
+++ b/src/orca/scripts/toolkits/Gecko/structural_navigation.py
@@ -142,6 +142,9 @@ class GeckoStructuralNavigation(structural_navigation.StructuralNavigation):
def _presentLine(self, obj, offset):
"""Presents the first line of the object to the user."""
+ if self._presentWithSayAll(obj, offset):
+ return
+
self._script.presentLine(obj, offset)
def _presentObject(self, obj, offset):
@@ -150,6 +153,9 @@ class GeckoStructuralNavigation(structural_navigation.StructuralNavigation):
if not obj:
return
+ if self._presentWithSayAll(obj, offset):
+ return
+
if obj.getRole() == pyatspi.ROLE_LINK:
try:
obj.queryComponent().grabFocus()
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 4011933..614436a 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -566,6 +566,7 @@ class Script(default.Script):
spoken and acss is an ACSS instance for speaking the text.
"""
+ self._sayAllIsInterrupted = False
self._inSayAll = False
if not obj:
return
@@ -620,6 +621,7 @@ class Script(default.Script):
text = obj.queryText()
if progressType == speechserver.SayAllContext.INTERRUPTED:
+ self._sayAllIsInterrupted = True
if isinstance(orca_state.lastInputEvent, input_event.KeyboardEvent):
lastKey = orca_state.lastInputEvent.event_string
if lastKey == "Down" and self._fastForwardSayAll(context):
@@ -629,7 +631,8 @@ class Script(default.Script):
self._inSayAll = False
self._sayAllContexts = []
- text.setCaretOffset(offset)
+ if not self._lastCommandWasStructNav:
+ text.setCaretOffset(offset)
return
# SayAllContext.COMPLETED doesn't necessarily mean done with SayAll;
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 03f6015..23a30f7 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -368,3 +368,4 @@ layoutMode = True
# NOTE: The following are experimental and may be changed or removed at
# any time
rewindAndFastForwardInSayAll = False
+structNavInSayAll = False
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index 58602ab..f89b0e2 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -40,8 +40,10 @@ from . import orca
from . import orca_gui_navlist
from . import orca_state
from . import settings
+from . import settings_manager
from . import speech
+_settingsManager = settings_manager.getManager()
#############################################################################
# #
# MatchCriteria #
@@ -1627,6 +1629,9 @@ class StructuralNavigation:
- offset: the character offset within obj.
"""
+ if self._presentWithSayAll(obj, offset):
+ return
+
self._script.updateBraille(obj)
self._script.sayLine(obj)
@@ -1638,6 +1643,9 @@ class StructuralNavigation:
- offset: the character offset within obj.
"""
+ if self._presentWithSayAll(obj, offset):
+ return
+
self._script.updateBraille(obj)
voices = self._script.voices
if obj.getRole() == pyatspi.ROLE_LINK:
@@ -1648,6 +1656,14 @@ class StructuralNavigation:
utterances = self._script.speechGenerator.generateSpeech(obj)
speech.speak(utterances, voice)
+ def _presentWithSayAll(self, obj, offset):
+ if self._script.inSayAll() \
+ and _settingsManager.getSetting('structNavInSayAll'):
+ self._script.sayAll(obj, offset)
+ return True
+
+ return False
+
def _getRoleName(self, obj):
# Another case where we'll do this for now, and clean it up when
# object presentation is refactored.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]