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

This commit is contained in:
Marcos Pinto 2007-07-04 08:48:20 +00:00
parent bdf9182bb5
commit 4ea66b684f
2 changed files with 43 additions and 26 deletions

View File

@ -85,7 +85,7 @@
<property name="visible">True</property> <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="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child> <child>
<widget class="GtkImageMenuItem" id="menuitem1"> <widget class="GtkImageMenuItem" id="menu_queue_top">
<property name="visible">True</property> <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="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Top</property> <property name="label" translatable="yes">_Top</property>
@ -102,7 +102,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menuitem6"> <widget class="GtkImageMenuItem" id="menu_queue_up">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Up</property> <property name="label" translatable="yes">_Up</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -118,7 +118,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menuitem7"> <widget class="GtkImageMenuItem" id="menu_queue_down">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Down</property> <property name="label" translatable="yes">_Down</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -134,7 +134,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menuitem8"> <widget class="GtkImageMenuItem" id="menu_queue_bottom">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Bottom</property> <property name="label" translatable="yes">_Bottom</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>

View File

@ -931,14 +931,35 @@ class DelugeGTK:
if not self.torrent_model.iter_is_valid(itr): if not self.torrent_model.iter_is_valid(itr):
itr = None itr = None
has_selected_torrents = self.torrent_view.get_selection().count_selected_rows() > 0 # Disable torrent options if no torrents are selected
self.wtree.get_widget("menu_torrent").set_sensitive(has_selected_torrents) torrent_selection = self.torrent_view.get_selection()
self.wtree.get_widget("toolbutton_remove").set_sensitive(has_selected_torrents) selection_count = torrent_selection.count_selected_rows()
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: 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 return True
try: try:
@ -1234,26 +1255,22 @@ class DelugeGTK:
self.update() self.update()
def q_torrent_up(self, obj=None): def q_torrent_up(self, obj=None):
torrent = self.get_selected_torrent() for torrent in self.get_selected_torrent_rows():
if torrent is not None:
self.manager.queue_up(torrent) self.manager.queue_up(torrent)
self.update() self.update()
def q_torrent_down(self, obj=None): def q_torrent_down(self, obj=None):
torrent = self.get_selected_torrent() for torrent in reversed(self.get_selected_torrent_rows()):
if torrent is not None:
self.manager.queue_down(torrent) self.manager.queue_down(torrent)
self.update() self.update()
def q_to_bottom(self, widget): def q_to_bottom(self, widget):
torrent = self.get_selected_torrent() for torrent in self.get_selected_torrent_rows():
if torrent is not None:
self.manager.queue_bottom(torrent) self.manager.queue_bottom(torrent)
self.update() self.update()
def q_to_top(self, widget): def q_to_top(self, widget):
torrent = self.get_selected_torrent() for torrent in reversed(self.get_selected_torrent_rows()):
if torrent is not None:
self.manager.queue_top(torrent) self.manager.queue_top(torrent)
self.update() self.update()