orca r4213 - branches/phase2/src/orca
- From: wwalker svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r4213 - branches/phase2/src/orca
- Date: Sun, 14 Sep 2008 16:53:35 +0000 (UTC)
Author: wwalker
Date: Sun Sep 14 16:53:35 2008
New Revision: 4213
URL: http://svn.gnome.org/viewvc/orca?rev=4213&view=rev
Log:
Work on plugin architecture some more.
Added:
branches/phase2/src/orca/bookmarks_plugin.py (contents, props changed)
branches/phase2/src/orca/debug_plugin.py (contents, props changed)
branches/phase2/src/orca/plugin.py (contents, props changed)
branches/phase2/src/orca/speech_plugin.py (contents, props changed)
Removed:
branches/phase2/src/orca/subscript.py
Modified:
branches/phase2/src/orca/Makefile.am
branches/phase2/src/orca/default.py
branches/phase2/src/orca/default_bindings.py
branches/phase2/src/orca/script.py
Modified: branches/phase2/src/orca/Makefile.am
==============================================================================
--- branches/phase2/src/orca/Makefile.am (original)
+++ branches/phase2/src/orca/Makefile.am Sun Sep 14 16:53:35 2008
@@ -7,8 +7,10 @@
orca_python_PYTHON = \
__init__.py \
+ bookmarks_plugin.py \
braille_monitor.py \
braille.py \
+ debug_plugin.py \
default.py \
default_bindings.py \
input_bindings.py \
@@ -16,10 +18,11 @@
orca_i18n.py \
orca.py \
platform.py \
+ plugin.py \
script_manager.py \
script.py \
settings.py \
- subscript.py \
+ speech_plugin.py \
utils.py
orca_pythondir=$(pyexecdir)/orca
Added: branches/phase2/src/orca/bookmarks_plugin.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/bookmarks_plugin.py Sun Sep 14 16:53:35 2008
@@ -0,0 +1,208 @@
+# 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 handling bookmarks.
+"""
+
+__id__ = "$Id$"
+__copyright__ = "Copyright (c) 2008 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import logging
+log = logging.getLogger('orca.bookmarks_plugin')
+
+import input_bindings
+import input_event
+import plugin
+
+from orca_i18n import _ # for gettext support
+
+# Bookmarking keys
+#
+keys = [
+ input_bindings.KeyBinding(
+ "b",
+ input_event.defaultModifierMask,
+ input_event.ORCA_ALT_MODIFIER_MASK,
+ "saveBookmarks"),
+
+ input_bindings.KeyBinding(
+ "b",
+ input_event.defaultModifierMask,
+ input_event.ORCA_SHIFT_MODIFIER_MASK,
+ "goToPrevBookmark"),
+
+ input_bindings.KeyBinding(
+ "b",
+ input_event.defaultModifierMask,
+ input_event.ORCA_MODIFIER_MASK,
+ "goToNextBookmark"),
+]
+for key in xrange(1, 7):
+ keys.append(
+ input_bindings.KeyBinding(
+ str(key),
+ input_event.defaultModifierMask,
+ input_event.ORCA_ALT_MODIFIER_MASK,
+ "addBookmark"))
+ keys.append(
+ input_bindings.KeyBinding(
+ str(key),
+ input_event.defaultModifierMask,
+ input_event.ORCA_MODIFIER_MASK,
+ "goToBookmark"))
+ keys.append(
+ input_bindings.KeyBinding(
+ str(key),
+ input_event.defaultModifierMask,
+ input_event.SHIFT_ALT_MODIFIER_MASK,
+ "bookmarkCurrentWhereAmI"))
+
+brailleKeys = []
+
+class Plugin(plugin.Plugin):
+ """A plugin for handling bookmarks.
+ """
+ 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({
+ "bookmarkCurrentWhereAmI" : input_bindings.Handler(
+ Plugin._bookmarkCurrentWhereAmI,
+ # Translators: this command announces information regarding
+ # the relationship of the given bookmark to the current
+ # position
+ #
+ _("Bookmark where am I with respect to current position.")),
+
+ "goToBookmark" : input_bindings.Handler(
+ Plugin._goToBookmark,
+ # Translators: this command moves the current position to the
+ # location stored at the bookmark.
+ #
+ _("Go to bookmark.")),
+
+ "addBookmark" : input_bindings.Handler(
+ Plugin._addBookmark,
+ # Translators: this event handler binds an in-page accessible
+ # object location to the given input key command.
+ #
+ _("Add bookmark.")),
+
+ "saveBookmarks" : input_bindings.Handler(
+ Plugin._saveBookmarks,
+ # Translators: this event handler saves all bookmarks for the
+ # current application to disk.
+ #
+ _("Save bookmarks.")),
+
+ "goToNextBookmark" : input_bindings.Handler(
+ Plugin._goToNextBookmark,
+ # Translators: this event handler cycles through the registered
+ # bookmarks and takes the user to the next bookmark location.
+ #
+ _("Go to next bookmark location.")),
+
+ "goToPrevBookmark" : input_bindings.Handler(
+ Plugin._goToPrevBookmark,
+ # Translators: this event handler cycles through the
+ # registered bookmarks and takes the user to the previous
+ # bookmark location.
+ #
+ _("Go to previous bookmark location.")),
+ })
+ 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 _bookmarkCurrentWhereAmI(self, inputEvent=None, modifiers=None):
+ """The bookmarkCurrentWhereAmI handler.
+ """
+ log.debug("_bookmarkCurrentWhereAmI: %s" % inputEvent)
+
+ def _goToBookmark(self, inputEvent=None, modifiers=None):
+ """The goToBookmark handler.
+ """
+ log.debug("_goToBookmark: %s" % inputEvent)
+
+ def _addBookmark(self, inputEvent=None, modifiers=None):
+ """The addBookmark handler.
+ """
+ log.debug("_addBookmark: %s" % inputEvent)
+
+ def _saveBookmarks(self, inputEvent=None, modifiers=None):
+ """The saveBookmarks handler.
+ """
+ log.debug("_saveBookmarks: %s" % inputEvent)
+
+ def _goToNextBookmark(self, inputEvent=None, modifiers=None):
+ """The goToNextBookmark handler.
+ """
+ log.debug("_goToNextBookmark: %s" % inputEvent)
+
+ def _goToPrevBookmark(self, inputEvent=None, modifiers=None):
+ """The goToPrevBookmark handler.
+ """
+ log.debug("_goToPrevBookmark: %s" % inputEvent)
+
+if __name__ == "__main__":
+ logging.basicConfig(format="%(name)s %(message)s")
+ log.setLevel(logging.DEBUG)
+
+ import script
+ scrypt = 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
Added: branches/phase2/src/orca/debug_plugin.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/debug_plugin.py Sun Sep 14 16:53:35 2008
@@ -0,0 +1,184 @@
+# 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 debug operations.
+"""
+
+__id__ = "$Id$"
+__copyright__ = "Copyright (c) 2008 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import logging
+log = logging.getLogger('orca.debug_plugin')
+
+import input_bindings
+import input_event
+import plugin
+
+from orca_i18n import _ # for gettext support
+
+keys = [
+ input_bindings.KeyBinding(
+ "End",
+ input_event.defaultModifierMask,
+ input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
+ "printAppsHandler"),
+
+ input_bindings.KeyBinding(
+ "Page_Up",
+ input_event.defaultModifierMask,
+ input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
+ "printAncestryHandler"),
+
+ input_bindings.KeyBinding(
+ "Page_Down",
+ input_event.defaultModifierMask,
+ input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
+ "printHierarchyHandler"),
+
+ input_bindings.KeyBinding(
+ "Home",
+ input_event.defaultModifierMask,
+ input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
+ "reportScriptInfoHandler"),
+]
+
+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({
+ "printAppsHandler" : input_bindings.Handler(
+ Plugin._printAppsHandler,
+ # Translators: this is a debug message that Orca users
+ # will not normally see. It describes a debug routine
+ # that prints a list of all known applications currently
+ # running on the desktop, to stdout.
+ #
+ _("Prints a debug listing of all known applications to the " \
+ "console where Orca is running.")),
+
+ "printAncestryHandler" : input_bindings.Handler(
+ Plugin._printAncestryHandler,
+ # Translators: this is a debug message that Orca users
+ # will not normally see. It describes a debug routine
+ # that will take the component in the currently running
+ # application that has focus, and print debug information
+ # to the console giving its component ancestry (i.e. all
+ # the components that are its descendants in the component
+ # tree).
+ #
+ _("Prints debug information about the ancestry of the " \
+ "object with focus.")),
+
+ "printHierarchyHandler" : input_bindings.Handler(
+ Plugin._printHierarchyHandler,
+ # Translators: this is a debug message that Orca users
+ # will not normally see. It describes a debug routine
+ # that will take the currently running application, and
+ # print debug information to the console giving its
+ # component hierarchy (i.e. all the components and all
+ # their descendants in the component tree).
+ #
+ _("Prints debug information about the application with " \
+ "focus.")),
+
+ "reportScriptInfoHandler" : input_bindings.Handler(
+ Plugin._reportScriptInfo,
+ # Translators: this is a debug message that Orca users
+ # will not normally see. It describes a debug routine
+ # that outputs useful information on the current script
+ # via speech and braille. This information will be
+ # helpful to script writers.
+ #
+ _("Reports information on current script.")),
+ })
+ 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 _printAppsHandler(self, inputEvent=None, modifiers=None):
+ """The printAppsHandler handler.
+ """
+ log.debug("_printAppsHandler: %s" % inputEvent)
+
+ def _printAncestryHandler(self, inputEvent=None, modifiers=None):
+ """The printAncestryHandler handler.
+ """
+ log.debug("_printAncestryHandler: %s" % inputEvent)
+
+ def _printHierarchyHandler(self, inputEvent=None, modifiers=None):
+ """The printHierarchyHandler handler.
+ """
+ log.debug("_printHierarchyHandler: %s" % inputEvent)
+
+ def _reportScriptInfo(self, inputEvent=None, modifiers=None):
+ """The reportScriptInfo handler.
+ """
+ log.debug("_reportScriptInfo: %s" % inputEvent)
+
+if __name__ == "__main__":
+ logging.basicConfig(format="%(name)s %(message)s")
+ log.setLevel(logging.DEBUG)
+
+ import script
+ scrypt = 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
Modified: branches/phase2/src/orca/default.py
==============================================================================
--- branches/phase2/src/orca/default.py (original)
+++ branches/phase2/src/orca/default.py Sun Sep 14 16:53:35 2008
@@ -46,6 +46,15 @@
"""
script.Script.__init__(self, application)
+ def _addPlugins(self):
+ """Adds various plugins to this script."""
+ import debug_plugin
+ import speech_plugin
+ import bookmarks_plugin
+ self._plugins.append(debug_plugin.Plugin(self))
+ self._plugins.append(speech_plugin.Plugin(self))
+ self._plugins.append(bookmarks_plugin.Plugin(self))
+
def _createObjectEventListeners(self):
"""Sets up the AT-SPI event listeners for this script.
"""
@@ -187,16 +196,6 @@
#
_("Searches for the previous instance of a string.")),
- "showZonesHandler" : input_bindings.Handler(
- Script._showZones,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine that
- # paints rectangles around the interesting (e.g., text)
- # zones in the active window for the application that
- # currently has focus.
- #
- _("Paints and prints the visible zones in the active window.")),
-
"toggleFlatReviewModeHandler" : input_bindings.Handler(
Script._toggleFlatReviewMode,
# Translators: the 'flat review' feature of Orca
@@ -523,16 +522,6 @@
_("Reads the attributes associated with the current text " \
"character.")),
- "reportScriptInfoHandler" : input_bindings.Handler(
- Script._reportScriptInfo,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine
- # that outputs useful information on the current script
- # via speech and braille. This information will be
- # helpful to script writers.
- #
- _("Reports information on current script.")),
-
"brailleCursorKeyHandler" : input_bindings.Handler(
Script._processBrailleCursorKey,
# Translators: a refreshable braille display is an
@@ -617,36 +606,6 @@
#
_("Enters learn mode. Press escape to exit learn mode.")),
- "decreaseSpeechRateHandler" : input_bindings.Handler(
- Script._decreaseSpeechRate,
- # Translators: the speech rate is how fast the speech
- # synthesis engine will generate speech.
- #
- _("Decreases the speech rate.")),
-
- "increaseSpeechRateHandler" : input_bindings.Handler(
- Script._increaseSpeechRate,
- # Translators: the speech rate is how fast the speech
- # synthesis engine will generate speech.
- #
- _("Increases the speech rate.")),
-
- "decreaseSpeechPitchHandler" : input_bindings.Handler(
- Script._decreaseSpeechPitch,
- # Translators: the speech pitch is how high or low in
- # pitch/frequency the speech synthesis engine will
- # generate speech.
- #
- _("Decreases the speech pitch.")),
-
- "increaseSpeechPitchHandler" : input_bindings.Handler(
- Script._increaseSpeechPitch,
- # Translators: the speech pitch is how high or low in
- # pitch/frequency the speech synthesis engine will
- # generate speech.
- #
- _("Increases the speech pitch.")),
-
"quitOrcaHandler" : input_bindings.Handler(
Script._quitOrca,
_("Quits Orca")),
@@ -675,103 +634,6 @@
#
_("Toggles the silencing of speech.")),
- "listAppsHandler" : input_bindings.Handler(
- Script._printAppsHandler,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine
- # that prints a list of all known applications currently
- # running on the desktop, to stdout.
- #
- _("Prints a debug listing of all known applications to the " \
- "console where Orca is running.")),
-
- "printActiveAppHandler" : input_bindings.Handler(
- Script._printActiveAppHandler,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine
- # that prints useful debugging information to the console,
- # for the application that is currently running (has focus).
- #
- _("Prints debug information about the currently active " \
- "application to the console where Orca is running.")),
-
- "printAncestryHandler" : input_bindings.Handler(
- Script._printAncestryHandler,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine
- # that will take the component in the currently running
- # application that has focus, and print debug information
- # to the console giving its component ancestry (i.e. all
- # the components that are its descendants in the component
- # tree).
- #
- _("Prints debug information about the ancestry of the " \
- "object with focus.")),
-
- "printHierarchyHandler" : input_bindings.Handler(
- Script._printHierarchyHandler,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine
- # that will take the currently running application, and
- # print debug information to the console giving its
- # component hierarchy (i.e. all the components and all
- # their descendants in the component tree).
- #
- _("Prints debug information about the application with " \
- "focus.")),
-
- "printMemoryUsageHandler" : input_bindings.Handler(
- Script._printMemoryUsageHandler,
- # Translators: this is a debug message that Orca users
- # will not normally see. It describes a debug routine
- # that will print Orca memory usage information.
- #
- _("Prints memory usage information.")),
-
- "bookmarkCurrentWhereAmI" : input_bindings.Handler(
- Script._bookmarkCurrentWhereAmI,
- # Translators: this command announces information regarding
- # the relationship of the given bookmark to the current
- # position
- #
- _("Bookmark where am I with respect to current position.")),
-
- "goToBookmark" : input_bindings.Handler(
- Script._goToBookmark,
- # Translators: this command moves the current position to the
- # location stored at the bookmark.
- #
- _("Go to bookmark.")),
-
- "addBookmark" : input_bindings.Handler(
- Script._addBookmark,
- # Translators: this event handler binds an in-page accessible
- # object location to the given input key command.
- #
- _("Add bookmark.")),
-
- "saveBookmarks" : input_bindings.Handler(
- Script._saveBookmarks,
- # Translators: this event handler saves all bookmarks for the
- # current application to disk.
- #
- _("Save bookmarks.")),
-
- "goToNextBookmark" : input_bindings.Handler(
- Script._goToNextBookmark,
- # Translators: this event handler cycles through the registered
- # bookmarks and takes the user to the next bookmark location.
- #
- _("Go to next bookmark location.")),
-
- "goToPrevBookmark" : input_bindings.Handler(
- Script._goToPrevBookmark,
- # Translators: this event handler cycles through the
- # registered bookmarks and takes the user to the previous
- # bookmark location.
- #
- _("Go to previous bookmark location.")),
-
"toggleColorEnhancementsHandler" : input_bindings.Handler(
Script._toggleColorEnhancements,
# Translators: "color enhancements" are changes users can
@@ -1005,11 +867,6 @@
"""
log.debug("_findPrevious: %s" % inputEvent)
- def _showZones(self, inputEvent=None, modifiers=None):
- """The showZones handler.
- """
- log.debug("_showZones: %s" % inputEvent)
-
def _toggleFlatReviewMode(self, inputEvent=None, modifiers=None):
"""The toggleFlatReviewMode handler.
"""
@@ -1125,11 +982,6 @@
"""
log.debug("_readCharAttributes: %s" % inputEvent)
- def _reportScriptInfo(self, inputEvent=None, modifiers=None):
- """The reportScriptInfo handler.
- """
- log.debug("_reportScriptInfo: %s" % inputEvent)
-
def _processBrailleCursorKey(self, inputEvent=None, modifiers=None):
"""The brailleCursorKeyHandler handler.
"""
@@ -1160,26 +1012,6 @@
"""
log.debug("_enterLearnMode: %s" % inputEvent)
- def _decreaseSpeechRate(self, inputEvent=None, modifiers=None):
- """The decreaseSpeechRate handler.
- """
- log.debug("_decreaseSpeechRate: %s" % inputEvent)
-
- def _increaseSpeechRate(self, inputEvent=None, modifiers=None):
- """The increaseSpeechRate handler.
- """
- log.debug("_increaseSpeechRate: %s" % inputEvent)
-
- def _decreaseSpeechPitch(self, inputEvent=None, modifiers=None):
- """The decreaseSpeechPitch handler.
- """
- log.debug("_decreaseSpeechPitch: %s" % inputEvent)
-
- def _increaseSpeechPitch(self, inputEvent=None, modifiers=None):
- """The increaseSpeechPitch handler.
- """
- log.debug("_increaseSpeechPitch: %s" % inputEvent)
-
def _quitOrca(self, inputEvent=None, modifiers=None):
"""The quitOrca handler.
"""
@@ -1200,61 +1032,6 @@
"""
log.debug("_toggleSilenceSpeech: %s" % inputEvent)
- def _printAppsHandler(self, inputEvent=None, modifiers=None):
- """The printAppsHandler handler.
- """
- log.debug("_printAppsHandler: %s" % inputEvent)
-
- def _printActiveAppHandler(self, inputEvent=None, modifiers=None):
- """The printActiveAppHandler handler.
- """
- log.debug("_printActiveAppHandler: %s" % inputEvent)
-
- def _printAncestryHandler(self, inputEvent=None, modifiers=None):
- """The printAncestryHandler handler.
- """
- log.debug("_printAncestryHandler: %s" % inputEvent)
-
- def _printHierarchyHandler(self, inputEvent=None, modifiers=None):
- """The printHierarchyHandler handler.
- """
- log.debug("_printHierarchyHandler: %s" % inputEvent)
-
- def _printMemoryUsageHandler(self, inputEvent=None, modifiers=None):
- """The printMemoryUsageHandler handler.
- """
- log.debug("_printMemoryUsageHandler: %s" % inputEvent)
-
- def _bookmarkCurrentWhereAmI(self, inputEvent=None, modifiers=None):
- """The bookmarkCurrentWhereAmI handler.
- """
- log.debug("_bookmarkCurrentWhereAmI: %s" % inputEvent)
-
- def _goToBookmark(self, inputEvent=None, modifiers=None):
- """The goToBookmark handler.
- """
- log.debug("_goToBookmark: %s" % inputEvent)
-
- def _addBookmark(self, inputEvent=None, modifiers=None):
- """The addBookmark handler.
- """
- log.debug("_addBookmark: %s" % inputEvent)
-
- def _saveBookmarks(self, inputEvent=None, modifiers=None):
- """The saveBookmarks handler.
- """
- log.debug("_saveBookmarks: %s" % inputEvent)
-
- def _goToNextBookmark(self, inputEvent=None, modifiers=None):
- """The goToNextBookmark handler.
- """
- log.debug("_goToNextBookmark: %s" % inputEvent)
-
- def _goToPrevBookmark(self, inputEvent=None, modifiers=None):
- """The goToPrevBookmark handler.
- """
- log.debug("_goToPrevBookmark: %s" % inputEvent)
-
def _toggleColorEnhancements(self, inputEvent=None, modifiers=None):
"""The toggleColorEnhancements 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 16:53:35 2008
@@ -82,81 +82,6 @@
"bypassNextCommandHandler"),
]
-# Bookmarking keys
-#
-bookmarkKeys = [
- input_bindings.KeyBinding(
- "b",
- input_event.defaultModifierMask,
- input_event.ORCA_ALT_MODIFIER_MASK,
- "saveBookmarks"),
-
- input_bindings.KeyBinding(
- "b",
- input_event.defaultModifierMask,
- input_event.ORCA_SHIFT_MODIFIER_MASK,
- "goToPrevBookmark"),
-
- input_bindings.KeyBinding(
- "b",
- input_event.defaultModifierMask,
- input_event.ORCA_MODIFIER_MASK,
- "goToNextBookmark"),
-]
-for key in xrange(1, 7):
- bookmarkKeys.append(
- input_bindings.KeyBinding(
- str(key),
- input_event.defaultModifierMask,
- input_event.ORCA_ALT_MODIFIER_MASK,
- "addBookmark"))
- bookmarkKeys.append(
- input_bindings.KeyBinding(
- str(key),
- input_event.defaultModifierMask,
- input_event.ORCA_MODIFIER_MASK,
- "goToBookmark"))
- bookmarkKeys.append(
- input_bindings.KeyBinding(
- str(key),
- input_event.defaultModifierMask,
- input_event.SHIFT_ALT_MODIFIER_MASK,
- "bookmarkCurrentWhereAmI"))
-
-# Debugging keys
-#
-debugKeys = [
- input_bindings.KeyBinding(
- "End",
- input_event.defaultModifierMask,
- input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
- "listAppsHandler"),
-
- input_bindings.KeyBinding(
- "Home",
- input_event.defaultModifierMask,
- input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
- "reportScriptInfoHandler"),
-
- input_bindings.KeyBinding(
- "Page_Up",
- input_event.defaultModifierMask,
- input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
- "printAncestryHandler"),
-
- input_bindings.KeyBinding(
- "Page_Down",
- input_event.defaultModifierMask,
- input_event.ORCA_CTRL_ALT_MODIFIER_MASK,
- "printHierarchyHandler"),
-
- input_bindings.KeyBinding(
- "Num_Lock",
- input_event.defaultModifierMask,
- input_event.ORCA_MODIFIER_MASK,
- "showZonesHandler"),
-]
-
# Unbound keys
#
unboundKeys = [
@@ -164,42 +89,6 @@
"",
input_event.defaultModifierMask,
input_event.NO_MODIFIER_MASK,
- "reportScriptInfoHandler"),
-
- input_bindings.KeyBinding(
- "",
- input_event.defaultModifierMask,
- input_event.NO_MODIFIER_MASK,
- "cycleDebugLevelHandler"),
-
- input_bindings.KeyBinding(
- "",
- input_event.defaultModifierMask,
- input_event.NO_MODIFIER_MASK,
- "decreaseSpeechRateHandler"),
-
- input_bindings.KeyBinding(
- "",
- input_event.defaultModifierMask,
- input_event.NO_MODIFIER_MASK,
- "increaseSpeechRateHandler"),
-
- input_bindings.KeyBinding(
- "",
- input_event.defaultModifierMask,
- input_event.NO_MODIFIER_MASK,
- "decreaseSpeechPitchHandler"),
-
- input_bindings.KeyBinding(
- "",
- input_event.defaultModifierMask,
- input_event.NO_MODIFIER_MASK,
- "increaseSpeechPitchHandler"),
-
- input_bindings.KeyBinding(
- "",
- input_event.defaultModifierMask,
- input_event.NO_MODIFIER_MASK,
"toggleColorEnhancementsHandler"),
input_bindings.KeyBinding(
@@ -759,7 +648,7 @@
"sayAllHandler"),
]
-commonKeys = generalKeys + bookmarkKeys + debugKeys + unboundKeys
+commonKeys = generalKeys + unboundKeys
desktopKeys = commonKeys + desktopFlatReviewKeys + desktopWhereAmIKeys
laptopKeys = commonKeys + laptopFlatReviewKeys + laptopWhereAmIKeys
Added: branches/phase2/src/orca/plugin.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/plugin.py Sun Sep 14 16:53:35 2008
@@ -0,0 +1,84 @@
+# 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 is managed by a Script.
+"""
+
+__id__ = "$Id$"
+__copyright__ = "Copyright (c) 2008 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import logging
+log = logging.getLogger('orca.plugin')
+
+import script
+
+class Plugin(script.Script):
+ """A Plugin is owned and managed by a Script.
+ """
+ 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
+ """
+ self._script = owner
+ script.Script.__init__(self, owner)
+
+ def _completeInit(self):
+ """Completes the __init__ step.
+ """
+ log.debug("NEW PLUGIN: %s" % self)
+
+ def __str__(self):
+ """Returns a human readable representation of the script.
+ """
+ return "plugin %s for %s" % (self.__module__, self._script)
+
+ def getPronunciations(self):
+ """Defines the application specific pronunciations for this script.
+
+ Returns a dictionary where the keys are the actual text strings and
+ the values are the replacement strings that are spoken instead.
+ """
+ return self._script.getPronunciations()
+
+ def getClickCount(self):
+ """Returns the click count of the last input event."""
+ return self._script.getClickCount()
+
+
+if __name__ == "__main__":
+ logging.basicConfig(format="%(name)s %(message)s")
+ log.setLevel(logging.DEBUG)
+
+ scrypt = 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
Modified: branches/phase2/src/orca/script.py
==============================================================================
--- branches/phase2/src/orca/script.py (original)
+++ branches/phase2/src/orca/script.py Sun Sep 14 16:53:35 2008
@@ -66,8 +66,12 @@
Arguments:
- application: the Python Accessible application to create a script for
"""
+ self.application = application
+
self._isActive = False
self.presentIfInactive = False
+
+ self._plugins = []
self._objectEventListeners = self._createObjectEventListeners()
self._inputEventHandlers = self._createInputEventHandlers()
@@ -75,34 +79,37 @@
self._createKeyBindings(self._inputEventHandlers)
self._brailleBindings = \
self._createBrailleBindings(self._inputEventHandlers)
-
- self._name = None
- self.application = application
- self._focus = None
- self._pointOfReference = {}
- self._completeInit(application)
- def _completeInit(self, application):
+ # The object which has the STATE_FOCUS state.
+ #
+ self.focus = None
+
+ # The object of interest. It might be the same as self.focus,
+ # but it might also be something else, such as an active
+ # descendant.
+ #
+ self.locus = {}
+
+ self._completeInit()
+ self._addPlugins()
+
+ def _completeInit(self):
"""Completes the __init__ step.
"""
- if application:
- self._name = self.application.name
- else:
- self._name = "default"
- self._name += " (module=" + self.__module__ + ")"
log.debug("NEW SCRIPT: %s" % self)
def __str__(self):
"""Returns a human readable representation of the script.
"""
- if not self._name:
- if application:
- self._name = self.application.name
- else:
- self._name = "default"
- self._name += " (module=" + self.__module__ + ")"
+ try:
+ name = self.application.name
+ except:
+ name = "None"
+ return "script %s (module=%s)" % (name, self.__module__)
- return self._name
+ def _addPlugins(self):
+ """Adds various plugins to this script."""
+ pass
def _createObjectEventListeners(self):
"""Sets up the AT-SPI event listeners for this script.
@@ -135,7 +142,7 @@
"""
return input_bindings.BrailleBindings(handlers)
- def _getPronunciations(self):
+ def getPronunciations(self):
"""Defines the application specific pronunciations for this script.
Returns a dictionary where the keys are the actual text strings and
@@ -148,6 +155,15 @@
# TODO: implement click count
return 1
+ def getBrailleKeys(self):
+ """Returns the BrlAPI commands this script and all of its plugins
+ care about.
+ """
+ keys = []
+ for binding in self._brailleBindings:
+ keys.append(binding.command)
+ return keys
+
def getInputEventHandlerKey(self, inputEventHandler):
"""Returns the name of the key that contains an inputEventHadler
passed as argument
@@ -176,6 +192,11 @@
keyboardEvent.modifiers,
self.getClickCount())
consumes = handler != None
+ if not consumes:
+ for plugin in self._plugins:
+ consumes = plugin.consumesKeyboardEvent(keyboardEvent)
+ if consumes:
+ break
return consumes
def processKeyboardEvent(self, keyboardEvent):
@@ -193,6 +214,8 @@
self,
keyboardEvent,
keyboardEvent.modifiers)
+ for plugin in self._plugins:
+ plugin.processKeyboardEvent(keyboardEvent)
def consumesBrailleEvent(self, brailleEvent):
"""Called when a key is pressed on the braille display. If we
@@ -212,6 +235,11 @@
0, # TODO: add current keyboard modifiers
self.getClickCount())
consumes = handler != None
+ if not consumes:
+ for plugin in self._plugins:
+ consumes = plugin.consumesBrailleEvent(brailleEvent)
+ if consumes:
+ break
return consumes
def processBrailleEvent(self, brailleEvent):
@@ -233,6 +261,8 @@
self,
brailleEvent,
0) # TODO: add current keyboard modifiers
+ for plugin in self._plugins:
+ plugin.processKeyboardEvent(brailleEvent)
def processObjectEvent(self, event):
"""Processes all AT-SPI object events of interest to this
@@ -265,6 +295,8 @@
for key in self._objectEventListeners.keys():
if event.type.startswith(key):
self._objectEventListeners[key](event)
+ for plugin in self._plugins:
+ plugin.processObjectEvent(event)
def activate(self):
"""Called when this script is activated.
@@ -278,10 +310,13 @@
utils.registerEventListener(eventType)
keys = []
- for binding in self._brailleBindings:
- keys.append(binding.command)
+ for scrypt in [self] + self._plugins:
+ keys += scrypt.getBrailleKeys()
braille.setupKeyRanges(keys)
+ for plugin in self._plugins:
+ plugin.activate()
+
self._isActive = True
log.debug("...%s has been activated" % self)
@@ -294,6 +329,9 @@
log.debug("deactivating %s..." % self)
+ for plugin in self._plugins:
+ plugin.deactivate()
+
for eventType in self._objectEventListeners.keys():
utils.deregisterEventListener(eventType)
Added: branches/phase2/src/orca/speech_plugin.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/speech_plugin.py Sun Sep 14 16:53:35 2008
@@ -0,0 +1,182 @@
+# 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 adjusting speech parameters.
+"""
+
+__id__ = "$Id$"
+__copyright__ = "Copyright (c) 2008 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import logging
+log = logging.getLogger('orca.speech_plugin')
+
+import input_bindings
+import input_event
+import plugin
+
+from orca_i18n import _ # for gettext support
+
+keys = [
+ input_bindings.KeyBinding(
+ "",
+ input_event.defaultModifierMask,
+ input_event.NO_MODIFIER_MASK,
+ "decreaseSpeechRateHandler"),
+
+ input_bindings.KeyBinding(
+ "",
+ input_event.defaultModifierMask,
+ input_event.NO_MODIFIER_MASK,
+ "increaseSpeechRateHandler"),
+
+ input_bindings.KeyBinding(
+ "",
+ input_event.defaultModifierMask,
+ input_event.NO_MODIFIER_MASK,
+ "decreaseSpeechPitchHandler"),
+
+ input_bindings.KeyBinding(
+ "",
+ input_event.defaultModifierMask,
+ input_event.NO_MODIFIER_MASK,
+ "increaseSpeechPitchHandler"),
+]
+
+import brlapi
+brailleKeys = [
+ input_bindings.BrailleBinding(
+ brlapi.KEY_CMD_SAY_FASTER,
+ input_event.NO_MODIFIER_MASK,
+ input_event.NO_MODIFIER_MASK,
+ "increaseSpeechRaterHandler"),
+
+ input_bindings.BrailleBinding(
+ brlapi.KEY_CMD_SAY_SLOWER,
+ input_event.NO_MODIFIER_MASK,
+ input_event.NO_MODIFIER_MASK,
+ "decreaseSpeechRaterHandler"),
+]
+
+class Plugin(plugin.Plugin):
+ """A plugin for adjusting speech parameters.
+ """
+ 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({
+ "decreaseSpeechRateHandler" : input_bindings.Handler(
+ Plugin._decreaseSpeechRate,
+ # Translators: the speech rate is how fast the speech
+ # synthesis engine will generate speech.
+ #
+ _("Decreases the speech rate.")),
+
+ "increaseSpeechRateHandler" : input_bindings.Handler(
+ Plugin._increaseSpeechRate,
+ # Translators: the speech rate is how fast the speech
+ # synthesis engine will generate speech.
+ #
+ _("Increases the speech rate.")),
+
+ "decreaseSpeechPitchHandler" : input_bindings.Handler(
+ Plugin._decreaseSpeechPitch,
+ # Translators: the speech pitch is how high or low in
+ # pitch/frequency the speech synthesis engine will
+ # generate speech.
+ #
+ _("Decreases the speech pitch.")),
+
+ "increaseSpeechPitchHandler" : input_bindings.Handler(
+ Plugin._increaseSpeechPitch,
+ # Translators: the speech pitch is how high or low in
+ # pitch/frequency the speech synthesis engine will
+ # generate speech.
+ #
+ _("Increases the speech pitch.")),
+ })
+ 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 _decreaseSpeechRate(self, inputEvent=None, modifiers=None):
+ """The decreaseSpeechRate handler.
+ """
+ log.debug("_decreaseSpeechRate: %s" % inputEvent)
+
+ def _increaseSpeechRate(self, inputEvent=None, modifiers=None):
+ """The increaseSpeechRate handler.
+ """
+ log.debug("_increaseSpeechRate: %s" % inputEvent)
+
+ def _decreaseSpeechPitch(self, inputEvent=None, modifiers=None):
+ """The decreaseSpeechPitch handler.
+ """
+ log.debug("_decreaseSpeechPitch: %s" % inputEvent)
+
+ def _increaseSpeechPitch(self, inputEvent=None, modifiers=None):
+ """The increaseSpeechPitch handler.
+ """
+ log.debug("_increaseSpeechPitch: %s" % inputEvent)
+
+if __name__ == "__main__":
+ logging.basicConfig(format="%(name)s %(message)s")
+ log.setLevel(logging.DEBUG)
+
+ import script
+ scrypt = 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]