From 739d8f329a43c65b7e2f3e689b189df25bcb6ef0 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 5 Mar 2012 04:41:58 +0000 Subject: [PATCH] [#1859] [GTKUI] Improve layout of Remove torrent dialog * Using Shift+Del will now pre-select removing files. * Will now show the name of the individual torrent being removed or the total count if multiple torrents selected. --- .../ui/gtkui/glade/remove_torrent_dialog.ui | 233 ++++++++---------- deluge/ui/gtkui/removetorrentdialog.py | 35 +-- deluge/ui/gtkui/torrentview.py | 5 +- 3 files changed, 123 insertions(+), 150 deletions(-) diff --git a/deluge/ui/gtkui/glade/remove_torrent_dialog.ui b/deluge/ui/gtkui/glade/remove_torrent_dialog.ui index b3a8fd495..1dabe5d8e 100644 --- a/deluge/ui/gtkui/glade/remove_torrent_dialog.ui +++ b/deluge/ui/gtkui/glade/remove_torrent_dialog.ui @@ -5,6 +5,7 @@ False 5 + Remove Torrent False True center-on-parent @@ -19,7 +20,6 @@ True False - 10 True @@ -35,41 +35,15 @@ - + True False - 5 - - - True - False - 0 - Remove the selected torrent? - - - - - True - - - False - True - 0 - - - - - True - False - 0 - If you remove the data, it will be lost permanently. - - - False - False - 1 - - + 0 + Remove the selected torrent(s)? + + + + True @@ -79,26 +53,55 @@ - False + True + True + 0 + + + + + + + + True + False + 0.05000000074505806 + 5 + end + + + + + + True False - 5 - 1 + 2 + + + + + True + False + + + False + True + 4 True False - center + end - + gtk-cancel + False True True True - False True - False @@ -107,47 +110,13 @@ - + + gtk-ok + False True True True - False - - - - True - False - 2 - - - True - False - 1 - gtk-delete - - - True - True - 0 - - - - - True - False - 0 - Remove With _Data - True - True - - - True - True - 1 - - - - + True False @@ -155,69 +124,69 @@ 1 - - - True - True - True - False - - - - True - False - 2 - - - True - False - 1 - gtk-remove - - - True - True - 0 - - - - - True - False - 0 - Remove _Torrent - True - True - - - True - True - 1 - - - - - - - False - False - 2 - - False True end - 1 + 4 + + + True + False + + + Include downloaded files + False + True + True + False + False + True + + + + False + False + 0 + + + + + False + 0 + 4 + 2 + (This is permanent!) + + + + + + + False + False + 1 + + + + + False + False + 1 + 5 + + + + + - button_cancel - button_data - button_ok + cancel_button + ok_button diff --git a/deluge/ui/gtkui/removetorrentdialog.py b/deluge/ui/gtkui/removetorrentdialog.py index 5446eae39..7ad018aa5 100644 --- a/deluge/ui/gtkui/removetorrentdialog.py +++ b/deluge/ui/gtkui/removetorrentdialog.py @@ -54,7 +54,7 @@ class RemoveTorrentDialog(object): :raises ValueError: if `torrent_id` contains no torrent_ids or is None """ - def __init__(self, torrent_ids): + def __init__(self, torrent_ids, delete_files=False): if type(torrent_ids) != list and type(torrent_ids) != tuple: raise TypeError("requires a list of torrent_ids") @@ -63,28 +63,29 @@ class RemoveTorrentDialog(object): self.__torrent_ids = torrent_ids - builder = gtk.Builder() - builder.add_from_file(deluge.common.resource_filename( + self.builder = gtk.Builder() + self.builder.add_from_file(deluge.common.resource_filename( "deluge.ui.gtkui", os.path.join("glade", "remove_torrent_dialog.ui")) ) - self.__dialog = builder.get_object("remove_torrent_dialog") + self.__dialog = self.builder.get_object("remove_torrent_dialog") self.__dialog.set_transient_for(component.get("MainWindow").window) - self.__dialog.set_title("") - if len(self.__torrent_ids) > 1: - # We need to pluralize the dialog - label_title = builder.get_object("label_title") - button_ok = builder.get_object("button_ok_label") - button_data = builder.get_object("button_data_label") + self.builder.connect_signals({ + "on_delete_files_toggled": self.on_delete_files_toggled + }) + self.builder.get_object('delete_files').set_active(delete_files) + label_title = self.builder.get_object("label_title") + label_torrents = self.builder.get_object("label_torrents") + num_torrents = len(self.__torrent_ids) + if num_torrents == 1: + label_torrents.set_markup(component.get("TorrentView").get_torrent_status(self.__torrent_ids[0])["name"]) + else: + label_title.set_markup(_("Remove the selected torrents?")) + label_torrents.set_markup(_("Total of %s torrents selected") % num_torrents) - def pluralize_torrents(text): - plural_torrent = _("Torrents") - return text.replace("torrent", plural_torrent.lower()).replace("Torrent", plural_torrent) - - 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_delete_files_toggled(self, widget): + self.builder.get_object('warning_label').set_visible(widget.get_active()) def __remove_torrents(self, remove_data): # Unselect all to avoid issues with the selection changed event diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index c50c328dc..fb8ba6d14 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -713,7 +713,10 @@ class TorrentView(listview.ListView, component.Component): log.debug("keypress_Delete") torrents = self.get_selected_torrents() if torrents: - RemoveTorrentDialog(torrents).run() + if event.state & gtk.gdk.SHIFT_MASK: + RemoveTorrentDialog(torrents, delete_files=True).run() + else: + RemoveTorrentDialog(torrents).run() def keypress_Menu(self, event): log.debug("keypress_Menu")