| 1 |
# (C) Copyright 2007-2025 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
""" The plugin manager interface. """ |
| 11 |
|
| 12 |
|
| 13 |
# Enthought library imports. |
| 14 |
from traits.api import Event, Interface |
| 15 |
|
| 16 |
# Local imports. |
| 17 |
from .plugin_event import PluginEvent |
| 18 |
|
| 19 |
|
| 20 |
class IPluginManager(Interface): |
| 21 |
"""The plugin manager interface.""" |
| 22 |
|
| 23 |
#### Events #### |
| 24 |
|
| 25 |
#: Fired when a plugin has been added to the manager. |
| 26 |
plugin_added = Event(PluginEvent) |
| 27 |
|
| 28 |
#: Fired when a plugin has been removed from the manager. |
| 29 |
plugin_removed = Event(PluginEvent) |
| 30 |
|
| 31 |
def __iter__(self): |
| 32 |
"""Return an iterator over the manager's plugins.""" |
| 33 |
|
| 34 |
def add_plugin(self, plugin): |
| 35 |
"""Add a plugin to the manager.""" |
| 36 |
|
| 37 |
def get_plugin(self, plugin_id): |
| 38 |
"""Return the plugin with the specified Id. |
| 39 |
|
| 40 |
Return None if no such plugin exists. |
| 41 |
|
| 42 |
""" |
| 43 |
|
| 44 |
def remove_plugin(self, plugin): |
| 45 |
"""Remove a plugin from the manager.""" |
| 46 |
|
| 47 |
def start(self): |
| 48 |
"""Start the plugin manager. |
| 49 |
|
| 50 |
This starts all of the manager's plugins. |
| 51 |
|
| 52 |
""" |
| 53 |
|
| 54 |
def start_plugin(self, plugin=None, plugin_id=None): |
| 55 |
"""Start the specified plugin. |
| 56 |
|
| 57 |
If a plugin is specified then start it. |
| 58 |
|
| 59 |
If no plugin is specified then the Id is used to look up the plugin |
| 60 |
and then start it. If no such plugin exists then a 'ValueError' |
| 61 |
exception is raised. |
| 62 |
|
| 63 |
""" |
| 64 |
|
| 65 |
def stop(self): |
| 66 |
"""Stop the plugin manager. |
| 67 |
|
| 68 |
This stop's all of the plugin manager's plugins (in the reverse order |
| 69 |
that they were started). |
| 70 |
|
| 71 |
""" |
| 72 |
|
| 73 |
def stop_plugin(self, plugin=None, plugin_id=None): |
| 74 |
"""Stop the specified plugin. |
| 75 |
|
| 76 |
If a plugin is specified then stop it (the Id is ignored). |
| 77 |
|
| 78 |
If no plugin is specified then the Id is used to look up the plugin and |
| 79 |
then stop it. If no such plugin exists then a 'ValueError' exception |
| 80 |
is raised. |
| 81 |
|
| 82 |
""" |