diff --git a/deluge/ui/gtkui/glade/dgtkpopups.glade b/deluge/ui/gtkui/glade/dgtkpopups.glade index 1022651f5..249640db1 100644 --- a/deluge/ui/gtkui/glade/dgtkpopups.glade +++ b/deluge/ui/gtkui/glade/dgtkpopups.glade @@ -1,239 +1,7 @@ - + - - Remove Torrent - GTK_WIN_POS_CENTER - GDK_WINDOW_TYPE_HINT_NORMAL - True - True - False - - - True - - - True - 10 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 3 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-dialog-warning - 6 - - - False - False - 5 - - - - - True - 0 - <span size="large"><b>Are you sure you want to remove the selected torrent(s) from Deluge?</b></span> - True - True - - - 10 - 1 - - - - - False - False - 5 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 20 - - - True - Delete downloaded files - 0 - True - - - - - False - False - 1 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - 20 - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Delete .torrent file - 0 - True - True - - - - - False - False - 2 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 3 - - - - - False - False - 5 - 1 - - - - - True - GTK_BUTTONBOX_END - - - True - gtk-no - True - 0 - - - - - True - gtk-yes - True - 1 - - - 1 - - - - - False - GTK_PACK_END - - - - - - - True - - - True - Show/Hide - True - - - - - - True - Add a Torrent... - True - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-add - 1 - - - - - - - True - Clear Finished - True - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-clear - 1 - - - - - - - True - - - - - True - gtk-preferences - True - True - - - - - - True - Plugins - True - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-execute - 1 - - - - - - - True - - - - - True - gtk-quit - True - True - - - - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK diff --git a/deluge/ui/gtkui/glade/remove_torrent_dialog.glade b/deluge/ui/gtkui/glade/remove_torrent_dialog.glade index 244d2f62b..addf5689d 100644 --- a/deluge/ui/gtkui/glade/remove_torrent_dialog.glade +++ b/deluge/ui/gtkui/glade/remove_torrent_dialog.glade @@ -1,12 +1,11 @@ - + - 350 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - Remove Torrent + Remove Torrent? False GTK_WIN_POS_CENTER_ON_PARENT GDK_WINDOW_TYPE_HINT_DIALOG @@ -25,13 +24,13 @@ 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 gtk-dialog-warning - 5 + 6 False @@ -39,11 +38,12 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <big><b>Remove Torrent(s)?</b></big> + <big><b>Are you sure you want to remove the selected torrent?</b></big> True + True False @@ -59,7 +59,6 @@ - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -67,40 +66,44 @@ 1 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - 10 - <b>Options</b> - True - - - False - False - 2 - - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 15 - - True - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Delete .torrent file(s) - 0 - True - True + 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 + + - 3 + 2 @@ -109,18 +112,37 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 15 - - True - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Delete saved data - 0 - True + 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 + + - 4 + 3 @@ -135,7 +157,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_BUTTONBOX_END + GTK_BUTTONBOX_CENTER True @@ -154,8 +176,7 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-ok - True + Remove Selected Torrent 0 diff --git a/deluge/ui/gtkui/glade/torrent_menu.glade b/deluge/ui/gtkui/glade/torrent_menu.glade index 1e046c273..148c078e9 100644 --- a/deluge/ui/gtkui/glade/torrent_menu.glade +++ b/deluge/ui/gtkui/glade/torrent_menu.glade @@ -64,6 +64,28 @@ True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Opt_ions + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-preferences + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + True @@ -108,7 +130,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _Remove Torrent True - True @@ -142,7 +163,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Move _Torrent @@ -159,4 +180,118 @@ + + 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 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Download Speed Limit + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-missing-image + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Upload Speed Limit + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-missing-image + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Connection Limit + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-network + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Upload _Slot Limit + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-sort-ascending + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Private + True + + + diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 633839773..368f44a52 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -59,9 +59,9 @@ from signals import Signals from pluginmanager import PluginManager from dbusinterface import DbusInterface from queuedtorrents import QueuedTorrents +from coreconfig import CoreConfig from deluge.configmanager import ConfigManager import deluge.common -import deluge.configmanager DEFAULT_PREFS = { "config_location": deluge.common.get_config_dir(), @@ -151,7 +151,8 @@ class GtkUI: # Start the signal receiver self.signal_receiver = Signals() - + self.coreconfig = CoreConfig() + # Initalize the plugins self.plugins = PluginManager() diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 5dc72af4d..ca408c178 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -52,6 +52,42 @@ 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")) + + # Attach options torrent menu + self.torrentmenu_glade.get_widget("menuitem_options").set_submenu( + self.torrentmenu_glade.get_widget("options_torrent_menu")) + self.torrentmenu_glade.get_widget("download-limit-image").set_from_file( + common.get_pixmap("downloading16.png")) + self.torrentmenu_glade.get_widget("upload-limit-image").set_from_file( + common.get_pixmap("seeding16.png")) + + for menuitem in ("menuitem_down_speed", "menuitem_up_speed", + "menuitem_max_connections", "menuitem_upload_slots"): + submenu = gtk.Menu() + item = gtk.MenuItem(_("Set Unlimited")) + item.set_name(menuitem) + item.connect("activate", self.on_menuitem_set_unlimited) + submenu.append(item) + item = gtk.MenuItem(_("Other..")) + item.set_name(menuitem) + item.connect("activate", self.on_menuitem_set_other) + submenu.append(item) + submenu.show_all() + self.torrentmenu_glade.get_widget(menuitem).set_submenu(submenu) + + submenu = gtk.Menu() + item = gtk.MenuItem(_("Set Private On")) + item.connect("activate", self.on_menuitem_set_private_on) + submenu.append(item) + item = gtk.MenuItem(_("Set Private Off")) + item.connect("activate", self.on_menuitem_set_private_off) + submenu.append(item) + submenu.show_all() + self.torrentmenu_glade.get_widget("menuitem_private").set_submenu(submenu) + self.torrentmenu = self.torrentmenu_glade.get_widget("torrent_menu") self.menu_torrent = self.window.main_glade.get_widget("menu_torrent") @@ -94,7 +130,15 @@ class MenuBar(component.Component): self.on_menuitem_updatetracker_activate, "on_menuitem_edittrackers_activate": \ self.on_menuitem_edittrackers_activate, - "on_menuitem_remove_activate": self.on_menuitem_remove_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_recheck_activate": self.on_menuitem_recheck_activate, "on_menuitem_open_folder": self.on_menuitem_open_folder_activate, "on_menuitem_move_activate": self.on_menuitem_move_activate @@ -195,14 +239,34 @@ class MenuBar(component.Component): component.get("TorrentView").get_selected_torrent(), component.get("MainWindow").window) dialog.run() - - def on_menuitem_remove_activate(self, data=None): - log.debug("on_menuitem_remove_activate") + + def on_menuitem_remove_session_activate(self, data=None): + log.debug("on_menuitem_remove_session_activate") from removetorrentdialog import RemoveTorrentDialog RemoveTorrentDialog( component.get("TorrentView").get_selected_torrents()).run() - #client.remove_torrent( - # component.get("TorrentView").get_selected_torrents()) + + 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() def on_menuitem_recheck_activate(self, data=None): log.debug("on_menuitem_recheck_activate") @@ -262,3 +326,61 @@ class MenuBar(component.Component): from aboutdialog import AboutDialog AboutDialog().run() + def on_menuitem_set_unlimited(self, widget): + log.debug("widget.name: %s", widget.name) + funcs = { + "menuitem_down_speed": client.set_torrent_max_download_speed, + "menuitem_up_speed": client.set_torrent_max_upload_speed, + "menuitem_max_connections": client.set_torrent_max_connections, + "menuitem_upload_slots": client.set_torrent_max_upload_slots + } + if widget.name in funcs.keys(): + for torrent in component.get("TorrentView").get_selected_torrents(): + funcs[widget.name](torrent, -1) + + def on_menuitem_set_other(self, widget): + log.debug("widget.name: %s", widget.name) + funcs = { + "menuitem_down_speed": client.set_torrent_max_download_speed, + "menuitem_up_speed": client.set_torrent_max_upload_speed, + "menuitem_max_connections": client.set_torrent_max_connections, + "menuitem_upload_slots": client.set_torrent_max_upload_slots + } + dialog_glade = gtk.glade.XML( + pkg_resources.resource_filename("deluge.ui.gtkui", + "glade/dgtkpopups.glade")) + speed_dialog = dialog_glade.get_widget("speed_dialog") + spin_title = dialog_glade.get_widget("spin_title") + if widget.name == "menuitem_down_speed": + spin_title.set_text(_("Set Max Download Speed (KiB/s):")) + elif widget.name == "menuitem_up_speed": + spin_title.set_text(_("Set Max Upload Speed (KiB/s):")) + elif widget.name == "menuitem_max_connections": + spin_title.set_text(_("Set Max Connections:")) + elif widget.name == "menuitem_upload_slots": + spin_title.set_text(_("Set Max Upload Slots:")) + + spin_speed = dialog_glade.get_widget("spin_speed") + spin_speed.set_value(-1) + spin_speed.select_region(0, -1) + response = speed_dialog.run() + if response == 1: # OK Response + if widget.name == "menuitem_down_speed" or widget.name == "menuitem_up_speed": + value = spin_speed.get_value() + else: + value = spin_speed.get_value_as_int() + else: + speed_dialog.destroy() + return + speed_dialog.destroy() + if widget.name in funcs.keys(): + for torrent in component.get("TorrentView").get_selected_torrents(): + funcs[widget.name](torrent, value) + + def on_menuitem_set_private_on(self, widget): + for torrent in component.get("TorrentView").get_selected_torrents(): + client.set_torrent_private_flag(torrent, True) + + def on_menuitem_set_private_off(self, widget): + for torrent in component.get("TorrentView").get_selected_torrents(): + client.set_torrent_private_flag(torrent, False) diff --git a/deluge/ui/gtkui/removetorrentdialog.py b/deluge/ui/gtkui/removetorrentdialog.py index b9de23bed..5218b4201 100644 --- a/deluge/ui/gtkui/removetorrentdialog.py +++ b/deluge/ui/gtkui/removetorrentdialog.py @@ -40,8 +40,11 @@ import deluge.component as component from deluge.log import LOG as log class RemoveTorrentDialog: - def __init__(self, torrent_ids): + 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 + self.glade = gtk.glade.XML( pkg_resources.resource_filename("deluge.ui.gtkui", "glade/remove_torrent_dialog.glade")) @@ -54,6 +57,20 @@ class RemoveTorrentDialog: "on_button_ok_clicked": self.on_button_ok_clicked, "on_button_cancel_clicked": self.on_button_cancel_clicked }) + + 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")) + + 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 run(self): if self.torrent_ids == None or self.torrent_ids == []: @@ -62,9 +79,10 @@ class RemoveTorrentDialog: self.dialog.show() def on_button_ok_clicked(self, widget): - data = self.glade.get_widget("chk_data").get_active() - torrent = self.glade.get_widget("chk_torrents").get_active() - client.remove_torrent(self.torrent_ids, torrent, data) + #data = self.glade.get_widget("chk_data").get_active() + #torrent = self.glade.get_widget("chk_torrents").get_active() + client.remove_torrent( + self.torrent_ids, self.remove_torrentfile, self.remove_data) self.dialog.destroy() def on_button_cancel_clicked(self, widget):