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



Author: wwalker
Date: Sun Sep 14 19:43:35 2008
New Revision: 4214
URL: http://svn.gnome.org/viewvc/orca?rev=4214&view=rev

Log:
A little more packaging.  Plugins are in their own package now.


Added:
   branches/phase2/src/orca/plugins/   (props changed)
   branches/phase2/src/orca/plugins/Makefile.am
   branches/phase2/src/orca/plugins/__init__.py   (contents, props changed)
   branches/phase2/src/orca/plugins/bookmarks.py   (contents, props changed)
   branches/phase2/src/orca/plugins/debug_actions.py   (contents, props changed)
   branches/phase2/src/orca/plugins/speech_parameters.py   (contents, props changed)
Removed:
   branches/phase2/src/orca/bookmarks_plugin.py
   branches/phase2/src/orca/debug_plugin.py
   branches/phase2/src/orca/speech_plugin.py
Modified:
   branches/phase2/configure.in
   branches/phase2/src/orca/Makefile.am
   branches/phase2/src/orca/default.py
   branches/phase2/src/orca/plugin.py
   branches/phase2/src/orca/script.py

Modified: branches/phase2/configure.in
==============================================================================
--- branches/phase2/configure.in	(original)
+++ branches/phase2/configure.in	Sun Sep 14 19:43:35 2008
@@ -159,6 +159,7 @@
 src/louis/Makefile
 src/louis/constants.py
 src/orca/Makefile
+src/orca/plugins/Makefile
 src/orca/scripts/Makefile
 src/orca/scripts/apps/Makefile
 src/orca/scripts/toolkits/Makefile

Modified: branches/phase2/src/orca/Makefile.am
==============================================================================
--- branches/phase2/src/orca/Makefile.am	(original)
+++ branches/phase2/src/orca/Makefile.am	Sun Sep 14 19:43:35 2008
@@ -7,10 +7,8 @@
 
 orca_python_PYTHON = \
 	__init__.py \
-	bookmarks_plugin.py \
 	braille_monitor.py \
 	braille.py \
-	debug_plugin.py \
 	default.py \
 	default_bindings.py \
 	input_bindings.py \
@@ -22,7 +20,8 @@
 	script_manager.py \
 	script.py \
 	settings.py \
-	speech_plugin.py \
 	utils.py
 
 orca_pythondir=$(pyexecdir)/orca
+
+SUBDIRS = plugins scripts

Modified: branches/phase2/src/orca/default.py
==============================================================================
--- branches/phase2/src/orca/default.py	(original)
+++ branches/phase2/src/orca/default.py	Sun Sep 14 19:43:35 2008
@@ -46,14 +46,19 @@
         """
         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 _getPluginClasses(self):
+        """Returns a list of classes to instantiante for plugins.
+        Subclasses should override this method to add their own
+        plugins.
+        """
+        import plugins.debug_actions
+        import plugins.speech_parameters
+        import plugins.bookmarks
+        
+        return script.Script._getPluginClasses(self) \
+            + [plugins.debug_actions.Plugin,
+               plugins.speech_parameters.Plugin,
+               plugins.bookmarks.Plugin]
 
     def _createObjectEventListeners(self):
         """Sets up the AT-SPI event listeners for this script.

Modified: branches/phase2/src/orca/plugin.py
==============================================================================
--- branches/phase2/src/orca/plugin.py	(original)
+++ branches/phase2/src/orca/plugin.py	Sun Sep 14 19:43:35 2008
@@ -44,6 +44,7 @@
     def _completeInit(self):
         """Completes the __init__ step.
         """
+        self.application = self._script.application
         log.debug("NEW PLUGIN: %s" % self)
 
     def __str__(self):

Added: branches/phase2/src/orca/plugins/Makefile.am
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/plugins/Makefile.am	Sun Sep 14 19:43:35 2008
@@ -0,0 +1,10 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+	__init__.py \
+	bookmarks.py \
+	debug_actions.py \
+	speech_parameters.py
+
+orca_pythondir=$(pyexecdir)/orca/plugins
+

Added: branches/phase2/src/orca/plugins/__init__.py
==============================================================================

Added: branches/phase2/src/orca/plugins/bookmarks.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/plugins/bookmarks.py	Sun Sep 14 19:43: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.plugins.bookmarks')
+
+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
+
+# 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 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

Added: branches/phase2/src/orca/plugins/debug_actions.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/plugins/debug_actions.py	Sun Sep 14 19:43: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.plugins.debug_actions')
+
+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
+
+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 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

Added: branches/phase2/src/orca/plugins/speech_parameters.py
==============================================================================
--- (empty file)
+++ branches/phase2/src/orca/plugins/speech_parameters.py	Sun Sep 14 19:43: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.plugins.speech_parameters')
+
+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
+
+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 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

Modified: branches/phase2/src/orca/script.py
==============================================================================
--- branches/phase2/src/orca/script.py	(original)
+++ branches/phase2/src/orca/script.py	Sun Sep 14 19:43:35 2008
@@ -71,8 +71,6 @@
         self._isActive = False
         self.presentIfInactive = False
 
-        self._plugins = []
-        
         self._objectEventListeners = self._createObjectEventListeners()
         self._inputEventHandlers = self._createInputEventHandlers()
         self._keyBindings = \
@@ -90,8 +88,15 @@
         #
         self.locus = {}
 
+        self._plugins = []
+        pluginClasses = self._getPluginClasses()
+        for pluginClass in pluginClasses:
+            try:
+                self._plugins.append(pluginClass(self))
+            except:
+                log.exception("handled exception creating plugin:")
+
         self._completeInit()
-        self._addPlugins()
 
     def _completeInit(self):
         """Completes the __init__ step.
@@ -107,9 +112,13 @@
             name = "None"
         return "script %s (module=%s)" % (name, self.__module__)
 
-    def _addPlugins(self):
-        """Adds various plugins to this script."""
-        pass
+    def _getPluginClasses(sef):
+        """Returns a list of classes to instantiante for plugins.
+        Subclasses should override this method to add their own
+        plugins.  One of the things a subclass can do is obtain
+        this list and then add or replace elements.
+        """
+        return []
 
     def _createObjectEventListeners(self):
         """Sets up the AT-SPI event listeners for this script.



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