mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 13:56:47 +00:00
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, "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.
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user