diff --git a/glade/preferences_dialog.glade b/glade/preferences_dialog.glade index 5c4e4b86e..8bd426b4f 100644 --- a/glade/preferences_dialog.glade +++ b/glade/preferences_dialog.glade @@ -295,8 +295,22 @@ True 0 True + + + + True + True + Queue new torrents above completed ones + True + 0 + True + + + 1 + + True @@ -331,7 +345,7 @@ - 1 + 2 @@ -344,7 +358,7 @@ True - 2 + 3 diff --git a/src/core.py b/src/core.py index 213b7c72f..2a4f11c1a 100644 --- a/src/core.py +++ b/src/core.py @@ -798,7 +798,15 @@ class Manager: # Add torrents to queue - at the end, of course for unique_ID in self.unique_IDs.keys(): if unique_ID not in self.state.queue: - self.state.queue.append(unique_ID) + if (self.get_pref('queue_above_completed')) and len(self.state.queue) > 0: + for index in range(len(self.state.queue)): + torrent_state = self.get_core_torrent_state(self.state.queue[index]) + if torrent_state['progress'] == 1.0: + break + self.state.queue.insert(index, unique_ID) + + else: + self.state.queue.append(unique_ID) # run through queue, remove those that no longer exists to_delete = [] for queue_item in self.state.queue: diff --git a/src/dialogs.py b/src/dialogs.py index 188e86218..0f5d05904 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -46,6 +46,7 @@ class PreferencesDlg: 'on_chk_use_tray_toggled': self.tray_toggle, 'on_save_all_to' : self.toggle_move_chk, 'on_ask_save' : self.toggle_move_chk, + 'on_chk_seedbottom' : self.toggle_queue_above_completed_chk, 'on_chk_autoseed' : self.toggle_clear_max_ratio_torrents_chk, 'on_btn_testport_clicked': self.TestPort, }) @@ -98,6 +99,8 @@ class PreferencesDlg: self.glade.get_widget("spin_proxy_port").set_value(self.preferences.get("proxy_port")) self.glade.get_widget("spin_torrents").set_value(float(self.preferences.get("max_active_torrents"))) self.glade.get_widget("chk_seedbottom").set_active(self.preferences.get("queue_seeds_to_bottom")) + self.glade.get_widget("chk_queue_above_completed").set_sensitive(self.preferences.get("queue_seeds_to_bottom")) + self.glade.get_widget("chk_queue_above_completed").set_active(self.preferences.get("queue_above_completed")) self.glade.get_widget("chk_autoseed").set_active(self.preferences.get("auto_end_seeding")) self.glade.get_widget("chk_clear_max_ratio_torrents").set_sensitive(self.preferences.get("auto_end_seeding")) self.glade.get_widget("chk_clear_max_ratio_torrents").set_active(self.preferences.get("clear_max_ratio_torrents")) @@ -150,6 +153,7 @@ class PreferencesDlg: self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active()) self.preferences.set("gui_update_interval", self.glade.get_widget("spin_gui").get_value()) self.preferences.set("clear_max_ratio_torrents", self.glade.get_widget("chk_clear_max_ratio_torrents").get_active()) + self.preferences.set("queue_above_completed", self.glade.get_widget("chk_queue_above_completed").get_active()) return r @@ -171,6 +175,13 @@ class PreferencesDlg: self.glade.get_widget("chk_clear_max_ratio_torrents").set_active(False) self.glade.get_widget("chk_clear_max_ratio_torrents").set_sensitive(False) + def toggle_queue_above_completed_chk(self, widget): + if(self.glade.get_widget("chk_seedbottom").get_active()): + self.glade.get_widget("chk_queue_above_completed").set_sensitive(True) + else: + self.glade.get_widget("chk_queue_above_completed").set_active(False) + self.glade.get_widget("chk_queue_above_completed").set_sensitive(False) + def toggle_move_chk(self, widget): if(self.glade.get_widget("radio_ask_save").get_active()): self.glade.get_widget("chk_move_completed").set_active(False) diff --git a/src/pref.py b/src/pref.py index f13bba35e..1c8600e9c 100644 --- a/src/pref.py +++ b/src/pref.py @@ -42,6 +42,7 @@ DEFAULT_PREFS = { "auto_seed_ratio" : 0, "close_to_tray" : False, "enable_files_dialog" : False, + "queue_above_completed" : False, "clear_max_ratio_torrents" : False, "default_download_path" : os.path.expanduser("~/"), "default_load_path" : os.path.expanduser("~/"),