From ce66e22099096b024a33ec73b4638e8762525eed Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Thu, 10 Jul 2008 04:46:48 +0000 Subject: [PATCH] Add a hook 'on_show_prefs' for plugins to setup their pref options prior to the preferences dialog showing --- deluge/ui/gtkui/pluginmanager.py | 11 ++++++++++- deluge/ui/gtkui/preferences.py | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/deluge/ui/gtkui/pluginmanager.py b/deluge/ui/gtkui/pluginmanager.py index 489fdb26b..324ddc68d 100644 --- a/deluge/ui/gtkui/pluginmanager.py +++ b/deluge/ui/gtkui/pluginmanager.py @@ -46,7 +46,8 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, self, "gtkui.conf", "deluge.plugin.gtkui") self.hooks = { - "on_apply_prefs": [] + "on_apply_prefs": [], + "on_show_prefs": [] } def register_hook(self, hook, function): @@ -80,6 +81,14 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, self.enable_plugins() ## Hook functions + def run_on_show_prefs(self): + """This hook is run before the user is shown the preferences dialog. + It is designed so that plugins can update their preference page with + the config.""" + log.debug("run_on_show_prefs") + for function in self.hooks["on_show_prefs"]: + function() + def run_on_apply_prefs(self): """This hook is run after the user clicks Apply or OK in the preferences dialog. diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index d55564270..2a7dc3d07 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -410,7 +410,8 @@ class Preferences(component.Component): row = self.plugin_liststore.append() self.plugin_liststore.set_value(row, 0, plugin) self.plugin_liststore.set_value(row, 1, enabled) - + + component.get("PluginManager").run_on_show_prefs() # Now show the dialog self.pref_dialog.show()