add move torrent
This commit is contained in:
parent
1a0718b4ac
commit
6cb3b2b9e0
|
@ -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():
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -141,5 +141,22 @@
|
|||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="menuitem1">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="label" translatable="yes">Move _Torrent</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menuitem_move_activate"/>
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="menu-item-image8">
|
||||
<property name="visible">True</property>
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="stock">gtk-save-as</property>
|
||||
<property name="icon_size">1</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue