[orca] Fix for bug #628842 - Orca speaks newly-focused panels in gnome-panel using the default voice rather



commit 9b2f4e74f9af0d2f680e4a902ee4d748cdcbb90b
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sun Sep 5 19:35:02 2010 -0400

    Fix for bug #628842 - Orca speaks newly-focused panels in gnome-panel using the default voice rather than the system voice

 src/orca/scripts/apps/gnome-panel/Makefile.am      |    3 +-
 src/orca/scripts/apps/gnome-panel/script.py        |    7 ++
 .../scripts/apps/gnome-panel/speech_generator.py   |   62 ++++++++++++++++++++
 3 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/apps/gnome-panel/Makefile.am b/src/orca/scripts/apps/gnome-panel/Makefile.am
index c6fc830..6fb175c 100644
--- a/src/orca/scripts/apps/gnome-panel/Makefile.am
+++ b/src/orca/scripts/apps/gnome-panel/Makefile.am
@@ -2,6 +2,7 @@ orca_pathdir=$(pyexecdir)
 
 orca_python_PYTHON = \
 	__init__.py \
-	script.py
+	script.py \
+	speech_generator.py
 
 orca_pythondir=$(pyexecdir)/orca/scripts/apps/gnome-panel
diff --git a/src/orca/scripts/apps/gnome-panel/script.py b/src/orca/scripts/apps/gnome-panel/script.py
index e33b101..72090b8 100644
--- a/src/orca/scripts/apps/gnome-panel/script.py
+++ b/src/orca/scripts/apps/gnome-panel/script.py
@@ -31,6 +31,8 @@ import orca.debug as debug
 import orca.speech as speech
 import pyatspi
 
+from speech_generator import SpeechGenerator
+
 ########################################################################
 #                                                                      #
 # The gnome-panel script class.                                        #
@@ -70,6 +72,11 @@ class Script(default.Script):
         
         return listeners
 
+    def getSpeechGenerator(self):
+        """Returns the speech generator for this script."""
+
+        return SpeechGenerator(self)
+
     def onStateChanged(self, event):
         """Called whenever an object's state changes.
 
diff --git a/src/orca/scripts/apps/gnome-panel/speech_generator.py b/src/orca/scripts/apps/gnome-panel/speech_generator.py
new file mode 100644
index 0000000..c2c8884
--- /dev/null
+++ b/src/orca/scripts/apps/gnome-panel/speech_generator.py
@@ -0,0 +1,62 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs.
+#
+# 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 speech generator for gnome-panel."""
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs."
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.settings as settings
+import orca.speech_generator as speech_generator
+
+class SpeechGenerator(speech_generator.SpeechGenerator):
+
+    def __init__(self, script):
+        speech_generator.SpeechGenerator.__init__(self, script)
+
+    def _generateName(self, obj, **args):
+        """Returns an array of strings for use by speech and braille that
+        represent the name of the object.  If the object is directly
+        displaying any text, that text will be treated as the name.
+        Otherwise, the accessible name of the object will be used.  If
+        there is no accessible name, then the description of the
+        object will be used.  This method will return an empty array
+        if nothing can be found.
+        """
+
+        acss = self.voice(speech_generator.DEFAULT)
+        role = args.get('role', obj.getRole())
+        if role == pyatspi.ROLE_FRAME:
+            if settings.onlySpeakDisplayedText:
+                return []
+            else:
+                acss = self.voice(speech_generator.SYSTEM)
+
+        result = speech_generator.SpeechGenerator.\
+            _generateName(self, obj, **args)
+
+        if result:
+            result.extend(acss)
+
+        return result



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