From 745872efdec1d26e1224939149c2321e0443c8d3 Mon Sep 17 00:00:00 2001 From: Zach Tibbitts Date: Tue, 27 Feb 2007 00:47:22 +0000 Subject: [PATCH] - --- glade/delugegtk.glade | 20 ++++++++++++++------ src/deluge.py | 37 ++++++++++++++++++++----------------- src/delugegtk.py | 11 +++++++++++ 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/glade/delugegtk.glade b/glade/delugegtk.glade index c63bd7166..1b4c2c627 100644 --- a/glade/delugegtk.glade +++ b/glade/delugegtk.glade @@ -16,7 +16,6 @@ True - GTK_TOOLBAR_BOTH_HORIZ False @@ -58,13 +57,22 @@ - + True - Update Tracker - Update Tracker + + + False + False + + + + + True + Start / Pause + Start / Pause True - gtk-refresh - + gtk-media-play + False diff --git a/src/deluge.py b/src/deluge.py index 720d2b4de..3db065042 100644 --- a/src/deluge.py +++ b/src/deluge.py @@ -421,25 +421,28 @@ class Manager: # ___ALL queuing code should be in this function, and ONLY here___ def apply_queue(self, efficient = True): # Handle autoseeding - downqueue as needed + try: + if self.auto_seed_ratio != -1: + for unique_ID in self.unique_IDs: + if self.get_core_torrent_state(unique_ID, efficient)['is_seed']: + torrent_state = self.get_core_torrent_state(unique_ID, efficient) + ratio = self.calc_ratio(unique_ID, torrent_state) + if ratio >= self.auto_seed_ratio: + self.queue_bottom(unique_ID) - if self.auto_seed_ratio != -1: - for unique_ID in self.unique_IDs: - if self.get_core_torrent_state(unique_ID, efficient)['is_seed']: - torrent_state = self.get_core_torrent_state(unique_ID, efficient) - ratio = self.calc_ratio(unique_ID, torrent_state) - if ratio >= self.auto_seed_ratio: - self.queue_bottom(unique_ID) - # Pause and resume torrents - for index in range(len(self.state.queue)): - unique_ID = self.state.queue[index] - if (index < self.state.max_active_torrents or self.state_max_active_torrents == -1) \ - and self.get_core_torrent_state(unique_ID, efficient)['is_paused'] \ - and not self.is_user_paused(unique_ID): - deluge_core.resume(unique_ID) - elif not self.get_core_torrent_state(unique_ID, efficient)['is_paused'] and \ - (index >= self.state.max_active_torrents or self.is_user_paused(unique_ID)): - deluge_core.pause(unique_ID) + # Pause and resume torrents + for index in range(len(self.state.queue)): + unique_ID = self.state.queue[index] + if (index < self.state.max_active_torrents or self.state_max_active_torrents == -1) \ + and self.get_core_torrent_state(unique_ID, efficient)['is_paused'] \ + and not self.is_user_paused(unique_ID): + deluge_core.resume(unique_ID) + elif not self.get_core_torrent_state(unique_ID, efficient)['is_paused'] and \ + (index >= self.state.max_active_torrents or self.is_user_paused(unique_ID)): + deluge_core.pause(unique_ID) + except AttributeError: + pass # Event handling diff --git a/src/delugegtk.py b/src/delugegtk.py index 387f23e2a..ce8612806 100644 --- a/src/delugegtk.py +++ b/src/delugegtk.py @@ -140,6 +140,7 @@ class DelugeGTK: ## Help Menu "show_about_dialog": self.show_about_dialog, ## Toolbar + "start_pause": self.start_pause, "update_tracker": self.update_tracker, "clear_finished": self.clear_finished, "queue_up": self.q_torrent_up, @@ -329,6 +330,11 @@ class DelugeGTK: else: return False + def start_pause(self, widget): + print "Pause btn clicked" + unique_id = self.get_selected_torrent() + self.manager.set_user_pause(unique_id, not self.manager.is_user_paused(unique_id)) + def build_summary_tab(self): #Torrent Summary tab # Look into glade's widget prefix function @@ -586,6 +592,11 @@ class DelugeGTK: if not self.torrent_model.iter_is_valid(itr): itr = None + if self.manager.is_user_paused(self.get_selected_torrent()): + self.wtree.get_widget("toolbutton_pause").set_stock_id(gtk.STOCK_MEDIA_PLAY) + else: + self.wtree.get_widget("toolbutton_pause").set_stock_id(gtk.STOCK_MEDIA_PAUSE) + self.saved_peer_info = None