orca r4216 - in branches/phase2/src/orca: . plugins



Author: wwalker
Date: Sun Sep 14 21:37:31 2008
New Revision: 4216
URL: http://svn.gnome.org/viewvc/orca?rev=4216&view=rev

Log:
Add Where Am I as a plugin.


Added:
   branches/phase2/src/orca/plugins/where_am_i.py   (contents, props changed)
Modified:
   branches/phase2/src/orca/default.py
   branches/phase2/src/orca/default_bindings.py
   branches/phase2/src/orca/plugins/Makefile.am

Modified: branches/phase2/src/orca/default.py
==============================================================================
--- branches/phase2/src/orca/default.py	(original)
+++ branches/phase2/src/orca/default.py	Sun Sep 14 21:37:31 2008
@@ -54,11 +54,13 @@
         import plugins.debug_actions
         import plugins.speech_parameters
         import plugins.bookmarks
+        import plugins.where_am_i
         
         return script.Script._getPluginClasses(self) \
             + [plugins.debug_actions.Plugin,
                plugins.speech_parameters.Plugin,
-               plugins.bookmarks.Plugin]
+               plugins.bookmarks.Plugin,
+               plugins.where_am_i.Plugin]
 
     def _createObjectEventListeners(self):
         """Sets up the AT-SPI event listeners for this script.
@@ -136,42 +138,6 @@
                 #
                 _("Speaks entire document.")),
 
-            "whereAmIBasicHandler" : input_bindings.Handler(
-                Script._whereAmIBasic,
-                # Translators: the "Where am I" feature of Orca allows
-                # a user to press a key and then have information
-                # about their current context spoken and brailled to
-                # them.  For example, the information may include the
-                # name of the current pushbutton with focus as well as
-                # its mnemonic.
-                #
-                _("Performs the basic where am I operation.")),
-
-            "whereAmIDetailedHandler" : input_bindings.Handler(
-                Script._whereAmIDetailed,
-                # Translators: the "Where am I" feature of Orca allows
-                # a user to press a key and then have information
-                # about their current context spoken and brailled to
-                # them.  For example, the information may include the
-                # name of the current pushbutton with focus as well as
-                # its mnemonic.
-                #
-                _("Performs the detailed where am I operation.")),
-
-            "getTitleHandler" : input_bindings.Handler(
-                Script._getTitle,
-                # Translators: This command will cause the window's
-                # title to be spoken.
-                #
-                _("Speaks the title bar.")),
-
-            "getStatusBarHandler" : input_bindings.Handler(
-                Script._getStatusBar,
-                # Translators: This command will cause the window's
-                # status bar contents to be spoken.
-                #
-                _("Speaks the status bar.")),
-
             "findHandler" : input_bindings.Handler(
                 Script._showFindGUI,
                 # Translators: the Orca "Find" dialog allows a user to
@@ -837,26 +803,6 @@
         """
         log.debug("_sayAll: %s" % inputEvent)
 
-    def _whereAmIBasic(self, inputEvent=None, modifiers=None):
-        """The whereAmIBasic handler.
-        """
-        log.debug("_whereAmIBasic: %s" % inputEvent)
-
-    def _whereAmIDetailed(self, inputEvent=None, modifiers=None):
-        """The whereAmIDetailed handler.
-        """
-        log.debug("_whereAmIDetailed: %s" % inputEvent)
-
-    def _getTitle(self, inputEvent=None, modifiers=None):
-        """The getTitle handler.
-        """
-        log.debug("_getTitle: %s" % inputEvent)
-
-    def _getStatusBar(self, inputEvent=None, modifiers=None):
-        """The getStatusBar handler.
-        """
-        log.debug("_getStatusBar: %s" % inputEvent)
-
     def _showFindGUI(self, inputEvent=None, modifiers=None):
         """The showFindGUI handler.
         """

Modified: branches/phase2/src/orca/default_bindings.py
==============================================================================
--- branches/phase2/src/orca/default_bindings.py	(original)
+++ branches/phase2/src/orca/default_bindings.py	Sun Sep 14 21:37:31 2008
@@ -420,40 +420,6 @@
         "findPreviousHandler"),
 ]
 
