[orca] Fix for bgo#585417 - Allow pauses to be inserted in speech output



commit a24d65cf38cb04e759ac90a93e91b4950e016166
Author: Willie Walker <william walker sun com>
Date:   Fri Jun 12 12:14:51 2009 -0400

    Fix for bgo#585417 - Allow pauses to be inserted in speech output
    
    This also adds pauses before speaking tutorial messages.

 src/orca/formatting.py                        |   22 ++++++++++++----------
 src/orca/scripts/apps/soffice/formatting.py   |    4 ++--
 src/orca/scripts/toolkits/Gecko/formatting.py |    4 ++--
 src/orca/speech.py                            |    5 +++++
 src/orca/speech_generator.py                  |   11 +++++++++++
 5 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 56001a9..52c8cf9 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -31,6 +31,8 @@ import pyatspi
 
 # pylint: disable-msg=C0301
 
+TUTORIAL = '(tutorial and (pause + tutorial) or [])'
+
 formatting = {
     'speech': {
         'prefix': {
@@ -41,8 +43,8 @@ formatting = {
             },
         'suffix': {
             'focused': '[]',
-            'unfocused': 'newNodeLevel + unselectedCell + tutorial',
-            'basicWhereAmI': 'tutorial + description',
+            'unfocused': 'newNodeLevel + unselectedCell + ' + TUTORIAL,
+            'basicWhereAmI': TUTORIAL + ' + description',
             'detailedWhereAmI' : '[]'
             },
         'default': {
@@ -76,7 +78,7 @@ formatting = {
             },
         pyatspi.ROLE_DOCUMENT_FRAME: {
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_EMBEDDED: {
             'focused': 'embedded',
@@ -86,7 +88,7 @@ formatting = {
             'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
             'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection + mnemonic',
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_FRAME: {
             'focused': '[]',
@@ -94,7 +96,7 @@ formatting = {
             },
         pyatspi.ROLE_HEADING: {
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_ICON: {
             'focused': 'labelAndName + imageDescription + roleName',
@@ -137,13 +139,13 @@ formatting = {
             'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
             'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection + mnemonic',
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_PASSWORD_TEXT: {
             'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
             'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection + mnemonic',
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_PROGRESS_BAR: {
             'focused': 'percentage',
@@ -172,7 +174,7 @@ formatting = {
             },
         pyatspi.ROLE_SECTION: {
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_SLIDER: {
             # Ignore the text on the slider.  See bug 340559
@@ -227,13 +229,13 @@ formatting = {
             'focused': 'terminal',
             'unfocused': 'terminal',
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_TEXT: {
             'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
             'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection + mnemonic',
             'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic',
-            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+            'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + ' + TUTORIAL
             },
         pyatspi.ROLE_TOGGLE_BUTTON: {
             'focused': 'toggleState',
diff --git a/src/orca/scripts/apps/soffice/formatting.py b/src/orca/scripts/apps/soffice/formatting.py
index 7b18df3..a3d562a 100644
--- a/src/orca/scripts/apps/soffice/formatting.py
+++ b/src/orca/scripts/apps/soffice/formatting.py
@@ -40,8 +40,8 @@ formatting = {
         #
         'suffix': {
             'focused': '[]',
-            'unfocused': 'newNodeLevel + tutorial',
-            'basicWhereAmI': 'tutorial + description',
+            'unfocused': 'newNodeLevel + ' + orca.formatting.TUTORIAL,
+            'basicWhereAmI': orca.formatting.TUTORIAL + ' + description',
             'detailedWhereAmI' : '[]'
             },
         pyatspi.ROLE_COMBO_BOX: {
diff --git a/src/orca/scripts/toolkits/Gecko/formatting.py b/src/orca/scripts/toolkits/Gecko/formatting.py
index 83a6493..64b5692 100644
--- a/src/orca/scripts/toolkits/Gecko/formatting.py
+++ b/src/orca/scripts/toolkits/Gecko/formatting.py
@@ -37,8 +37,8 @@ formatting = {
     'speech': {
         'suffix': {
             'focused': '[]',
-            'unfocused': 'newNodeLevel + unselectedCell + tutorial',
-            'basicWhereAmI': 'tutorial + description + liveRegionDescription',
+            'unfocused': 'newNodeLevel + unselectedCell + ' + orca.formatting.TUTORIAL,
+            'basicWhereAmI': orca.formatting.TUTORIAL + ' + description + liveRegionDescription',
             'detailedWhereAmI' : '[]'
             },
         'default': {
diff --git a/src/orca/speech.py b/src/orca/speech.py
index 1ef9630..8c000d2 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -38,6 +38,7 @@ import keynames
 import orca
 import orca_state
 import settings
+import speech_generator
 
 from acss import ACSS
 from orca_i18n import _           # for gettext support
@@ -186,6 +187,10 @@ def speak(content, acss=None, interrupt=True):
                     subString += " " + element
                 else:
                     subString = element
+            elif isinstance(element, speech_generator.Pause):
+                if subString:
+                    _speak(subString + ".", acss, interrupt)
+                    subString = None
             else:
                 if subString:
                     _speak(subString, acss, interrupt)
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 15a843c..efbe188 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -52,6 +52,14 @@ def _formatExceptionInfo(maxTBlevel=5):
     excTb = traceback.format_tb(trbk, maxTBlevel)
     return (excName, excArgs, excTb)
 
+class Pause:
+    """A dummy class to indicate we want to insert a pause into an
+    utterance."""
+    def __init__(self):
+        pass
+
+PAUSE = [Pause()]
+
 # [[[WDW - general note -- for all the _generate* methods, it would be great if
 # we could return an empty array if we can determine the method does not
 # apply to the object.  This would allow us to reduce the number of strings
@@ -2106,6 +2114,9 @@ class SpeechGenerator:
     #                                                                   #
     #####################################################################
 
+    def _generatePause(self, obj, **args):
+        return PAUSE
+
     def voice(self, key=None):
         """Returns an array containing a voice.  The key is a value
         to be used to look up the voice in the settings.py:voices



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