[orca/570658] Simplify planner script



commit 6513de21c4b9398eb79fb1cb707f8fbe3cb074c2
Author: Willie Walker <william walker sun com>
Date:   Sat May 16 07:47:21 2009 -0400

    Simplify planner script
    
    We want to avoid using isDesiredFocusedItem as much as possible.  This
    change also tries to isolate the change to what's really needed, which
    is getting the label for one of the poorly labelled toggle buttons in
    the UI.
---
 src/orca/scripts/apps/planner/Makefile.am         |    1 -
 src/orca/scripts/apps/planner/formatting.py       |   46 -------------------
 src/orca/scripts/apps/planner/script.py           |    9 ----
 src/orca/scripts/apps/planner/speech_generator.py |   51 ++++++++++++++-------
 4 files changed, 34 insertions(+), 73 deletions(-)

diff --git a/src/orca/scripts/apps/planner/Makefile.am b/src/orca/scripts/apps/planner/Makefile.am
index 817a7df..a9365cd 100644
--- a/src/orca/scripts/apps/planner/Makefile.am
+++ b/src/orca/scripts/apps/planner/Makefile.am
@@ -3,7 +3,6 @@ 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/planner/formatting.py b/src/orca/scripts/apps/planner/formatting.py
deleted file mode 100644
index ca9c074..0000000
--- a/src/orca/scripts/apps/planner/formatting.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# 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 planner."""
-
-__id__ = "$Id$"
-__version__   = "$Revision$"
-__date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
-__license__   = "LGPL"
-
-# pylint: disable-msg=C0301
-
-import pyatspi
-
-import orca.formatting
-
-formatting = {
-    'speech': {
-        pyatspi.ROLE_TOGGLE_BUTTON: {
-            'unfocused': '(isDesiredFocusedItem and _("Display more options") + labelAndName + allTextSelection + roleName + toggleState + availability) or label',
-            'focused': '(isDesiredFocusedItem and toggleState) or label'
-            },
-    }
-}
-
-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/planner/script.py b/src/orca/scripts/apps/planner/script.py
index d63c4d3..decea2d 100644
--- a/src/orca/scripts/apps/planner/script.py
+++ b/src/orca/scripts/apps/planner/script.py
@@ -28,7 +28,6 @@ __license__   = "LGPL"
 import orca.default as default
 
 from braille_generator import BrailleGenerator
-from formatting import Formatting
 from speech_generator import SpeechGenerator
 
 ########################################################################
@@ -47,16 +46,8 @@ class Script(default.Script):
         """
         default.Script.__init__(self, app)
 
-    # This method tries to detect and handle the following cases:
-    # 1) Toolbar: the last toggle button to show 'more options'
-    # 2) Main window: one of the four graphic toggle buttons.
-    #
     def getBrailleGenerator(self):
         return BrailleGenerator(self)
 
     def getSpeechGenerator(self):
         return SpeechGenerator(self)
-
-    def getFormatting(self):
-        """Returns the formatting strings for this script."""
-        return Formatting(self)
diff --git a/src/orca/scripts/apps/planner/speech_generator.py b/src/orca/scripts/apps/planner/speech_generator.py
index 23f2b99..a6df0c4 100644
--- a/src/orca/scripts/apps/planner/speech_generator.py
+++ b/src/orca/scripts/apps/planner/speech_generator.py
@@ -25,29 +25,46 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2006-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
-import orca.speechgenerator as speechgenerator
 import pyatspi
 
+import orca.speechgenerator as speechgenerator
+
+from orca.orca_i18n import _         # for gettext support
+
 class SpeechGenerator(speechgenerator.SpeechGenerator):
 
+    # pylint: disable-msg=W0142
+
     def __init__(self, script):
         speechgenerator.SpeechGenerator.__init__(self, script)
 
-    # We make this to appropiately present ribbon's toggle button in a
-    # toolbar used to display in a menu those options that doesn fill
-    # in toolbar when the application is resized.
-    #
-    # Also for each one of the graphics buttons in the main window
-    #
-    def _getIsDesiredFocusedItem(self, obj, **args):
-        # Application should implement an accessible name in this
-        # component, but until this is made We speech/braille "display
-        # more options" when the focus is in one of these toggle
-        # buttons.
+    def _getLabelAndName(self, obj, **args):
+        """Gets the label and the name if the name is different from the label.
+        """
+        result = []
+
+        # This is the black triangle at the far right of the toolbar.
+        #
+        handleRibbonButton = \
+            obj and not obj.name \
+            and obj.getRole() == pyatspi.ROLE_TOGGLE_BUTTON \
+            and obj.parent.getRole() == pyatspi.ROLE_TOOL_BAR
+
+        # This is one of the Gantt, Tasks, Resources, etc., buttons on the
+        # left hand side of the main window.
         #
-        roleList = [pyatspi.ROLE_TOGGLE_BUTTON, \
-                    pyatspi.ROLE_TOOL_BAR]
-        if self._script.isDesiredFocusedItem(obj, roleList) and not obj.name:
-            return True
+        handleTabButton = \
+            obj and not obj.name \
+            and obj.getRole() == pyatspi.ROLE_TOGGLE_BUTTON \
+            and obj.parent.getRole() == pyatspi.ROLE_FILLER \
+            and len(obj.parent) == 2
+
+        if handleRibbonButton:
+            result.append(_("Display more options"))
+        elif handleTabButton:
+            result.append(self._script.getDisplayedText(obj.parent[1]))
         else:
-            return False
+            result.append(speechgenerator.SpeechGenerator._getLabelAndName(
+                self, obj, **args))
+
+        return result



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