-# Desktop where am I keys (and SayAll)
-#    
-desktopWhereAmIKeys = [
-    input_bindings.KeyBinding(
-        "KP_Enter",
-        input_event.defaultModifierMask,
-        input_event.NO_MODIFIER_MASK,
-        "whereAmIBasicHandler", 1),
-
-    input_bindings.KeyBinding(
-        "KP_Enter",
-        input_event.defaultModifierMask,
-        input_event.NO_MODIFIER_MASK,
-        "whereAmIDetailedHandler", 2),
-
-    input_bindings.KeyBinding(
-        "KP_Enter",
-        input_event.defaultModifierMask,
-        input_event.ORCA_MODIFIER_MASK,
-        "getTitleHandler", 1),
-
-    input_bindings.KeyBinding(
-        "KP_Enter",
-        input_event.defaultModifierMask,
-        input_event.ORCA_MODIFIER_MASK,
-        "getStatusBarHandler", 2),
-
-    input_bindings.KeyBinding(
-        "KP_Add",
-        input_event.defaultModifierMask,
-        input_event.NO_MODIFIER_MASK,
-        "sayAllHandler"),
-]
-
 # Laptop flat review keys
 #
 laptopFlatReviewKeys = [
@@ -614,33 +580,15 @@
         "findPreviousHandler"),
 ]
 
-# Laptop where am I keys (and SayAll)
-#    
-laptopWhereAmIKeys = [
-    input_bindings.KeyBinding(
-        "Return",
-        input_event.defaultModifierMask,
-        input_event.ORCA_MODIFIER_MASK,
-        "whereAmIBasicHandler", 1),
-
-    input_bindings.KeyBinding(
-        "Return",
-        input_event.defaultModifierMask,
-        input_event.ORCA_MODIFIER_MASK,
-        "whereAmIDetailedHandler", 2),
-
-    input_bindings.KeyBinding(
-        "slash",
-        input_event.defaultModifierMask,
-        input_event.ORCA_MODIFIER_MASK,
-        "getTitleHandler", 1),
-
+desktopSayAllKeys = [
     input_bindings.KeyBinding(
-        "slash",
+        "KP_Add",
         input_event.defaultModifierMask,
-        input_event.ORCA_MODIFIER_MASK,
-        "getStatusBarHandler", 2),
+        input_event.NO_MODIFIER_MASK,
+        "sayAllHandler"),
+]
 
