Display Queue preferences tab when enabled.

This commit is contained in:
Andrew Resch 2007-11-10 00:22:11 +00:00
parent 7d9a30a545
commit 3c9209dce4
6 changed files with 184 additions and 126 deletions

1
TODO
View File

@ -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

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.0 on Sun Nov 4 19:04:42 2007 by andrew@delicious-->
<!--Generated with glade3 3.2.2 on Fri Nov 9 16:19:20 2007 by andrew@fragment-->
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -31,6 +31,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Queue new torrents to top</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>
@ -80,7 +81,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9999 1 10 10</property>
<property name="adjustment">0 -1 9999 1 10 10</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
@ -98,7 +99,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9999 1 10 10</property>
<property name="adjustment">0 -1 9999 1 10 10</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
@ -116,7 +117,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9999 1 10 10</property>
<property name="adjustment">0 -1 9999 1 10 10</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
@ -208,6 +209,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Queue newly finished torrents to bottom</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>
@ -222,6 +224,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Stop seeding when share ratio reaches:</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_chk_seed_ratio_toggled"/>
</widget>
@ -266,6 +269,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Remove torrent when share ratio reached</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>

View File

@ -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(["#"])

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Thu Oct 4 19:41:27 2007 by andrew@fragment-->
<!--Generated with glade3 3.2.2 on Fri Nov 9 15:44:33 2007 by andrew@fragment-->
<glade-interface>
<widget class="GtkDialog" id="pref_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -883,40 +883,71 @@ Either</property>
<property name="n_columns">2</property>
<property name="column_spacing">15</property>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload">
<widget class="GtkSpinButton" id="spin_max_connections_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="max_length">4</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="digits">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum download speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -941,74 +972,43 @@ Either</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<widget class="GtkSpinButton" id="spin_max_upload">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum download speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_global">
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="max_length">4</property>
<property name="tooltip" translatable="yes">The maximum upload slots for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -1052,24 +1052,29 @@ Either</property>
<property name="n_columns">2</property>
<property name="column_spacing">15</property>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_per_torrent">
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_per_torrent">
<property name="visible">True</property>
@ -1087,24 +1092,19 @@ Either</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<widget class="GtkSpinButton" id="spin_max_upload_slots_per_torrent">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@ -1165,7 +1165,6 @@ Either</property>
<widget class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
@ -1357,33 +1356,15 @@ Either</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<child>
<widget class="GtkRadioButton" id="radio_open_folder_stock">
<widget class="GtkEntry" id="txt_open_folder_location">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Open folder with:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_open_folder_custom">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Custom:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_open_folder_stock</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@ -1413,20 +1394,38 @@ Thunar</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="txt_open_folder_location">
<widget class="GtkRadioButton" id="radio_open_folder_custom">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Custom:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_open_folder_stock</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_open_folder_stock">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Open folder with:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -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)

View File

@ -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("<b><i><big>" + name + "</big></i></b>")
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()