[orca/570658] Migrate pidgin script to new speech generator



commit 667c6ae011fcc1ce728b1c6a2128aa141419b6b1
Author: Willie Walker <william walker sun com>
Date:   Tue May 19 11:08:29 2009 -0400

    Migrate pidgin script to new speech generator
---
 src/orca/scripts/apps/pidgin/speech_generator.py |  130 +++++++++-------------
 1 files changed, 52 insertions(+), 78 deletions(-)

diff --git a/src/orca/scripts/apps/pidgin/speech_generator.py b/src/orca/scripts/apps/pidgin/speech_generator.py
index 73da585..82f19c4 100644
--- a/src/orca/scripts/apps/pidgin/speech_generator.py
+++ b/src/orca/scripts/apps/pidgin/speech_generator.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2004-2008 Sun Microsystems Inc.
+# Copyright 2004-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
@@ -17,30 +17,14 @@
 # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
 # Boston MA  02110-1301 USA.
 
-"""Custom script for gaim.  This provides the ability for Orca to
-monitor both the IM input and IM output text areas at the same time.
-
-The following script specific key sequences are supported:
-
-  Insert-h      -  Toggle whether we prefix chat room messages with
-                   the name of the chat room.
-  Insert-[1-9]  -  Speak and braille a previous chat room message.
-"""
-
 __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.settings as settings
 import orca.speechgenerator as speechgenerator
 
-from orca.orca_i18n import _
-from orca.orca_i18n import ngettext  # for ngettext support
-
 ########################################################################
 #                                                                      #
 # Custom SpeechGenerator                                               #
@@ -52,67 +36,57 @@ class SpeechGenerator(speechgenerator.SpeechGenerator):
     to the expanded/collapsed state and node count for the buddy list.
     """
 
+    # pylint: disable-msg=W0142
+
     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 cell
-        - already_focused: False if object just received focus
-
-        Returns a list of utterances to be spoken for the object.
-        """
-
-        utterances = speechgenerator.SpeechGenerator._getSpeechForTableCell( \
-            self, obj, already_focused)
-
-        if not self._script.isInBuddyList(obj):
-            return utterances
-
-        # The Pidgin buddy list consists of two columns. The column which
-        # is set as the expander column and which also contains the node
-        # relationship is hidden.  Hidden columns are not included among
-        # a table's columns.  The hidden object of interest seems to always
-        # immediately precede the visible object.
-        #
-        expanderCell = obj.parent[obj.getIndexInParent() - 1]
-        if not expanderCell:
-            return utterances
-
-        state = expanderCell.getState()
-        if state.contains(pyatspi.STATE_EXPANDABLE):
-            if state.contains(pyatspi.STATE_EXPANDED):
-                # Translators: this represents the state of a node in a tree.
-                # 'expanded' means the children are showing.
-                # 'collapsed' means the children are not showing.
-                #
-                utterances.append(_("expanded"))
-                childNodes = self._script.getChildNodes(expanderCell)
-                children = len(childNodes)
-
-                if not children \
-                   or (settings.speechVerbosityLevel == \
-                       settings.VERBOSITY_LEVEL_VERBOSE):
-                    # Translators: this is the number of items in a layered
-                    # pane or table.
-                    #
-                    itemString = ngettext("%d item",
-                                          "%d items",
-                                          children) % children
-                    utterances.append(itemString)
+    def _getExpandableState(self, obj, **args):
+        result = []
+        if self._script.isInBuddyList(obj):
+            # The Pidgin buddy list consists of two columns. The
+            # column which is set as the expander column and which
+            # also contains the node relationship is hidden.  Hidden
+            # columns are not included among a table's columns.  The
+            # hidden object of interest seems to always immediately
+            # precede the visible object.
+            #
+            expanderCell = obj.parent[obj.getIndexInParent() - 1]
+            if expanderCell:
+                result.extend(
+                    speechgenerator.SpeechGenerator._getExpandableState(
+                        self, expanderCell, **args))
             else:
-                # Translators: this represents the state of a node in a tree.
-                # 'expanded' means the children are showing.
-                # 'collapsed' means the children are not showing.
-                #
-                utterances.append(_("collapsed"))
-
-        self._debugGenerator("gaim._getSpeechForTableCell",
-                             obj,
-                             already_focused,
-                             utterances)
-
-        return utterances
-
+                result.extend(
+                    speechgenerator.SpeechGenerator._getExpandableState(
+                        self, obj, **args))
+        else:
+            result.extend(
+                speechgenerator.SpeechGenerator._getExpandableState(
+                    self, obj, **args))
+        return result
+
+    def _getNumberOfChildren(self, obj, **args):
+        result = []
+        if self._script.isInBuddyList(obj):
+            # The Pidgin buddy list consists of two columns. The
+            # column which is set as the expander column and which
+            # also contains the node relationship is hidden.  Hidden
+            # columns are not included among a table's columns.  The
+            # hidden object of interest seems to always immediately
+            # precede the visible object.
+            #
+            expanderCell = obj.parent[obj.getIndexInParent() - 1]
+            if expanderCell:
+                result.extend(
+                    speechgenerator.SpeechGenerator._getNumberOfChildren(
+                        self, expanderCell, **args))
+            else:
+                result.extend(
+                    speechgenerator.SpeechGenerator._getNumberOfChildren(
+                        self, obj, **args))
+        else:
+            result.extend(
+                speechgenerator.SpeechGenerator._getNumberOfChildren(
+                    self, obj, **args))
+        return result



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