diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-11-07 19:48:16 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-11-07 19:48:16 +0100 |
commit | 54962e6796301f6fb57d09f7778ab50f69e35943 (patch) | |
tree | c1312f5cdc386970079f776b0477a24da0d9b599 /src/plugin_manager.py | |
parent | 04f103b9e67ccd1de7376be4f7b5156ec425e99c (diff) | |
parent | 17e5411d8f050a3c5e5bcd010551eecac96b5911 (diff) | |
download | poezio-54962e6796301f6fb57d09f7778ab50f69e35943.tar.gz poezio-54962e6796301f6fb57d09f7778ab50f69e35943.tar.bz2 poezio-54962e6796301f6fb57d09f7778ab50f69e35943.tar.xz poezio-54962e6796301f6fb57d09f7778ab50f69e35943.zip |
Merge branch 'plugins' of /home/louiz/git/poezio into plugins
Conflicts:
src/core.py
Diffstat (limited to 'src/plugin_manager.py')
-rw-r--r-- | src/plugin_manager.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugin_manager.py b/src/plugin_manager.py index 5bd6d75b..37db3d13 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -34,6 +34,7 @@ class PluginManager(object): self.plugins = {} # module name -> plugin object self.commands = {} # module name -> dict of commands loaded for the module self.event_handlers = {} # module name -> list of event_name/handler pairs loaded for the module + self.poezio_event_handlers = {} def load(self, name): if name in self.plugins: @@ -60,6 +61,7 @@ class PluginManager(object): self.modules[name] = module self.commands[name] = {} self.event_handlers[name] = [] + self.poezio_event_handlers[name] = [] self.plugins[name] = module.Plugin(self, self.core, plugins_conf_dir) def unload(self, name): @@ -69,14 +71,14 @@ class PluginManager(object): del self.core.commands[command] for event_name, handler in self.event_handlers[name]: self.core.xmpp.del_event_handler(event_name, handler) - for event_name in self.core.internal_events: - if name in event_name: - del event_name[name] + for handler in self.poezio_event_handlers[name]: + self.core.events.del_event_handler(None, handler) self.plugins[name].unload() del self.plugins[name] del self.commands[name] del self.event_handlers[name] + del self.poezio_event_handlers[name] except Exception as e: import traceback self.core.information(_("Could not unload plugin (may not be safe to try again): ") + traceback.format_exc()) @@ -105,6 +107,16 @@ class PluginManager(object): eh = self.event_handlers[module_name] eh = list(filter(lambda e : e != (event_name, handler), eh)) + def add_poezio_event_handler(self, module_name, event_name, handler, first, last, position): + eh = self.poezio_event_handlers[module_name] + eh.append(handler) + self.core.events.add_event_handler(event_name, handler, first, last, position) + + def del_poezio_event_handler(self, module_name, event_name, handler): + self.core.events.del_event_handler(None, handler) + eh = self.poezio_event_handlers[module_name] + eh = list(filter(lambda e : e != handler, eh)) + def completion_load(self, the_input): """ completion function that completes the name of the plugins, from |