Add a hook 'on_show_prefs' for plugins to setup their pref options prior

to the preferences dialog showing
This commit is contained in:
Andrew Resch 2008-07-10 04:46:48 +00:00
parent cc9acf19aa
commit ce66e22099
2 changed files with 12 additions and 2 deletions

View File

@ -46,7 +46,8 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
self, "gtkui.conf", "deluge.plugin.gtkui") self, "gtkui.conf", "deluge.plugin.gtkui")
self.hooks = { self.hooks = {
"on_apply_prefs": [] "on_apply_prefs": [],
"on_show_prefs": []
} }
def register_hook(self, hook, function): def register_hook(self, hook, function):
@ -80,6 +81,14 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
self.enable_plugins() self.enable_plugins()
## Hook functions ## 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): def run_on_apply_prefs(self):
"""This hook is run after the user clicks Apply or OK in the preferences """This hook is run after the user clicks Apply or OK in the preferences
dialog. dialog.

View File

@ -411,6 +411,7 @@ class Preferences(component.Component):
self.plugin_liststore.set_value(row, 0, plugin) self.plugin_liststore.set_value(row, 0, plugin)
self.plugin_liststore.set_value(row, 1, enabled) self.plugin_liststore.set_value(row, 1, enabled)
component.get("PluginManager").run_on_show_prefs()
# Now show the dialog # Now show the dialog
self.pref_dialog.show() self.pref_dialog.show()