From 3c9209dce43e4e7b1253d69dd50b0d8bf286396e Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 10 Nov 2007 00:22:11 +0000 Subject: [PATCH] Display Queue preferences tab when enabled. --- TODO | 1 - .../queue/queue/glade/queueprefs.glade | 12 +- deluge/plugins/queue/queue/gtkui.py | 14 +- .../ui/gtkui/glade/preferences_dialog.glade | 225 +++++++++--------- deluge/ui/gtkui/pluginmanager.py | 12 +- deluge/ui/gtkui/preferences.py | 46 +++- 6 files changed, 184 insertions(+), 126 deletions(-) diff --git a/TODO b/TODO index 95e3c993c..4dceb5879 100644 --- a/TODO +++ b/TODO @@ -15,7 +15,6 @@ of deluge. * Hide open folder if not localhost * Modify sensitivity of torrent/tray menu based on connection state -* Add queue preferences tab * Add classic/normal mode to preferences * Implement 'Classic' mode * Add remove torrent dialog and ability to remove data diff --git a/deluge/plugins/queue/queue/glade/queueprefs.glade b/deluge/plugins/queue/queue/glade/queueprefs.glade index 4817944a7..67d89aae3 100644 --- a/deluge/plugins/queue/queue/glade/queueprefs.glade +++ b/deluge/plugins/queue/queue/glade/queueprefs.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -31,6 +31,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Queue new torrents to top + 0 True @@ -80,7 +81,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 1 - -1 -1 9999 1 10 10 + 0 -1 9999 1 10 10 True True @@ -98,7 +99,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 1 - -1 -1 9999 1 10 10 + 0 -1 9999 1 10 10 True True @@ -116,7 +117,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 1 - -1 -1 9999 1 10 10 + 0 -1 9999 1 10 10 True True @@ -208,6 +209,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Queue newly finished torrents to bottom + 0 True @@ -222,6 +224,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Stop seeding when share ratio reaches: + 0 True @@ -266,6 +269,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Remove torrent when share ratio reached + 0 True diff --git a/deluge/plugins/queue/queue/gtkui.py b/deluge/plugins/queue/queue/gtkui.py index 53e8ebb60..60e93293e 100644 --- a/deluge/plugins/queue/queue/gtkui.py +++ b/deluge/plugins/queue/queue/gtkui.py @@ -48,6 +48,9 @@ class GtkUI(ui.UI): menu_glade = gtk.glade.XML(pkg_resources.resource_filename("queue", "glade/queuemenu.glade")) + prefs_glade = gtk.glade.XML(pkg_resources.resource_filename("queue", + "glade/queueprefs.glade")) + menu_glade.signal_autoconnect({ "on_menuitem_queuetop_activate": \ self.on_queuetop_activate, @@ -63,11 +66,8 @@ class GtkUI(ui.UI): # Connect to the 'torrent_queue_changed' signal #self.core.connect_to_signal("torrent_queue_changed", # self.torrent_queue_changed_signal) - - # Get the torrentview component from the plugin manager - #self.torrentview = self.plugin.get_torrentview() + # Add the '#' column at the first position - #self.torrentview.add_text_column("#", self.plugin.add_torrentview_text_column("#", col_type=int, position=0, @@ -100,6 +100,11 @@ class GtkUI(ui.UI): self.queue_menuitem.set_submenu(menu) self.queue_menuitem.show_all() self.plugin.add_torrentmenu_menu(self.queue_menuitem) + + # Add preferences page + self.queue_pref_page = \ + prefs_glade.get_widget("queue_prefs_box") + self.plugin.add_preferences_page("Queue", self.queue_pref_page) def unload_interface(self): self.plugin.remove_torrentmenu_item(self.menu_sep) @@ -108,6 +113,7 @@ class GtkUI(ui.UI): self.plugin.remove_toolbar_button(self.toolbutton_up) self.plugin.remove_toolbar_button(self.toolbutton_down) self.plugin.remove_torrentview_column("#") + self.plugin.remove_preferences_page("Queue") def update(self): self.plugin.update_torrent_view(["#"]) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 6b130df42..b745de87d 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -883,40 +883,71 @@ Either 2 15 - + True - True - The maximum upload slots for all torrents. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - True - 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: - 1 - 2 3 4 GTK_FILL - + True True - The maximum upload speed 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 - 1 + True True + GTK_UPDATE_IF_VALID 1 2 - 2 - 3 + GTK_FILL + + + + + True + The maximum download speed for all torrents. Set -1 for unlimited. + 0 + Maximum Download Speed (KiB/s): + + + 1 + 2 GTK_FILL @@ -941,74 +972,43 @@ Either - + True - The maximum download speed for all torrents. Set -1 for unlimited. - 0 - Maximum Download Speed (KiB/s): + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + 1 + True - 1 - 2 + 1 + 2 + 2 + 3 GTK_FILL - + True True - The maximum number of connections allowed. Set -1 for unlimited. - 4 + The maximum upload slots for all torrents. Set -1 for unlimited. 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,24 +1052,29 @@ Either 2 15 - + 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 Upload Slots: - 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 @@ -1087,24 +1092,19 @@ Either - + 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: + 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 @@ -1165,7 +1165,6 @@ Either True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 2 True @@ -1357,33 +1356,15 @@ 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 @@ -1413,20 +1394,38 @@ 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/pluginmanager.py b/deluge/ui/gtkui/pluginmanager.py index e90179a29..48148df53 100644 --- a/deluge/ui/gtkui/pluginmanager.py +++ b/deluge/ui/gtkui/pluginmanager.py @@ -74,12 +74,18 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, def add_torrentmenu_menu(self, *args): return component.get("MenuBar").torrentmenu.append(*args) + def add_torrentmenu_separator(self): + return component.get("MenuBar").add_torrentmenu_separator() + def remove_torrentmenu_item(self, *args): return component.get("MenuBar").torrentmenu.remove(*args) - def add_torrentmenu_separator(self): - return component.get("MenuBar").add_torrentmenu_separator() - + def add_preferences_page(self, *args): + return component.get("Preferences").add_page(*args) + + def remove_preferences_page(self, *args): + return component.get("Preferences").remove_page(*args) + def update_torrent_view(self, *args): return component.get("TorrentView").update(*args) diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 52d098503..31aea403b 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -101,9 +101,53 @@ class Preferences(component.Component): def add_page(self, name, widget): """Add a another page to the notebook""" - index = self.notebook.append_page(widget) + # Create a header and scrolled window for the preferences tab + widget.unparent() + vbox = gtk.VBox() + label = gtk.Label() + label.set_use_markup(True) + label.set_markup("" + name + "") + label.set_alignment(0.05, 0.50) + label.set_padding(0, 10) + vbox.pack_start(label, False, True, 0) + sep = gtk.HSeparator() + vbox.pack_start(sep, False, True, 0) + align = gtk.Alignment() + align.set_padding(5, 0, 0, 0) + align.add(widget) + vbox.pack_start(align, False, False, 0) + scrolled = gtk.ScrolledWindow() + viewport = gtk.Viewport() + viewport.set_shadow_type(gtk.SHADOW_NONE) + viewport.add(vbox) + scrolled.add(viewport) + scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scrolled.show_all() + # Add this page to the notebook + index = self.notebook.append_page(scrolled) self.liststore.append([index, name]) + return name + def remove_page(self, name): + """Removes a page from the notebook""" + self.page_num_to_remove = None + self.iter_to_remove = None + + def check_row(model, path, iter, user_data): + row_name = model.get_value(iter, 1) + if row_name == user_data: + # This is the row we need to remove + self.page_num_to_remove = model.get_value(iter, 0) + self.iter_to_remove = iter + return + + self.liststore.foreach(check_row, name) + # Remove the page and row + if self.page_num_to_remove != None: + self.notebook.remove_page(self.page_num_to_remove) + if self.iter_to_remove != None: + self.liststore.remove(self.iter_to_remove) + def show(self): # Update the preferences dialog to reflect current config settings self.core_config = client.get_config()