diff --git a/deluge/core/core.py b/deluge/core/core.py index 24ff7ddd2..77295b733 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -351,6 +351,11 @@ class Core( if not self.torrents.pause(torrent_id): log.warning("Error pausing torrent %s", torrent_id) + def export_move_torrent(self, torrent_id, folder): + log.debug("Moving torrent %s to %s", torrent_id, folder) + if not self.torrents.move(torrent_id, folder): + log.warning("Error moving torrent %s to %s", torrent_id, folder) + def export_pause_all_torrents(self): """Pause all torrents in the session""" if not self.torrents.pause_all(): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 67710aa2f..268e57f84 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -335,6 +335,15 @@ class TorrentManager(component.Component): return True + def move(self, torrent_id, folder): + """Move a torrent""" + try: + self.torrents[torrent_id].handle.move_storage(folder) + except: + return False + + return True + def pause_all(self): """Pauses all torrents.. Returns a list of torrents paused.""" torrent_was_paused = False diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 87a67986f..c400dfd66 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -326,6 +326,11 @@ def pause_torrent(torrent_ids): for torrent_id in torrent_ids: get_core().call("pause_torrent", None, torrent_id) +def move_torrent(torrent_ids, folder): + """Pauses torrent_ids""" + for torrent_id in torrent_ids: + get_core().call("move_torrent", None, torrent_id, folder) + def pause_all_torrents(): """Pauses all torrents""" get_core().call("pause_all_torrents", None) diff --git a/deluge/ui/gtkui/glade/torrent_menu.glade b/deluge/ui/gtkui/glade/torrent_menu.glade index 0e58f551c..1e046c273 100644 --- a/deluge/ui/gtkui/glade/torrent_menu.glade +++ b/deluge/ui/gtkui/glade/torrent_menu.glade @@ -141,5 +141,22 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Move _Torrent + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-save-as + 1 + + + + diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 7f7e473f3..fb7638211 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -42,6 +42,7 @@ import gettext import locale import pkg_resources import signal +import os.path import deluge.component as component import deluge.ui.client as client @@ -93,7 +94,8 @@ DEFAULT_PREFS = { "autostart_localhost": False, "autoadd_queued": False, "autoadd_enable": False, - "autoadd_location": "" + "autoadd_location": "", + "choose_directory_dialog_path": os.path.expanduser("~") } class GtkUI: @@ -181,4 +183,3 @@ class GtkUI: def _on_no_core(self, data): component.stop() - diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 3413b8a7c..fa56070d4 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -96,7 +96,8 @@ class MenuBar(component.Component): self.on_menuitem_edittrackers_activate, "on_menuitem_remove_activate": self.on_menuitem_remove_activate, "on_menuitem_recheck_activate": self.on_menuitem_recheck_activate, - "on_menuitem_open_folder": self.on_menuitem_open_folder_activate + "on_menuitem_open_folder": self.on_menuitem_open_folder_activate, + "on_menuitem_move_activate": self.on_menuitem_move_activate }) self.change_sensitivity = [ @@ -211,6 +212,25 @@ class MenuBar(component.Component): def on_menuitem_open_folder_activate(self, data=None): log.debug("on_menuitem_open_folder") + def on_menuitem_move_activate(self, data=None): + log.debug("on_menuitem_move_activate") + from deluge.configmanager import ConfigManager + config = ConfigManager("gtkui.conf") + chooser = gtk.FileChooserDialog(_("Choose a directory to move files to"\ + ) , component.get("MainWindow").window, \ + gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_CANCEL, \ + gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) + if not common.windows_check(): + chooser.set_icon(common.get_logo(18)) + chooser.set_property("skip-taskbar-hint", True) + chooser.set_current_folder(config["choose_directory_dialog_path"]) + if chooser.run() == gtk.RESPONSE_OK: + result = chooser.get_filename() + config["choose_directory_dialog_path"] = result + client.move_torrent( + component.get("TorrentView").get_selected_torrents(), result) + chooser.destroy() + ## View Menu ## def on_menuitem_toolbar_toggled(self, value): log.debug("on_menuitem_toolbar_toggled")