Add a hook 'on_show_prefs' for plugins to setup their pref options prior
to the preferences dialog showing
This commit is contained in:
parent
cc9acf19aa
commit
ce66e22099
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue