mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-10 10:28:39 +00:00
add move torrent
This commit is contained in:
parent
1a0718b4ac
commit
6cb3b2b9e0
6 changed files with 60 additions and 3 deletions
|
@ -351,6 +351,11 @@ class Core(
|
||||||
if not self.torrents.pause(torrent_id):
|
if not self.torrents.pause(torrent_id):
|
||||||
log.warning("Error pausing torrent %s", 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):
|
def export_pause_all_torrents(self):
|
||||||
"""Pause all torrents in the session"""
|
"""Pause all torrents in the session"""
|
||||||
if not self.torrents.pause_all():
|
if not self.torrents.pause_all():
|
||||||
|
|
|
@ -335,6 +335,15 @@ class TorrentManager(component.Component):
|
||||||
|
|
||||||
return True
|
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):
|
def pause_all(self):
|
||||||
"""Pauses all torrents.. Returns a list of torrents paused."""
|
"""Pauses all torrents.. Returns a list of torrents paused."""
|
||||||
torrent_was_paused = False
|
torrent_was_paused = False
|
||||||
|
|
|
@ -326,6 +326,11 @@ def pause_torrent(torrent_ids):
|
||||||
for torrent_id in torrent_ids:
|
for torrent_id in torrent_ids:
|
||||||
get_core().call("pause_torrent", None, torrent_id)
|
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():
|
def pause_all_torrents():
|
||||||
"""Pauses all torrents"""
|
"""Pauses all torrents"""
|
||||||
get_core().call("pause_all_torrents", None)
|
get_core().call("pause_all_torrents", None)
|
||||||
|
|
|
@ -141,5 +141,22 @@
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</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>
|
</widget>
|
||||||
</glade-interface>
|
</glade-interface>
|
||||||
|
|
|
@ -42,6 +42,7 @@ import gettext
|
||||||
import locale
|
import locale
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import signal
|
import signal
|
||||||
|
import os.path
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.ui.client as client
|
import deluge.ui.client as client
|
||||||
|
@ -93,7 +94,8 @@ DEFAULT_PREFS = {
|
||||||
"autostart_localhost": False,
|
"autostart_localhost": False,
|
||||||
"autoadd_queued": False,
|
"autoadd_queued": False,
|
||||||
"autoadd_enable": False,
|
"autoadd_enable": False,
|
||||||
"autoadd_location": ""
|
"autoadd_location": "",
|
||||||
|
"choose_directory_dialog_path": os.path.expanduser("~")
|
||||||
}
|
}
|
||||||
|
|
||||||
class GtkUI:
|
class GtkUI:
|
||||||
|
@ -181,4 +183,3 @@ class GtkUI:
|
||||||
|
|
||||||
def _on_no_core(self, data):
|
def _on_no_core(self, data):
|
||||||
component.stop()
|
component.stop()
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,8 @@ class MenuBar(component.Component):
|
||||||
self.on_menuitem_edittrackers_activate,
|
self.on_menuitem_edittrackers_activate,
|
||||||
"on_menuitem_remove_activate": self.on_menuitem_remove_activate,
|
"on_menuitem_remove_activate": self.on_menuitem_remove_activate,
|
||||||
"on_menuitem_recheck_activate": self.on_menuitem_recheck_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 = [
|
self.change_sensitivity = [
|
||||||
|
@ -211,6 +212,25 @@ class MenuBar(component.Component):
|
||||||
def on_menuitem_open_folder_activate(self, data=None):
|
def on_menuitem_open_folder_activate(self, data=None):
|
||||||
log.debug("on_menuitem_open_folder")
|
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 ##
|
## View Menu ##
|
||||||
def on_menuitem_toolbar_toggled(self, value):
|
def on_menuitem_toolbar_toggled(self, value):
|
||||||
log.debug("on_menuitem_toolbar_toggled")
|
log.debug("on_menuitem_toolbar_toggled")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue