From d240ba3c01dca1606d31282b7150b2a668a84aac Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 5 Oct 2007 05:05:07 +0000 Subject: [PATCH] Preferences plugin tab stuff. --- deluge/pluginmanagerbase.py | 2 +- deluge/ui/functions.py | 10 + .../ui/gtkui/glade/preferences_dialog.glade | 226 +++++++++--------- deluge/ui/gtkui/listview.py | 6 +- deluge/ui/gtkui/mainwindow.py | 6 +- deluge/ui/gtkui/preferences.py | 42 +++- deluge/ui/gtkui/systemtray.py | 1 - 7 files changed, 171 insertions(+), 122 deletions(-) diff --git a/deluge/pluginmanagerbase.py b/deluge/pluginmanagerbase.py index 2ed1b79f0..bce76b70b 100644 --- a/deluge/pluginmanagerbase.py +++ b/deluge/pluginmanagerbase.py @@ -77,7 +77,7 @@ class PluginManagerBase: def get_enabled_plugins(self): """Returns a list of enabled plugins""" - return self.plugins.key() + return self.plugins.keys() def scan_for_plugins(self): """Scans for available plugins""" diff --git a/deluge/ui/functions.py b/deluge/ui/functions.py index d8c45f87f..fb6b5dcfc 100644 --- a/deluge/ui/functions.py +++ b/deluge/ui/functions.py @@ -161,6 +161,16 @@ def get_listen_port(core=None): core = get_core() return int(core.get_listen_port()) +def get_available_plugins(core=None): + if core is None: + core = get_core() + return deluge.common.pythonize(core.get_available_plugins()) + +def get_enabled_plugins(core=None): + if core is None: + core = get_core() + return deluge.common.pythonize(core.get_enabled_plugins()) + def open_url_in_browser(url): """Opens link in the desktop's default browser""" def start_browser(): diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 8563d26e6..6b130df42 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,13 +1,13 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 Deluge Preferences GTK_WIN_POS_CENTER_ON_PARENT - 500 + 510 520 True GDK_WINDOW_TYPE_HINT_DIALOG @@ -883,71 +883,40 @@ Either 2 15 - + True - The maximum upload speed for all torrents. Set -1 for unlimited. - 0 - Maximum Upload Speed (KiB/s): - - - 2 - 3 - GTK_FILL - - - - - True - The maximum number of connections allowed. Set -1 for unlimited. - 0 - Maximum Connections: - - - GTK_FILL - - - - - True - The maximum upload speed for all torrents. Set -1 for unlimited. - 0 - Maximum Upload Slots: + True + The maximum upload slots for all torrents. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + True + True + 1 + 2 3 4 GTK_FILL - + True True - The maximum number of connections allowed. Set -1 for unlimited. - 4 + The maximum upload speed for all torrents. Set -1 for unlimited. 1 -1 -1 9000 1 10 10 1 - True + 1 True - GTK_UPDATE_IF_VALID 1 2 - GTK_FILL - - - - - True - The maximum download speed for all torrents. Set -1 for unlimited. - 0 - Maximum Download Speed (KiB/s): - - - 1 - 2 + 2 + 3 GTK_FILL @@ -972,43 +941,74 @@ Either - + True - True - The maximum upload speed for all torrents. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - 1 - True + The maximum download speed for all torrents. Set -1 for unlimited. + 0 + Maximum Download Speed (KiB/s): - 1 - 2 - 2 - 3 + 1 + 2 GTK_FILL - + True True - The maximum upload slots for all torrents. Set -1 for unlimited. + The maximum number of connections allowed. Set -1 for unlimited. + 4 1 -1 -1 9000 1 10 10 1 True True + GTK_UPDATE_IF_VALID 1 2 + GTK_FILL + + + + + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 0 + Maximum Upload Slots: + + 3 4 GTK_FILL + + + True + The maximum number of connections allowed. Set -1 for unlimited. + 0 + Maximum Connections: + + + GTK_FILL + + + + + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 0 + Maximum Upload Speed (KiB/s): + + + 2 + 3 + GTK_FILL + + @@ -1052,29 +1052,24 @@ Either 2 15 - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Maximum Upload Slots: + True + The maximum upload slots per torrent. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + True + True + 1 + 2 1 2 GTK_FILL - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Maximum Connections: - - - GTK_FILL - - True @@ -1092,19 +1087,24 @@ Either - + True - True - The maximum upload slots per torrent. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - True - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Maximum Connections: + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Maximum Upload Slots: - 1 - 2 1 2 GTK_FILL @@ -1357,15 +1357,33 @@ Either 2 10 - + True - False True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Open folder with: + 0 + True + True + + + + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Custom: + 0 + True + True + radio_open_folder_stock + - 1 - 2 1 2 GTK_FILL @@ -1395,38 +1413,20 @@ Thunar - + True + False True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Custom: - 0 - True - True - radio_open_folder_stock - + 1 + 2 1 2 GTK_FILL - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Open folder with: - 0 - True - True - - - - GTK_FILL - - diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtkui/listview.py index e8cfdc701..1f80953cc 100644 --- a/deluge/ui/gtkui/listview.py +++ b/deluge/ui/gtkui/listview.py @@ -297,17 +297,15 @@ class ListView: column.set_cell_data_func(render, function, tuple(self.columns[header].column_indices)) elif column_type == "texticon": - column.pack_start(render[pixbuf]) + column.pack_start(render[pixbuf], False) if function is not None: column.set_cell_data_func(render[pixbuf], function, self.columns[header].column_indices[pixbuf]) - column.pack_start(render[text]) + column.pack_start(render[text], True) column.add_attribute(render[text], "text", self.columns[header].column_indices[text]) elif column_type == None: return - - column.set_sort_column_id(self.columns[header].column_indices[sortid]) column.set_clickable(True) diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 46c40420a..5d882cbb4 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -61,7 +61,7 @@ class MainWindow: self.window.set_icon(deluge.common.get_logo(32)) self.vpaned = self.main_glade.get_widget("vpaned") # Load the window state - self.load_window_geometry() + self.load_window_state() # Keep track of window's minimization state so that we don't update the # UI when it is minimized. @@ -101,6 +101,8 @@ class MainWindow: return True def show(self): + # Load the state prior to showing + self.load_window_state() self.window.show() def hide(self): @@ -130,7 +132,7 @@ class MainWindow: self.hide() gtk.main_quit() - def load_window_geometry(self): + def load_window_state(self): x = self.config["window_x_pos"] y = self.config["window_y_pos"] w = self.config["window_width"] diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 23574360c..ef9fee42b 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -66,11 +66,26 @@ class Preferences: self.liststore.append([i, category]) i += 1 + # Setup plugin tab listview + self.plugin_liststore = gtk.ListStore(str, bool) + self.plugin_listview = self.glade.get_widget("plugin_listview") + self.plugin_listview.set_model(self.plugin_liststore) + render = gtk.CellRendererToggle() + render.connect("toggled", self.on_plugin_toggled) + render.set_property("activatable", True) + self.plugin_listview.append_column( + gtk.TreeViewColumn(_("Enabled"), render, active=1)) + self.plugin_listview.append_column( + gtk.TreeViewColumn(_("Plugin"), gtk.CellRendererText(), text=0)) + # Connect to the 'changed' event of TreeViewSelection to get selection # changes. self.treeview.get_selection().connect("changed", self.on_selection_changed) + self.plugin_listview.get_selection().connect("changed", + self.on_plugin_selection_changed) + self.glade.signal_autoconnect({ "on_pref_dialog_delete_event": self.on_pref_dialog_delete_event, "on_button_ok_clicked": self.on_button_ok_clicked, @@ -177,6 +192,21 @@ class Preferences: self.glade.get_widget("chk_send_info").set_active( self.gtkui_config["send_info"]) + ## Plugins tab ## + all_plugins = functions.get_available_plugins() + enabled_plugins = functions.get_enabled_plugins() + # Clear the existing list so we don't duplicate entries. + self.plugin_liststore.clear() + # Iterate through the lists and add them to the liststore + for plugin in all_plugins: + if plugin in enabled_plugins: + enabled = True + else: + enabled = False + row = self.plugin_liststore.append() + self.plugin_liststore.set_value(row, 0, plugin) + self.plugin_liststore.set_value(row, 1, enabled) + # Now show the dialog self.pref_dialog.show() @@ -359,4 +389,14 @@ class Preferences: url = "http://deluge-torrent.org/test-port.php?port=%s" % \ functions.get_listen_port(self.core) functions.open_url_in_browser(url) - + + def on_plugin_toggled(self, renderer, path): + log.debug("on_plugin_toggled") + row = self.plugin_liststore.get_iter_from_string(path) + name = self.plugin_liststore.get_value(row, 0) + value = self.plugin_liststore.get_value(row, 1) + self.plugin_liststore.set_value(row, 1, not value) + + def on_plugin_selection_changed(self, treeselection): + log.debug("on_plugin_selection_changed") + diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 4e78b3df1..3b1bd64d5 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -134,7 +134,6 @@ class SystemTray: if self.config["lock_tray"] == True: self.unlock_tray("mainwinshow") else: - self.window.load_window_geometry() self.window.show() # Force UI update as we don't update it while in tray self.window.update()