diff --git a/deluge/core/core.py b/deluge/core/core.py index 15a7d0c24..e01250a6c 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -432,10 +432,10 @@ class Core( # Run the plugin hooks for 'post_torrent_add' self.plugins.run_post_torrent_add(torrent_id) - def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data): + def export_remove_torrent(self, torrent_ids, remove_data): log.debug("Removing torrent %s from the core.", torrent_ids) for torrent_id in torrent_ids: - if self.torrents.remove(torrent_id, remove_torrent, remove_data): + if self.torrents.remove(torrent_id, remove_data): # Run the plugin hooks for 'post_torrent_remove' self.plugins.run_post_torrent_remove(torrent_id) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index fd0bebc80..2785d9a71 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -421,30 +421,15 @@ class TorrentManager(component.Component): return filedump - def remove(self, torrent_id, remove_torrent=False, remove_data=False): + def remove(self, torrent_id, remove_data=False): """Remove a torrent from the manager""" try: - # Remove from libtorrent session - option = 0 - # Remove data if set - if remove_data: - option = 1 self.session.remove_torrent(self.torrents[torrent_id].handle, - option) + 1 if remove_data else 0) except (RuntimeError, KeyError), e: log.warning("Error removing torrent: %s", e) return False - # Remove the .torrent file if requested - if remove_torrent: - try: - torrent_file = os.path.join( - self.config["torrentfiles_location"], - self.torrents[torrent_id].filename) - os.remove(torrent_file) - except Exception, e: - log.warning("Unable to remove .torrent file: %s", e) - # Remove the .fastresume if it exists self.torrents[torrent_id].delete_fastresume() diff --git a/deluge/ui/console/commands/rm.py b/deluge/ui/console/commands/rm.py index afde058ce..f8a9d9267 100644 --- a/deluge/ui/console/commands/rm.py +++ b/deluge/ui/console/commands/rm.py @@ -12,8 +12,6 @@ class Command(BaseCommand): aliases = ['del'] option_list = BaseCommand.option_list + ( - make_option('--remove_torrent', action='store_true', default=False, - help="remove the torrent's file"), make_option('--remove_data', action='store_true', default=False, help="remove the torrent's data"), ) @@ -22,7 +20,7 @@ class Command(BaseCommand): try: args = mapping.to_ids(args) torrents = match_torrents(args) - client.remove_torrent(torrents, options['remove_torrent'], options['remove_data']) + client.remove_torrent(torrents, options['remove_data']) except Exception, msg: print template.ERROR(str(msg)) diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index db7b6f6ea..112d46329 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -316,21 +316,30 @@ gtk-add + + False + - + True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Remove Torrent gtk-remove + + False + True + + False + False + @@ -342,6 +351,9 @@ gtk-media-pause + + False + @@ -353,11 +365,18 @@ gtk-media-play + + False + True + + False + False + @@ -369,6 +388,9 @@ gtk-go-up + + False + @@ -380,12 +402,19 @@ gtk-go-down + + False + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + False + False + @@ -396,6 +425,9 @@ gtk-preferences + + False + @@ -406,6 +438,9 @@ gtk-network + + False + @@ -640,290 +675,165 @@ 10 5 - - True - 0 - - - 5 - 6 - 3 - 4 - GTK_FILL - - - - - True - 0 - <b>Auto Managed:</b> - True - - - 4 - 5 - 3 - 4 - GTK_FILL - - - - + True 0 7 8 - 2 - 3 - GTK_FILL - - - - - True - 0 - - - 7 - 8 - 1 - 2 - GTK_FILL - - - - - True - 0 - <b>Seed Rank:</b> - True - - - 6 - 7 - 2 - 3 - GTK_FILL - - - - - True - 0 - <b>Seeding Time:</b> - True - - - 6 - 7 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 7 - 8 - GTK_FILL - - - - - True - 0 - <b>Active Time:</b> - True - - - 6 - 7 - GTK_FILL - - - - - True - 0 - True - - - 1 - 2 3 4 GTK_FILL - + True 0 + <b>Date Added:</b> + True - 3 - 4 + 6 + 7 3 4 GTK_FILL - - True - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 8 - 4 - 5 - GTK_FILL - - - - - True - 0 - 0 - <b>Tracker Status:</b> - True - - - 4 - 5 - GTK_FILL - GTK_FILL - - - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 5 - 6 - 2 - 3 - GTK_FILL - - - - - True - 0 - 1 - <b>Availability:</b> - True - - - 4 - 5 - 2 - 3 - GTK_FILL - - - - - True - 0 - - - 3 - 4 - 2 - 3 - GTK_FILL - - - - + True 0 1 2 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + GTK_FILL + + + + + True + 0 + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 1 + 2 + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Downloaded:</b> + True + + + + + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Uploaded:</b> + True + + + + + 1 + 2 + GTK_FILL + + + + + True + 5 + + + True + 0 + <b>Share Ratio:</b> + True + + + + 2 3 GTK_FILL - + True - 0 + 5 + + + True + 0 + <b>Next Announce:</b> + True + + - 5 - 6 - 1 - 2 + 3 + 4 GTK_FILL - - True - 0 - <b>Peers:</b> - True - - - 4 - 5 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 5 - 6 - GTK_FILL - - - - - True - 0 - <b>Seeders:</b> - True - - - 4 - 5 - GTK_FILL - - - - + True 15 5 - + True 0 - <b>Pieces:</b> + <b>Speed:</b> True @@ -931,30 +841,6 @@ 2 3 - 3 - 4 - GTK_FILL - - - - - True - 15 - 5 - - - True - 0 - <b>ETA:</b> - True - - - - - 2 - 3 - 2 - 3 GTK_FILL @@ -981,15 +867,15 @@ - + True 15 5 - + True 0 - <b>Speed:</b> + <b>ETA:</b> True @@ -997,154 +883,303 @@ 2 3 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Next Announce:</b> - True - - - - - 3 - 4 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Share Ratio:</b> - True - - - - 2 3 GTK_FILL - + True + 15 5 - + True 0 - <b>Uploaded:</b> + <b>Pieces:</b> True - 1 - 2 - GTK_FILL - - - - - True - 5 - - - True - 0 - <b>Downloaded:</b> - True - - - - - GTK_FILL - - - - - True - 0 - - - 3 - 4 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - 0 - - - 3 - 4 - GTK_FILL - - - - - True - 0 - - - 1 - 2 - GTK_FILL - - - - - True - 0 - <b>Date Added:</b> - True - - - 6 - 7 + 2 + 3 3 4 GTK_FILL - + + True + 0 + <b>Seeders:</b> + True + + + 4 + 5 + GTK_FILL + + + + + True + 0 + + + 5 + 6 + GTK_FILL + + + + + True + 0 + <b>Peers:</b> + True + + + 4 + 5 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 5 + 6 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 2 + 3 + GTK_FILL + + + + + True + 0 + 1 + <b>Availability:</b> + True + + + 4 + 5 + 2 + 3 + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 5 + 6 + 2 + 3 + GTK_FILL + + + + + True + 0 + 0 + <b>Tracker Status:</b> + True + + + 4 + 5 + GTK_FILL + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 8 + 4 + 5 + GTK_FILL + + + + + True + 0 + + + 3 + 4 + 3 + 4 + GTK_FILL + + + + + True + 0 + True + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + True + 0 + <b>Active Time:</b> + True + + + 6 + 7 + GTK_FILL + + + + True 0 7 8 + GTK_FILL + + + + + True + 0 + <b>Seeding Time:</b> + True + + + 6 + 7 + 1 + 2 + GTK_FILL + + + + + True + 0 + <b>Seed Rank:</b> + True + + + 6 + 7 + 2 + 3 + GTK_FILL + + + + + True + 0 + + + 7 + 8 + 1 + 2 + GTK_FILL + + + + + True + 0 + + + 7 + 8 + 2 + 3 + GTK_FILL + + + + + True + 0 + <b>Auto Managed:</b> + True + + + 4 + 5 + 3 + 4 + GTK_FILL + + + + + True + 0 + + + 5 + 6 3 4 GTK_FILL @@ -1234,7 +1269,7 @@ - + True 0 True @@ -1242,114 +1277,45 @@ 1 2 - 4 - 5 - - - - - - True - 0 - 1 - <b># of files:</b> - True - - - 4 - 5 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - True - PANGO_WRAP_CHAR - True - - - 1 - 4 - 1 - 2 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <b>Hash:</b> - True - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - PANGO_WRAP_CHAR - True - - - 1 - 4 - 6 - 7 - - - - - - True - 0 - 1 - <b>Tracker:</b> - True - - - 6 - 7 - GTK_FILL - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Total Size:</b> - True - - - - 3 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + True + + + 1 + 4 + 5 + 6 + + + + + + True + 0 + 1 + <b>Status:</b> + True + + + 5 + 6 GTK_FILL - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 True PANGO_WRAP_CHAR @@ -1358,27 +1324,8 @@ 1 4 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 0 - 1 - <b>Name:</b> - True - - - - - GTK_FILL + 2 + 3 @@ -1405,7 +1352,110 @@ - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Name:</b> + True + + + + + GTK_FILL + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_STRUCTURE_MASK + 0 + True + PANGO_WRAP_CHAR + True + + + 1 + 4 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Total Size:</b> + True + + + + + 3 + 4 + GTK_FILL + + + + + + True + 0 + 1 + <b>Tracker:</b> + True + + + 6 + 7 + GTK_FILL + + + + + + True + 0 + PANGO_WRAP_CHAR + True + + + 1 + 4 + 6 + 7 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <b>Hash:</b> + True + + + 1 + 2 + GTK_FILL + + + + + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 @@ -1416,43 +1466,28 @@ 1 4 - 2 - 3 + 1 + 2 - + True 0 1 - <b>Status:</b> + <b># of files:</b> True - 5 - 6 + 4 + 5 GTK_FILL - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - True - - - 1 - 4 - 5 - 6 - - - - - + True 0 True @@ -1460,8 +1495,8 @@ 1 2 - 3 - 4 + 4 + 5 @@ -1642,7 +1677,7 @@ - + True True 6 @@ -1652,8 +1687,100 @@ 1 2 + 3 + 4 + + + + + + + True + 0 + Max Upload Slots: + + + 3 + 4 + GTK_FILL + + + + + + True + KiB/s + + + 2 + 3 + 1 + 2 + + + + + + + True + KiB/s + + + 2 + 3 + + + + + + + True + 0 + Max Download Speed: + + + GTK_FILL + + + + + + True + 0 + Max Upload Speed: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Max Connections: + + 2 3 + GTK_FILL + + + + + + True + True + 6 + 1 + -1 -1 999999 1 10 10 + 1 + + + 1 + 2 @@ -1677,110 +1804,18 @@ - + True True 6 1 -1 -1 999999 1 10 10 - 1 1 2 - - - - - - - True - 0 - Max Connections: - - 2 3 - GTK_FILL - - - - - - True - 0 - Max Upload Speed: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Max Download Speed: - - - GTK_FILL - - - - - - True - KiB/s - - - 2 - 3 - - - - - - - True - KiB/s - - - 2 - 3 - 1 - 2 - - - - - - - True - 0 - Max Upload Slots: - - - 3 - 4 - GTK_FILL - - - - - - True - True - 6 - 1 - -1 -1 999999 1 10 10 - - - 1 - 2 - 3 - 4 @@ -2419,14 +2454,23 @@ 10 2 - + + True + 0 + <i>Current Version:</i> + True + + + GTK_FILL + + + + True 1 2 - 1 - 2 @@ -2444,26 +2488,17 @@ - + True 1 2 + 1 + 2 - - - True - 0 - <i>Current Version:</i> - True - - - GTK_FILL - - diff --git a/deluge/ui/gtkui/glade/remove_torrent_dialog.glade b/deluge/ui/gtkui/glade/remove_torrent_dialog.glade index c3fce706f..290eb55a3 100644 --- a/deluge/ui/gtkui/glade/remove_torrent_dialog.glade +++ b/deluge/ui/gtkui/glade/remove_torrent_dialog.glade @@ -1,56 +1,32 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - Remove Torrent? False + True GTK_WIN_POS_CENTER_ON_PARENT + True GDK_WINDOW_TYPE_HINT_DIALOG - False + False True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 2 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 + 10 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 10 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-dialog-warning - 6 - - - False - False - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <big><b>Are you sure you want to remove the selected torrent?</b></big> - True - True - - - False - False - 1 - - + gtk-dialog-warning + 6 False @@ -58,99 +34,23 @@ - + + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <big><b>Are you sure you want to remove the selected torrent?</b></big> + True False + False 1 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 15 - - - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-dialog-warning - - - False - False - 1 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <i>The associated .torrent will be deleted!</i> - True - - - 1 - - - - - - - 2 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 15 - - - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-dialog-warning - - - False - False - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <i>The downloaded data will be deleted!</i> - True - - - 1 - - - - - - - 3 - - False False - 5 - 1 + 2 @@ -163,25 +63,38 @@ True True True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-cancel + gtk-cancel True - 0 + -6 + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Remove Torrent and Data + 2 + + + + 1 + + True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Remove Selected Torrent - 0 + Remove Torrent + 1 - 1 + 2 diff --git a/deluge/ui/gtkui/glade/torrent_menu.glade b/deluge/ui/gtkui/glade/torrent_menu.glade index 496fd7d61..eef4f5adc 100644 --- a/deluge/ui/gtkui/glade/torrent_menu.glade +++ b/deluge/ui/gtkui/glade/torrent_menu.glade @@ -151,6 +151,7 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _Remove Torrent True + True @@ -201,46 +202,6 @@ - - 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 - From Session - True - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - .. And Delete Torrent File - True - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - .. And Delete Downloaded Files - True - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - .. And Delete All Files - True - - - - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -331,7 +292,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-go-up + gtk-go-up True True @@ -341,7 +302,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-go-down + gtk-go-down True True diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 77ed93de0..89eb24dd9 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -49,10 +49,6 @@ class MenuBar(component.Component): pkg_resources.resource_filename("deluge.ui.gtkui", "glade/torrent_menu.glade")) - # Attach remove torrent menu - self.torrentmenu_glade.get_widget("menuitem_remove").set_submenu( - self.torrentmenu_glade.get_widget("remove_torrent_menu")) - self.torrentmenu_glade.get_widget("menuitem_queue").set_submenu( self.torrentmenu_glade.get_widget("queue_torrent_menu")) @@ -147,15 +143,8 @@ class MenuBar(component.Component): self.on_menuitem_updatetracker_activate, "on_menuitem_edittrackers_activate": \ self.on_menuitem_edittrackers_activate, - "on_menuitem_remove_session_activate": \ - self.on_menuitem_remove_session_activate, - "on_menuitem_remove_torrentfile_activate": \ - self.on_menuitem_remove_torrentfile_activate, - "on_menuitem_remove_data_activate": \ - self.on_menuitem_remove_data_activate, - "on_menuitem_remove_both_activate": \ - self.on_menuitem_remove_both_activate, - + "on_menuitem_remove_activate": \ + self.on_menuitem_remove_activate, "on_menuitem_recheck_activate": self.on_menuitem_recheck_activate, "on_menuitem_open_folder_activate": self.on_menuitem_open_folder_activate, "on_menuitem_move_activate": self.on_menuitem_move_activate, @@ -287,33 +276,10 @@ class MenuBar(component.Component): component.get("MainWindow").window) dialog.run() - def on_menuitem_remove_session_activate(self, data=None): - log.debug("on_menuitem_remove_session_activate") + def on_menuitem_remove_activate(self, data=None): + log.debug("on_menuitem_remove_activate") from removetorrentdialog import RemoveTorrentDialog - RemoveTorrentDialog( - component.get("TorrentView").get_selected_torrents()).run() - - def on_menuitem_remove_torrentfile_activate(self, data=None): - log.debug("on_menuitem_remove_torrentfile_activate") - from removetorrentdialog import RemoveTorrentDialog - RemoveTorrentDialog( - component.get("TorrentView").get_selected_torrents(), - remove_torrentfile=True).run() - - def on_menuitem_remove_data_activate(self, data=None): - log.debug("on_menuitem_remove_data_activate") - from removetorrentdialog import RemoveTorrentDialog - RemoveTorrentDialog( - component.get("TorrentView").get_selected_torrents(), - remove_data=True).run() - - def on_menuitem_remove_both_activate(self, data=None): - log.debug("on_menuitem_remove_both_activate") - from removetorrentdialog import RemoveTorrentDialog - RemoveTorrentDialog( - component.get("TorrentView").get_selected_torrents(), - remove_torrentfile=True, - remove_data=True).run() + RemoveTorrentDialog(component.get("TorrentView").get_selected_torrents()).run() def on_menuitem_recheck_activate(self, data=None): log.debug("on_menuitem_recheck_activate") diff --git a/deluge/ui/gtkui/removetorrentdialog.py b/deluge/ui/gtkui/removetorrentdialog.py index 75b9033cb..9c2cf24cf 100644 --- a/deluge/ui/gtkui/removetorrentdialog.py +++ b/deluge/ui/gtkui/removetorrentdialog.py @@ -1,7 +1,7 @@ # # removetorrentdialog.py # -# Copyright (C) 2007 Andrew Resch +# Copyright (C) 2007, 2008 Andrew Resch # # Deluge is free software. # @@ -22,62 +22,72 @@ # Boston, MA 02110-1301, USA. # - import gtk, gtk.glade import pkg_resources -import deluge.common from deluge.ui.client import aclient as client import deluge.component as component from deluge.log import LOG as log -import deluge.ui.gtkui.common as common -class RemoveTorrentDialog: - def __init__(self, torrent_ids, remove_torrentfile=False, remove_data=False): - self.torrent_ids = torrent_ids - self.remove_torrentfile = remove_torrentfile - self.remove_data = remove_data +class RemoveTorrentDialog(object): + """ + This class is used to create and show a Remove Torrent Dialog. - self.glade = gtk.glade.XML( + :param torrent_ids: a list of torrent_ids to remove + + :raises TypeError: if :param:`torrent_id` is not a sequence type + :raises ValueError: if :param:`torrent_id` contains no torrent_ids or is None + + """ + def __init__(self, torrent_ids): + if type(torrent_ids) != list and type(torrent_ids) != tuple: + raise TypeError("requires a list of torrent_ids") + + if not torrent_ids: + raise ValueError("requires a list of torrent_ids") + + self.__torrent_ids = torrent_ids + + glade = gtk.glade.XML( pkg_resources.resource_filename("deluge.ui.gtkui", "glade/remove_torrent_dialog.glade")) - self.dialog = self.glade.get_widget("remove_torrent_dialog") - self.dialog.set_icon(common.get_logo(32)) - self.dialog.set_transient_for(component.get("MainWindow").window) + self.__dialog = glade.get_widget("remove_torrent_dialog") + self.__dialog.set_transient_for(component.get("MainWindow").window) + self.__dialog.set_title("") - self.glade.signal_autoconnect({ - "on_button_ok_clicked": self.on_button_ok_clicked, - "on_button_cancel_clicked": self.on_button_cancel_clicked - }) - - if len(self.torrent_ids) > 1: + if len(self.__torrent_ids) > 1: # We need to pluralize the dialog - self.dialog.set_title("Remove Torrents?") - self.glade.get_widget("label_title").set_markup( - _("Are you sure you want to remove the selected torrents?")) - self.glade.get_widget("button_ok").set_label(_("Remove Selected Torrents")) + label_title = glade.get_widget("label_title") + button_ok = glade.get_widget("button_ok") + button_data = glade.get_widget("button_data") - if self.remove_torrentfile or self.remove_data: - self.glade.get_widget("hseparator1").show() - if self.remove_torrentfile: - self.glade.get_widget("hbox_torrentfile").show() - if self.remove_data: - self.glade.get_widget("hbox_data").show() + def pluralize_torrents(text): + plural_torrent = _("Torrents") + return text.replace("torrent", plural_torrent.lower()).replace("Torrent", plural_torrent) - def run(self): - if self.torrent_ids == None or self.torrent_ids == []: - self.dialog.destroy() - return - self.dialog.show() + label_title.set_markup(pluralize_torrents(label_title.get_label())) + button_ok.set_label(pluralize_torrents(button_ok.get_label())) + button_data.set_label(pluralize_torrents(button_data.get_label())) - def on_button_ok_clicked(self, widget): - client.remove_torrent( - self.torrent_ids, self.remove_torrentfile, self.remove_data) + def __remove_torrents(self, remove_data): + client.remove_torrent(self.__torrent_ids, remove_data) # Unselect all to avoid issues with the selection changed event component.get("TorrentView").treeview.get_selection().unselect_all() - self.dialog.destroy() - def on_button_cancel_clicked(self, widget): - self.dialog.destroy() + def run(self): + """ + Shows the dialog and awaits for user input. The user can select to + remove the torrent(s) from the session with or without their data. + """ + # Response IDs from the buttons + RESPONSE_SESSION = 1 + RESPONSE_DATA = 2 + response = self.__dialog.run() + if response == RESPONSE_SESSION: + self.__remove_torrents(False) + elif response == RESPONSE_DATA: + self.__remove_torrents(True) + + self.__dialog.destroy() diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index b5c509b0f..d8c91159d 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -63,11 +63,6 @@ class ToolBar(component.Component): "toolbutton_queue_down" ] - # Set the Remove Torrent toolbuttons drop-down menu - tb_remove = self.window.main_glade.get_widget("toolbutton_remove") - tb_remove.set_menu( - component.get("MenuBar").torrentmenu_glade.get_widget("remove_torrent_menu")) - if self.config["classic_mode"]: self.window.main_glade.get_widget("toolbutton_connectionmanager").hide() @@ -142,7 +137,7 @@ class ToolBar(component.Component): def on_toolbutton_remove_clicked(self, data): log.debug("on_toolbutton_remove_clicked") # Use the menubar's callbacks - component.get("MenuBar").on_menuitem_remove_session_activate(data) + component.get("MenuBar").on_menuitem_remove_activate(data) def on_toolbutton_pause_clicked(self, data): log.debug("on_toolbutton_pause_clicked") diff --git a/deluge/ui/null/deluge_shell.py b/deluge/ui/null/deluge_shell.py index f98486b39..f65e4a5a8 100755 --- a/deluge/ui/null/deluge_shell.py +++ b/deluge/ui/null/deluge_shell.py @@ -404,7 +404,7 @@ class CommandRemove(Command): return try: torrents = self.match_torrents(cmd[1:]) - client.remove_torrent(torrents, False, False) + client.remove_torrent(torrents, False) except Exception, msg: print "*** Error:", str(msg), "\n" @@ -500,4 +500,3 @@ class NullUI: print print "Thanks." - diff --git a/deluge/ui/webui/pages.py b/deluge/ui/webui/pages.py index ebb22f222..dd5f5c27a 100644 --- a/deluge/ui/webui/pages.py +++ b/deluge/ui/webui/pages.py @@ -192,7 +192,7 @@ class torrent_delete: vars = web.input(data_also = None, torrent_also = None) data_also = bool(vars.data_also) torrent_also = bool(vars.torrent_also) - proxy.remove_torrent(torrent_ids, torrent_also, data_also) + proxy.remove_torrent(torrent_ids, data_also) do_redirect() route("/torrent/delete/(.*)",torrent_delete) @@ -487,7 +487,3 @@ class gettext: web.header("Content-Type", "text/javascript") print render.gettext() route("/gettext.js", gettext) - - - - diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js b/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js index db7669503..428bf307e 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js @@ -10,7 +10,7 @@ Copyright: Object: Deluge.UI - The object that manages + The object that manages Example: Deluge.Grid.initialize(); @@ -21,11 +21,11 @@ Deluge.UI = { this.torrents = {}; this.torrentIds = []; Deluge.Client = new JSON.RPC('/json/rpc'); - + var theme = Cookie.read('theme'); if (theme) this.setTheme(theme); else this.setTheme('classic'); - + this.bound = { onUpdate: this.onUpdate.bindWithEvent(this), onResize: this.onResize.bindWithEvent(this), @@ -38,32 +38,32 @@ Deluge.UI = { if (this.vbox) this.vbox.calculatePositions(); }.bindWithEvent(this)); }, - + /* Property: loadUI A method to load the UI after a delayed period of time until mooui has been fixed to allow a refresh of the widgets to gather the new style information. - + Example: Deluge.UI.loadUI(); */ loadUI: function() { this.vbox = new Widgets.VBox('page', {expand: true}); - + this.toolbar = new Deluge.Widgets.Toolbar(); this.addWindow = new Deluge.Widgets.AddWindow(); this.createWindow = new Deluge.Widgets.CreateTorrent(); if (Browser.Engine.name != 'trident') { this.prefsWindow = new Deluge.Widgets.PreferencesWindow(); } - + this.statusbar = new Deluge.Widgets.StatusBar(); this.labels = new Deluge.Widgets.Labels() this.details = new Deluge.Widgets.Details() - + this.initializeGrid() - + this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, { pane1: {min: 180}, pane2: {min: 100, expand: true} @@ -74,36 +74,36 @@ Deluge.UI = { pane1: {min: 100, expand: true}, pane2: {min: 200} }); - + this.vbox.addBox(this.toolbar, {fixed: true}); this.vbox.addBox(this.splitVert); this.vbox.addBox(this.statusbar, {fixed: true}); this.vbox.calculatePositions(); this.details.expand() - + this.toolbar.addEvent('buttonClick', this.bound.onToolbarClick); this.details.addEvent('filesAction', this.bound.onFilesAction); this.labels.addEvent('filterChanged', this.bound.onFilterChanged); details.addEvent('resize', function(e) { this.details.expand(); }.bindWithEvent(this)); - + this.initialized = true; window.addEvent('resize', this.bound.onResize); Deluge.UI.update(); this.overlay = $('overlay').dispose(); }, - + /* Property: initializeGrid Initializes the Deluge torrent grid. - + Example: Deluge.UI.initializeGrid(); */ initializeGrid: function() { this.grid = new Deluge.Widgets.TorrentGrid('torrents') - + var menu = new Widgets.PopupMenu() menu.add(Deluge.Menus.Torrents); menu.addEvent('action', function(e) { @@ -117,7 +117,7 @@ Deluge.UI = { menu.torrent_id = e.row_id menu.show(e) }.bindWithEvent(this)) - + this.grid.addEvent('selectedChanged', function(e) { if ($chk(this.grid.selectedRow)) { this.details.update(this.grid.selectedRow.id); @@ -126,16 +126,16 @@ Deluge.UI = { } }.bindWithEvent(this)) }, - - + + /* Property: setTheme Change the theme of the AJAX UI by unloading the current stylesheet and reloading a different one. - + Arguments: name: the name of the theme to be switched too. - + Example: Deluge.UI.setTheme('white'); */ @@ -163,12 +163,12 @@ Deluge.UI = { }.periodical(50, this); }; }, - + /* Property: run Start the Deluge UI polling the server to get the updated torrent information. - + Example: Deluge.UI.run(); */ @@ -177,12 +177,12 @@ Deluge.UI = { this.running = this.update.periodical(2000, this); } }, - + /* Property: stop Stop the Deluge UI polling the server to get the updated torrent information. - + Example: Deluge.UI.stop(); */ @@ -192,18 +192,18 @@ Deluge.UI = { this.running = false; } }, - + /* Property: update The function that is called to perform the update to the UI. - + Example: Deluge.UI.update(); */ update: function() { filter = {}; if (!this.initialized) return; - var type = this.labels.filterType, name = this.labels.filterName + var type = this.labels.filterType, name = this.labels.filterName if (type && !(type == 'state' && name == 'All')) { filter[this.labels.filterType] = this.labels.filterName; } @@ -211,14 +211,14 @@ Deluge.UI = { onSuccess: this.bound.onUpdate }); }, - + /* Property: onUpdate Event handler for when the update data is returned from the server. - + Arguments: data - The data returned from the server - + Example: Deluge.Client.update_ui(Deluge.Keys.Grid, filter, { onSuccess: this.onUpdate.bindWithEvent(this) @@ -234,7 +234,7 @@ Deluge.UI = { }) this.grid.updateTorrents(this.torrents); this.statusbar.update(this.stats); - + if ($chk(this.grid.selectedRow)) { this.details.update(this.grid.selectedRow.id); } else { @@ -242,14 +242,14 @@ Deluge.UI = { } this.labels.update(this.filters); }, - + /* Property: onFilesAction Event handler for when a torrents file priorities have been changed. - + Arguments: e - The event args - + Example: details.addEvent('filesAction', this.onFilesAction.bindWithEvent(this)); */ @@ -265,63 +265,63 @@ Deluge.UI = { Deluge.Client.set_torrent_file_priorities(event.torrentId, priorities, { onSuccess: function(response) { this.details.update(event.torrentId) - }.bindWithEvent(this) + }.bindWithEvent(this) }) }.bindWithEvent(this) }) }, - + /* Property: onResize Event handler for when the page is resized - + Arguments: e - The event args - + Example: window.addEvent('resize', this.onResize.bindWithEvent(this)); */ onResize: function(e) { this.vbox.calculatePositions(); }, - + /* Property: onToolbarClick Event handler for when a list item is clicked - + Arguments: e - The event args - + Example: toolbar.addEvent('buttonClick', this.onToolbarClick.bindWithEvent(this)); */ onToolbarClick: function(e) { this.torrentAction(e.action); }, - + /* Property: onFilterChanged Event handler for when a filter is changed in the sidebar. - + Arguments: e - The event args - + Example: labels.addEvent('filterChanged', this.onFilterChanged.bindWithEvent(this)); */ onFilterChanged: function(e) { this.update(); }, - + /* Property: torrentAction Peform either a global action or and action on selected torrents and then update the UI after performing the action. - + Arguments: action - The action to perform value - The value accompanying the action, if there is one. - + Example: Deluge.UI.torrentAction('resume'); */ @@ -396,7 +396,7 @@ Deluge.UI = { removeTorrent = true; removeFiles = true; } - client.remove_torrent(torrentIds, removeTorrent, removeFiles); + client.remove_torrent(torrentIds, removeFiles); break; case 'preferences': this.prefsWindow.show(); diff --git a/deluge/ui/webui/tests/test_all.py b/deluge/ui/webui/tests/test_all.py index 5b4354ceb..dcbf24a92 100644 --- a/deluge/ui/webui/tests/test_all.py +++ b/deluge/ui/webui/tests/test_all.py @@ -230,7 +230,7 @@ class TestIntegration(TestWebUiBase): #delete all, nice use case for refactoring delete.. torrent_ids = proxy.get_session_state() for torrent in torrent_ids: - proxy.remove_torrent([torrent], False, False) + proxy.remove_torrent([torrent], False) torrent_ids = proxy.get_session_state() self.assertEqual(torrent_ids, []) @@ -411,4 +411,3 @@ elif False: else: unittest.main() -