+laptopSayAllKeys = [
     input_bindings.KeyBinding(
         "semicolon",
         input_event.defaultModifierMask,
@@ -649,8 +597,8 @@
 ]
 
 commonKeys = generalKeys + unboundKeys
-desktopKeys = commonKeys + desktopFlatReviewKeys + desktopWhereAmIKeys
-laptopKeys = commonKeys + laptopFlatReviewKeys + laptopWhereAmIKeys
+desktopKeys = commonKeys + desktopFlatReviewKeys + desktopSayAllKeys
+laptopKeys = commonKeys + laptopFlatReviewKeys + laptopSayAllKeys
 
 import brlapi
 brailleKeys = [

Modified: branches/phase2/src/orca/plugins/Makefile.am
==============================================================================
--- branches/phase2/src/orca/plugins/Makefile.am	(original)
+++ branches/phase2/src/orca/plugins/Makefile.am	Sun Sep 14 21:37:31 2008
@@ -4,7 +4,8 @@
 	__init__.py \
 	bookmarks.py \
 	debug_actions.py \
-	speech_parameters.py
+	speech_parameters.py \
+	where_am_i.py
 
 orca_pythondir=$(pyexecdir)/orca/plugins
 

Added: branches/phase2/src/orca/plugins/where_am_i.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/plugins/where_am_i.py	Sun Sep 14 21:37:31 2008
@@ -0,0 +1,206 @@
+# Copyright 2008 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.
+
+"""A Plugin for providing Where Am I operations.
+"""
+
+__id__        = "$Id$"
+__copyright__ = "Copyright (c) 2008 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import logging
+log = logging.getLogger('orca.plugins.where_am_i')
+
+import orca.input_bindings as input_bindings
+import orca.input_event as input_event
+import orca.plugin as plugin
+
+from orca.orca_i18n import _ # for gettext support
+
+# Desktop where am I keys
+#    
+desktopKeys = [
+    input_bindings.KeyBinding(
+        "KP_Enter",
+        input_event.defaultModifierMask,
+        input_event.NO_MODIFIER_MASK,
+        "whereAmIBasicHandler", 1),
+
+    input_bindings.KeyBinding(
+        "KP_Enter",
+        input_event.defaultModifierMask,
+        input_event.NO_MODIFIER_MASK,
+        "whereAmIDetailedHandler", 2),
+
+    input_bindings.KeyBinding(
+        "KP_Enter",
+        input_event.defaultModifierMask,
+        input_event.ORCA_MODIFIER_MASK,
+        "getTitleHandler", 1),
+
+    input_bindings.KeyBinding(
+        "KP_Enter",
+        input_event.defaultModifierMask,
+        input_event.ORCA_MODIFIER_MASK,
+        "getStatusBarHandler", 2),
+]
+
+# Laptop where am I keys
+#    
+laptopKeys = [
+    input_bindings.KeyBinding(
+        "Return",
+        input_event.defaultModifierMask,
+        input_event.ORCA_MODIFIER_MASK,
+        "whereAmIBasicHandler", 1),
+
+    input_bindings.KeyBinding(
+        "Return",
+        input_event.defaultModifierMask,
+        input_event.ORCA_MODIFIER_MASK,
+        "whereAmIDetailedHandler", 2),
+
+    input_bindings.KeyBinding(
+        "slash",
+        input_event.defaultModifierMask,
+        input_event.ORCA_MODIFIER_MASK,
+        "getTitleHandler", 1),
+
+    input_bindings.KeyBinding(
+        "slash",
+        input_event.defaultModifierMask,
+        input_event.ORCA_MODIFIER_MASK,
+        "getStatusBarHandler", 2),
+]
+
+keys = desktopKeys
+brailleKeys = []
+
+class Plugin(plugin.Plugin):
+    """A plugin for getting debug information.
+    """
+    def __init__(self, owner):
+        """Creates a Plugin for the given script.
+        This method should not be called by anyone except the
+        owner.
+
+        Arguments:
+        - owner: the Script owning this Plugin
+        """
+        plugin.Plugin.__init__(self, owner)
+
+    def _createInputEventHandlers(self):
+        """Defines InputEventHandler fields for this script that can be
+        called by the key and braille bindings.
+        """
+        handlers = plugin.Plugin._createInputEventHandlers(self)
+        handlers.update({
+            "whereAmIBasicHandler" : input_bindings.Handler(
+                Plugin._whereAmIBasic,
+                # Translators: the "Where am I" feature of Orca allows
+                # a user to press a key and then have information
+                # about their current context spoken and brailled to
+                # them.  For example, the information may include the
+                # name of the current pushbutton with focus as well as
+                # its mnemonic.
+                #
+                _("Performs the basic where am I operation.")),
+
+            "whereAmIDetailedHandler" : input_bindings.Handler(
+                Plugin._whereAmIDetailed,
+                # Translators: the "Where am I" feature of Orca allows
+                # a user to press a key and then have information
+                # about their current context spoken and brailled to
+                # them.  For example, the information may include the
+                # name of the current pushbutton with focus as well as
+                # its mnemonic.
+                #
+                _("Performs the detailed where am I operation.")),
+
+            "getTitleHandler" : input_bindings.Handler(
+                Plugin._getTitle,
+                # Translators: This command will cause the window's
+                # title to be spoken.
+                #
+                _("Speaks the title bar.")),
+
+            "getStatusBarHandler" : input_bindings.Handler(
+                Plugin._getStatusBar,
+                # Translators: This command will cause the window's
+                # status bar contents to be spoken.
+                #
+                _("Speaks the status bar.")),
+        })
+        return handlers
+
+    def _createKeyBindings(self, handlers):
+        """Defines the key bindings for this script.
+
+        Returns an instance of input_bindings.KeyBindings.
+        """
+        bindings = plugin.Plugin._createKeyBindings(self, handlers)
+        bindings.extend(keys)
+        return bindings
+
+    def _createBrailleBindings(self, handlers):
+        """Defines the braille bindings for this script.
+
+        Returns an instance of input_bindings.BrailleBindings.
+        """
+        bindings = plugin.Plugin._createBrailleBindings(self, handlers)
+        bindings.extend(brailleKeys)
+        return bindings
+
+    def _whereAmIBasic(self, inputEvent=None, modifiers=None):
+        """The whereAmIBasic handler.
+        """
+        log.debug("_whereAmIBasic: %s" % inputEvent)
+
+    def _whereAmIDetailed(self, inputEvent=None, modifiers=None):
+        """The whereAmIDetailed handler.
+        """
+        log.debug("_whereAmIDetailed: %s" % inputEvent)
+
+    def _getTitle(self, inputEvent=None, modifiers=None):
+        """The getTitle handler.
+        """
+        log.debug("_getTitle: %s" % inputEvent)
+
+    def _getStatusBar(self, inputEvent=None, modifiers=None):
+        """The getStatusBar handler.
+        """
+        log.debug("_getStatusBar: %s" % inputEvent)
+
+if __name__ == "__main__":
+    logging.basicConfig(format="%(name)s %(message)s")
+    log.setLevel(logging.DEBUG)
+
+    import orca.script
+    scrypt = orca.script.Script(None)
+    plugin = Plugin(scrypt)
+    print scrypt
+    print plugin
+
+    plugin.processObjectEvent(None)
+
+    plugin.activate()
+    try:
+        plugin.processObjectEvent(None)
+    except:
+        # Expected since no event was passed in
+        #
+        pass



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