[orca/570658] Work on rhythmbox speech generator



commit 550b498700104f1a72d25b2f6594ecb85b9c5a52
Author: Willie Walker <william walker sun com>
Date:   Sat May 16 20:51:25 2009 -0400

    Work on rhythmbox speech generator
    
    I did what I could without having an MP3 codec.  Will take a look
    at this on my other machine after checking this in.
---
 src/orca/scripts/apps/rhythmbox/Makefile.am        |    1 +
 src/orca/scripts/apps/rhythmbox/formatting.py      |   50 ++++++++++++++++
 src/orca/scripts/apps/rhythmbox/script.py          |   10 ++-
 .../scripts/apps/rhythmbox/speech_generator.py     |   63 +++-----------------
 4 files changed, 67 insertions(+), 57 deletions(-)

diff --git a/src/orca/scripts/apps/rhythmbox/Makefile.am b/src/orca/scripts/apps/rhythmbox/Makefile.am
index 37f07a7..9bbca3e 100644
--- a/src/orca/scripts/apps/rhythmbox/Makefile.am
+++ b/src/orca/scripts/apps/rhythmbox/Makefile.am
@@ -3,6 +3,7 @@ orca_pathdir=$(pyexecdir)
 orca_python_PYTHON = \
 	__init__.py \
 	braille_generator.py \
+	formatting.py \
 	script.py \
 	speech_generator.py
 
diff --git a/src/orca/scripts/apps/rhythmbox/formatting.py b/src/orca/scripts/apps/rhythmbox/formatting.py
new file mode 100644
index 0000000..acdb492
--- /dev/null
+++ b/src/orca/scripts/apps/rhythmbox/formatting.py
@@ -0,0 +1,50 @@
+# Orca
+#
+# Copyright 2006-2009 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+"""Custom formatting for rhythmbox."""
+
+__id__ = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.formatting
+
+formatting = {
+    'speech': {
+        # When the rating widget changes values, it emits an accessible
+        # name changed event. Because it is of ROLE_UNKNOWN, the default
+        # speechgenerator's _getDefaultSpeech handles it. And because
+        # the widget is already focused, it doesn't speak anything. We
+        # want to speak the widget's name as it contains the number of
+        # stars being displayed.
+        #
+        pyatspi.ROLE_UNKNOWN: {
+            'focused': 'labelAndName'
+            },
+    }
+}
+
+class Formatting(orca.formatting.Formatting):
+    def __init__(self, script):
+        orca.formatting.Formatting.__init__(self, script)
+        self.update(formatting)
diff --git a/src/orca/scripts/apps/rhythmbox/script.py b/src/orca/scripts/apps/rhythmbox/script.py
index 933d627..a965800 100644
--- a/src/orca/scripts/apps/rhythmbox/script.py
+++ b/src/orca/scripts/apps/rhythmbox/script.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -22,13 +22,14 @@
 __id__ = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
 import orca.default as default
 
 from speech_generator import SpeechGenerator
 from braille_generator import BrailleGenerator
+from formatting import Formatting
 
 class Script(default.Script):
 
@@ -43,10 +44,13 @@ class Script(default.Script):
     def getBrailleGenerator(self):
         """Returns the braille generator for this script.
         """
-
         return BrailleGenerator(self)
 
     def getSpeechGenerator(self):
         """Returns the speech generator for this script.
         """
         return SpeechGenerator(self)
+
+    def getFormatting(self):
+        """Returns the formatting strings for this script."""
+        return Formatting(self)
diff --git a/src/orca/scripts/apps/rhythmbox/speech_generator.py b/src/orca/scripts/apps/rhythmbox/speech_generator.py
index 8b5eba9..2315613 100644
--- a/src/orca/scripts/apps/rhythmbox/speech_generator.py
+++ b/src/orca/scripts/apps/rhythmbox/speech_generator.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -22,72 +22,27 @@
 __id__ = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
-import pyatspi
 import orca.speechgenerator as speechgenerator
 
 class SpeechGenerator(speechgenerator.SpeechGenerator):
-    """Overrides _getSpeechForTableCell to correctly handle the table
+
+    # pylint: disable-msg=W0142
+
+    """Overrides _getRealTableCell to correctly handle the table
     cells in the Library table.
     """
-
     def __init__(self, script):
         speechgenerator.SpeechGenerator.__init__(self, script)
 
-    def _getSpeechForTableCell(self, obj, already_focused):
-        """Get the speech utterances for a single table cell
-
-        Arguments:
-        - obj: the table
-        - already_focused: False if object just received focus
-
-        Returns a list of utterances to be spoken for the object.
-        """
-
+    def _getRealTableCell(self, obj, **args):
         # Check to see if this is a table cell from the Library table.
         # If so, it'll have five children and we are interested in the
         # penultimate one. See bug #512639 for more details.
         #
         if obj.childCount == 5:
             obj = obj[3]
-        return speechgenerator.SpeechGenerator.\
-                    _getSpeechForTableCell(self, obj, already_focused)
-
-    def _getDefaultSpeech(self, obj, already_focused, role=None):
-        """Gets a list of utterances to be spoken for the current
-        object's name, role, and any accelerators.  This is usually the
-        fallback speech generator should no other specialized speech
-        generator exist for this object.
-
-        The default speech will be of the following form:
-
-        label name role availability
-
-        Arguments:
-        - obj: an Accessible
-        - already_focused: False if object just received focus
-        - role: A role that should be used instead of the Accessible's 
-          possible role.
-
-        Returns a list of utterances to be spoken for the object.
-        """
-
-        # When the rating widget changes values, it emits an accessible
-        # name changed event. Because it is of ROLE_UNKNOWN, the default
-        # speechgenerator's _getDefaultSpeech handles it. And because
-        # the widget is already focused, it doesn't speak anything. We
-        # want to speak the widget's name as it contains the number of
-        # stars being displayed.
-        #
-        if obj.getRole() == pyatspi.ROLE_UNKNOWN and already_focused:
-            utterances = self._getSpeechForObjectName(obj)
-            self._debugGenerator("rhythmbox _getDefaultSpeech",
-                                 obj,
-                                 already_focused,
-                                 utterances)
-            return utterances
-
-        return speechgenerator.SpeechGenerator.\
-                        _getDefaultSpeech(self, obj, already_focused, role)
+        return speechgenerator.SpeechGenerator._getRealTableCell(
+            self, obj, **args)



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