[orca/orca-gnome3: 12/87] Running activation / deactivation for plugins, pas into event managing
- From: Alejandro Leiva <aleiva src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca/orca-gnome3: 12/87] Running activation / deactivation for plugins, pas into event managing
- Date: Fri, 1 Apr 2011 11:13:49 +0000 (UTC)
commit eadd3e7336b096ff8cae5f5827f93cd14fba6fe2
Author: José Ignacio �lvarez Ruiz <jialvarez emergya es>
Date: Tue Mar 1 20:41:06 2011 +0100
Running activation / deactivation for plugins, pas into event managing
src/orca/baseplugins/test.py | 66 +++++++++++++++++++++++++++++++++--------
src/orca/pluglib/manager.py | 23 +-------------
2 files changed, 55 insertions(+), 34 deletions(-)
---
diff --git a/src/orca/baseplugins/test.py b/src/orca/baseplugins/test.py
index a0a85f7..288ae0c 100644
--- a/src/orca/baseplugins/test.py
+++ b/src/orca/baseplugins/test.py
@@ -1,17 +1,24 @@
# - coding: utf-8 -
-from pluglib.confstore import GConfStore
-from pluglib.interfaces import *
+# Copyright (C) 2010, J. Félix Ontañón <felixonta gmail com>
+# Copyright (C) 2011, J. Ignacio Ã?lvarez <neonigma gmail com>
-class gConfPlugin(GConfStore):
- defaults = {
- 'enable': True,
- }
+# This file is part of Pluglib.
- def __init__(self):
- super(gConfPlugin, self).__init__('/apps/orca/plugins/test')
- self.save()
- print 'Hello World (plugin started)!'
+# Pluglib is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Pluglib 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Pluglib. If not, see <http://www.gnu.org/licenses/>.
+
+from pluglib.interfaces import *
class testPlugin(IPlugin):
name = 'Test Plugin'
@@ -22,9 +29,42 @@ class testPlugin(IPlugin):
icon = 'gtk-missing-image'
def __init__(self):
- self.gc_plug = gConfPlugin()
+ print 'Hello World (plugin started)!'
+
+from event_manager import EventManager, Event, event_manager as em
+
+def func1(*args):
+ print "Im the func1 with args: " + str(args)
+
+def func2(*args):
+ print "Im the func2 with args: " + str(args)
+
+def func3(*args):
+ print "Im the func3 with args: " + str(args)
+
+
+# Create some events
+event1 = Event('event1')
+event2 = Event('event2')
+
+em.add_event(event1)
+em.add_event(event2)
+
+# Connecting functions with events
+em.connect('event1', func3, [1,2])
+em.connect('event1', func2)
+em.connect('event2', func1)
+
+# Sending signals
+print "sending event1 from test plugin..."
+em.signal('event1')
+print "sending event2 from test plugin..."
+em.signal('event2')
+
+# sending signal with arguments
+print "sending event1 from test plugin with arguments..."
+em.signal('event1', [1,2,3])
- def disable(self):
- self.gc_plug.disable('enable')
+print "\n"
IPlugin.register(testPlugin)
diff --git a/src/orca/pluglib/manager.py b/src/orca/pluglib/manager.py
index 4000612..bc31067 100644
--- a/src/orca/pluglib/manager.py
+++ b/src/orca/pluglib/manager.py
@@ -28,7 +28,7 @@ import abc
import store_config
import settings_manager
-from interfaces import *
+from pluglib.interfaces import *
class ModulePluginManager(IPluginManager):
"""A plugin manager that handles with python modules"""
@@ -39,8 +39,6 @@ class ModulePluginManager(IPluginManager):
if not type(self.plugin_paths) is list:
self.plugin_paths = [self.plugin_paths]
- self.plugin_paths=['baseplugins']
-
#{'plugin_name': {'class': plugin_class, 'object': plugin_object,
# 'type': plugin_type, 'registered':, if_registered}
self.plugins = {}
@@ -99,7 +97,7 @@ class ModulePluginManager(IPluginManager):
return plugins
def scan_more_plugins(self):
- print "Scanning new plugins"
+ print "Scanning plugins..."
# CHECK BASEPLUGINS FOR MORE PLUGINS
new_plugins = {}
for path in self.plugin_paths:
@@ -113,23 +111,12 @@ class ModulePluginManager(IPluginManager):
self.plugins = new_plugins
def load_class_in_plugin(self, dict_plugins, module_name, path):
- print "module_name: " + str(module_name)
- print "path: " + str(path)
modfile, name, desc = imp.find_module(module_name, path)
- print "modfile: " + str(modfile)
- print "name: " + str(name)
- print "desc: " + str(desc)
-
# the idea is not repeat this load unnecessarily
module = imp.load_module(module_name, modfile, name, desc)
- print "module: " + str(module)
-
for (the_name, klass) in inspect.getmembers(module, inspect.isclass):
- print "the_name: " + str(the_name)
- print "klass: " + str(klass)
- print "subclase compar: " + str(issubclass(klass, IPlugin))
if issubclass(klass, IPlugin) and the_name != "IPlugin":
klass_update = {'class': klass}
object_update = {'object': None}
@@ -141,8 +128,6 @@ class ModulePluginManager(IPluginManager):
type_update = {'type': 'Command'}
dict_plugins.update(type_update)
- print "el dict: " + str(dict_plugins)
-
def scan_plugins(self):
self.scan_more_plugins()
@@ -151,12 +136,10 @@ class ModulePluginManager(IPluginManager):
self.plugins = self.plugins_conf.copy()
load_plugins = self.plugins['plugins'];
- print "load_plugins: " + str(load_plugins)
for module_name, data in load_plugins.iteritems():
if load_plugins[module_name]['active'] == True:
try:
- print "Loading class in: " + str(load_plugins[module_name])
self.load_class_in_plugin(load_plugins[module_name],
module_name, [load_plugins[module_name]['path']])
print "Starting existent module: " + str(module_name)
@@ -181,7 +164,6 @@ class ModulePluginManager(IPluginManager):
[self.plugins[plugin_name]['path']])
plugin_class = self.plugins[plugin_name]['class']
- print "plugin class: " + str(plugin_class)
if issubclass(plugin_class, IDependenciesChecker) \
and not plugin_class.check_dependencies():
@@ -210,7 +192,6 @@ class ModulePluginManager(IPluginManager):
del (plugin_name)
def get_plugins(self):
- print self.plugins
return [(plugin_name, plugin['class'],
plugin['type'], plugin['registered'], plugin['name'])
for (plugin_name, plugin) in self.plugins.items()]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]