diff --git a/delugeplugins.py b/delugeplugins.py index 198ba3444..143bb09e8 100644 --- a/delugeplugins.py +++ b/delugeplugins.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # # delugeplugins.py # @@ -19,6 +20,43 @@ # 51 Franklin Street, Fifth Floor # Boston, MA 02110-1301, USA. +import os + class PluginManager: def __init__(self): - pass \ No newline at end of file + self.plugin_dirs = [] + self.plugins = {} + + def add_plugin_dir(self, directory): + self.plugin_dirs.append(directory) + + def scan_for_plugins(self): + register_plugin = self.register_plugin + for folder in self.plugin_dirs: + print "Looking in", folder + plugin_folders = os.listdir(folder) + for plugin in plugin_folders: + if os.path.isfile(folder + plugin + "/plugin.py"): + execfile(folder + plugin + "/plugin.py") + + def register_plugin(self, + name, + plugin_class, + version, + description, + config=False, + default=False, + requires=None, + interface=None, + required_plugins=None): + self.plugins[name] = (plugin_class, version, description, config, default, requires, interface, required_plugins) + +## Few lines of code to test functionality +if __name__ == "__main__": + p = PluginManager() + p.add_plugin_dir("plugins/") + p.scan_for_plugins() + for x in p.plugins: + print x + for y in p.plugins[x]: + print "\t", y \ No newline at end of file diff --git a/dgtk.py b/dgtk.py index 3fb2533f7..43a9f6bb5 100644 --- a/dgtk.py +++ b/dgtk.py @@ -30,7 +30,7 @@ import gtk.glade ## Right now this only supports PyGTK's native -## tray library. I will add egg support into +## tray library. I may add egg support into ## this class at a later time. class TrayIcon: def __init__(self, parent): @@ -111,6 +111,13 @@ class PreferencesDialog: self.prf = self.wtree.get_widget("pref_dialog") self.notebook = self.wtree.get_widget("pref_notebook") self.prf.set_icon_from_file(dcommon.get_pixmap("deluge32.png")) + + self.plugin_view = self.wtree.get_widget("plugin_view") + self.plugin_store = gtk.ListStore(str, 'gboolean') + self.plugin_view.set_model(self.plugin_store) + self.plugin_name_column = add_text_column(self.plugin_view, "Plugin", 0) + self.plugin_name_column.set_expand(True) + self.plugin_toggle_column = add_toggle_column(self.plugin_view, "Enable", 1) def show_pref(self, arg=None): self.prf.show_all() diff --git a/glade/dgtkpref.glade b/glade/dgtkpref.glade index 1549ff792..808138036 100644 --- a/glade/dgtkpref.glade +++ b/glade/dgtkpref.glade @@ -6,6 +6,8 @@ 480 5 Preferences Dialog + 583 + 431 False @@ -105,8 +107,8 @@ - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER True + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER 1 @@ -135,7 +137,6 @@ True - True True @@ -183,7 +184,6 @@ their share ratio reaches: True - True True @@ -462,7 +462,7 @@ their share ratio reaches: 2 2 - + True False GTK_WRAP_WORD @@ -481,7 +481,9 @@ their share ratio reaches: True - button + + + @@ -513,7 +515,7 @@ their share ratio reaches: - + True diff --git a/plugins/ExamplePlugin/plugin.py b/plugins/ExamplePlugin/plugin.py new file mode 100644 index 000000000..fa31ddb1d --- /dev/null +++ b/plugins/ExamplePlugin/plugin.py @@ -0,0 +1,19 @@ +#!/usr/bin/python + +class plugin_Example: + def __init__(self, deluge_core, deluge_interface): + self.core = deluge_core + self.interface = deluge_interface + + def unload(self): + pass + + def update(self): + pass + + +register_plugin("Example", + plugin_Example, + "0.2", + "An example plugin", + requires="0.5.0") \ No newline at end of file