From 4ea66b684f61be6cac3777a21c21e4ce0b2633e7 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Wed, 4 Jul 2007 08:48:20 +0000 Subject: [PATCH] activates or deactivates the queue-up/down arrows depending on which torrents are selected. It also makes it possible to move several torrents at the same time - Mattias Bengtsson --- glade/torrent_menu.glade | 8 +++--- src/interface.py | 61 +++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/glade/torrent_menu.glade b/glade/torrent_menu.glade index 70f9eebf9..c5ace73f5 100644 --- a/glade/torrent_menu.glade +++ b/glade/torrent_menu.glade @@ -85,7 +85,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _Top @@ -102,7 +102,7 @@ - + True _Up True @@ -118,7 +118,7 @@ - + True _Down True @@ -134,7 +134,7 @@ - + True _Bottom True diff --git a/src/interface.py b/src/interface.py index 60554dd6c..26fbca8e1 100644 --- a/src/interface.py +++ b/src/interface.py @@ -931,14 +931,35 @@ class DelugeGTK: if not self.torrent_model.iter_is_valid(itr): itr = None - has_selected_torrents = self.torrent_view.get_selection().count_selected_rows() > 0 - self.wtree.get_widget("menu_torrent").set_sensitive(has_selected_torrents) - self.wtree.get_widget("toolbutton_remove").set_sensitive(has_selected_torrents) - self.wtree.get_widget("toolbutton_pause").set_sensitive(has_selected_torrents) - self.wtree.get_widget("toolbutton_up").set_sensitive(has_selected_torrents) - self.wtree.get_widget("toolbutton_down").set_sensitive(has_selected_torrents) - - if not has_selected_torrents: + # Disable torrent options if no torrents are selected + torrent_selection = self.torrent_view.get_selection() + selection_count = torrent_selection.count_selected_rows() + + self.wtree.get_widget("menu_torrent").set_sensitive(selection_count > 0) + self.wtree.get_widget("toolbutton_remove").set_sensitive(selection_count > 0) + self.wtree.get_widget("toolbutton_pause").set_sensitive(selection_count > 0) + self.wtree.get_widget("toolbutton_up").set_sensitive(selection_count > 0) + self.wtree.get_widget("toolbutton_down").set_sensitive(selection_count > 0) + + # Disable moving top torrents up or bottom torrents down + top_torrents_selected = True + bottom_torrents_selected = True + + for i in range(selection_count): + if not torrent_selection.path_is_selected(i): + top_torrents_selected = False + + if not torrent_selection.path_is_selected(len(self.torrent_model) - 1 - i): + bottom_torrents_selected = False + + self.torrent_glade.get_widget("menu_queue_top").set_sensitive(not top_torrents_selected) + self.torrent_glade.get_widget("menu_queue_up").set_sensitive(not top_torrents_selected) + self.torrent_glade.get_widget("menu_queue_down").set_sensitive(not bottom_torrents_selected) + self.torrent_glade.get_widget("menu_queue_bottom").set_sensitive(not bottom_torrents_selected) + self.wtree.get_widget("toolbutton_up").set_sensitive(not top_torrents_selected) + self.wtree.get_widget("toolbutton_down").set_sensitive(not bottom_torrents_selected) + + if selection_count == 0: return True try: @@ -1234,29 +1255,25 @@ class DelugeGTK: self.update() def q_torrent_up(self, obj=None): - torrent = self.get_selected_torrent() - if torrent is not None: + for torrent in self.get_selected_torrent_rows(): self.manager.queue_up(torrent) - self.update() - + self.update() + def q_torrent_down(self, obj=None): - torrent = self.get_selected_torrent() - if torrent is not None: + for torrent in reversed(self.get_selected_torrent_rows()): self.manager.queue_down(torrent) - self.update() + self.update() def q_to_bottom(self, widget): - torrent = self.get_selected_torrent() - if torrent is not None: + for torrent in self.get_selected_torrent_rows(): self.manager.queue_bottom(torrent) - self.update() + self.update() def q_to_top(self, widget): - torrent = self.get_selected_torrent() - if torrent is not None: + for torrent in reversed(self.get_selected_torrent_rows()): self.manager.queue_top(torrent) - self.update() - + self.update() + def toolbar_toggle(self, widget): if widget.get_active(): self.wtree.get_widget("tb_left").show()