Added mechanism to successfully load plugins after GUI extension points have been created, e.g. when we want to modify ChatControl behaviour and objects of this class have already been created.

Also: customized IPython console look
This commit is contained in:
Mateusz Biliński 2008-06-03 08:25:16 +00:00
parent f62698e28c
commit 77f10031f1
2 changed files with 37 additions and 10 deletions

View File

@ -3208,6 +3208,7 @@ class Interface:
font = 'Lucida Console 9' font = 'Lucida Console 9'
else: else:
font = 'Luxi Mono 10' font = 'Luxi Mono 10'
font="Terminus 10"
window = gtk.Window() window = gtk.Window()
window.set_size_request(750,550) window.set_size_request(750,550)
@ -3217,6 +3218,8 @@ class Interface:
view = IPythonView() view = IPythonView()
view.modify_font(pango.FontDescription(font)) view.modify_font(pango.FontDescription(font))
view.set_wrap_mode(gtk.WRAP_CHAR) view.set_wrap_mode(gtk.WRAP_CHAR)
view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"));
view.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"));
sw.add(view) sw.add(view)
window.add(sw) window.add(sw)
window.show_all() window.show_all()

View File

@ -52,7 +52,6 @@ class PluginManager(object):
after GUI object creation) after GUI object creation)
:todo: implement mechanism to dynamically deactive plugins (call plugin's :todo: implement mechanism to dynamically deactive plugins (call plugin's
deactivation handler) deactivation handler)
''' '''
__metaclass__ = Singleton __metaclass__ = Singleton
@ -81,12 +80,17 @@ class PluginManager(object):
Registered GUI extension points. Registered GUI extension points.
''' '''
self.gui_extension_points_handlers = {}
'''
Registered handlers of GUI extension points.
'''
for path in gajim.PLUGINS_DIRS: for path in gajim.PLUGINS_DIRS:
self.plugins.extend(PluginManager.scan_dir_for_plugins(path)) self.plugins.extend(PluginManager.scan_dir_for_plugins(path))
log.debug('plugins: %s'%(self.plugins)) log.debug('plugins: %s'%(self.plugins))
self._activate_all_plugins() #self._activate_all_plugins()
log.debug('active: %s'%(self.active_plugins)) log.debug('active: %s'%(self.active_plugins))
@ -115,10 +119,17 @@ class PluginManager(object):
''' '''
log.debug(type(args)) self._add_gui_extension_point_call_to_list(gui_extpoint_name, *args)
self._execute_all_handlers_of_gui_extension_point(gui_extpoint_name, *args)
if gui_extpoint_name in self.gui_extension_points: @log_calls('PluginManager')
for handlers in self.gui_extension_points[gui_extpoint_name]: def _add_gui_extension_point_call_to_list(self, gui_extpoint_name, *args):
self.gui_extension_points.setdefault(gui_extpoint_name, []).append(args)
@log_calls('PluginManager')
def _execute_all_handlers_of_gui_extension_point(self, gui_extpoint_name, *args):
if gui_extpoint_name in self.gui_extension_points_handlers:
for handlers in self.gui_extension_points_handlers[gui_extpoint_name]:
handlers[0](*args) handlers[0](*args)
@log_calls('PluginManager') @log_calls('PluginManager')
@ -132,16 +143,29 @@ class PluginManager(object):
success = True success = True
for gui_extpoint_name, gui_extpoint_handlers in \ self._add_gui_extension_points_handlers_from_plugin(plugin_object)
plugin_object.gui_extension_points.iteritems(): self._handle_all_gui_extension_points_with_plugin(plugin_object)
self.gui_extension_points.setdefault(gui_extpoint_name, []).append(
gui_extpoint_handlers)
if success: if success:
self.active_plugins.append(plugin_object) self.active_plugins.append(plugin_object)
return success return success
@log_calls('PluginManager')
def _add_gui_extension_points_handlers_from_plugin(self, plugin_object):
for gui_extpoint_name, gui_extpoint_handlers in \
plugin_object.gui_extension_points.iteritems():
self.gui_extension_points_handlers.setdefault(gui_extpoint_name, []).append(
gui_extpoint_handlers)
@log_calls('PluginManager')
def _handle_all_gui_extension_points_with_plugin(self, plugin_object):
for gui_extpoint_name, gui_extpoint_handlers in \
plugin_object.gui_extension_points.iteritems():
if gui_extpoint_name in self.gui_extension_points:
for gui_extension_point_args in self.gui_extension_points[gui_extpoint_name]:
gui_extpoint_handlers[0](*gui_extension_point_args)
@log_calls('PluginManager') @log_calls('PluginManager')
def _activate_all_plugins(self): def _activate_all_plugins(self):
''' '''