From 1f12f3b4211239fe6d6944e5823469834467d374 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Fri, 3 Aug 2007 04:31:07 +0000 Subject: [PATCH] add pause all and resume all to tray --- glade/tray_menu.glade | 34 ++++++++++++++++++++++++++++++++++ src/core.py | 14 ++++++++++++++ src/interface.py | 8 ++++++++ 3 files changed, 56 insertions(+) diff --git a/glade/tray_menu.glade b/glade/tray_menu.glade index 79f19eb67..3217f7bb9 100644 --- a/glade/tray_menu.glade +++ b/glade/tray_menu.glade @@ -14,6 +14,40 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Pause All + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-media-pause + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Resume All + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-media-play + 1 + + + + True diff --git a/src/core.py b/src/core.py index 28907c8ca..8598c7a58 100644 --- a/src/core.py +++ b/src/core.py @@ -935,3 +935,17 @@ class Manager: if speed != -1: speed = speed * 1024 return deluge_core.set_per_download_rate_limit(unique_ID, speed) + + def pause_all(self): + for index, unique_ID in enumerate(self.state.queue): + torrent_state = self.get_core_torrent_state(unique_ID) + if torrent_state['is_paused']: + pass + else: + self.set_user_pause(unique_ID, True, enforce_queue=False) + + def resume_all(self): + for index, unique_ID in enumerate(self.state.queue): + torrent_state = self.get_core_torrent_state(unique_ID) + if torrent_state['is_paused']: + self.set_user_pause(unique_ID, False, enforce_queue=False) diff --git a/src/interface.py b/src/interface.py index 8721dc9be..873b5392e 100644 --- a/src/interface.py +++ b/src/interface.py @@ -169,6 +169,12 @@ class DelugeGTK: # Force an update when user changes the notebook tab self.update_torrent_info_widget(None, page_num) + def pause_all_clicked(self, arg=None): + self.manager.pause_all() + + def resume_all_clicked(self, arg=None): + self.manager.resume_all() + def build_tray_icon(self): self.tray_icon = gtk.status_icon_new_from_file(common.get_pixmap("deluge32.png")) @@ -176,6 +182,8 @@ class DelugeGTK: self.tray_menu = self.tray_glade.get_widget("tray_menu") self.tray_glade.signal_autoconnect({ "quit": self.quit, + "pause_all": self.pause_all_clicked, + "resume_all": self.resume_all_clicked, "plugins": self.show_plugin_dialog_clicked, "preferences": self.show_preferences_dialog_clicked, "add_torrent": self.add_torrent_clicked,