mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +00:00
move "move completed downloads" into the "move torrent" plugin
This commit is contained in:
parent
c58331f5e6
commit
4d2a2dd604
10 changed files with 617 additions and 523 deletions
|
@ -1,4 +1,6 @@
|
|||
Deluge 0.5.5 (xx August 2007)
|
||||
* New Move torrent plugin - takes over for "move completed downloads" feature
|
||||
and provides a "Move Torrent" option when right-clicking on a torrent
|
||||
* Save column widths
|
||||
* Queue order after restart fixes.
|
||||
* Use payload instead of including protocol overhead to ease user confusion
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,7 +48,12 @@ class DesiredRatio:
|
|||
self.callback_ids = []
|
||||
|
||||
# Setup preferences
|
||||
self.config = deluge.pref.Preferences(filename=deluge.common.CONFIG_DIR + "/desired_ratio.conf", global_defaults=False, defaults=DEFAULT_PREFS)
|
||||
self.config_file = deluge.common.CONFIG_DIR + "/desired_ratio.conf"
|
||||
self.config = deluge.pref.Preferences(self.config_file, global_defaults=False, defaults=DEFAULT_PREFS)
|
||||
try:
|
||||
self.config.load()
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
# Connect to events for the torrent menu so we know when to build and remove our sub-menu
|
||||
self.callback_ids.append(self.interface.torrent_menu.connect_after("realize", self.torrent_menu_show))
|
||||
|
@ -62,8 +67,6 @@ class DesiredRatio:
|
|||
# Make the sub-menu for the torrent menu
|
||||
self.ratio_menuitem = gtk.MenuItem(_("_Desired Ratio"))
|
||||
|
||||
|
||||
|
||||
self.ratio_menu = self.interface.build_menu_radio_list(self.config.get("ratios"), self.ratio_clicked, self.get_torrent_desired_ratio(), None, True, _("_Not Set"), 1, None)
|
||||
|
||||
self.ratio_menuitem.set_submenu(self.ratio_menu)
|
||||
|
@ -81,6 +84,7 @@ class DesiredRatio:
|
|||
pass
|
||||
|
||||
def unload(self):
|
||||
self.config.save(self.config_file)
|
||||
# Disconnect all callbacks
|
||||
for callback_id in self.callback_ids:
|
||||
self.interface.torrent_menu.disconnect(callback_id)
|
||||
|
@ -123,11 +127,12 @@ class DesiredRatio:
|
|||
# Set the ratio in the core and remember the setting
|
||||
self.core.set_ratio(self.unique_ID, value)
|
||||
self.set_ratios[self.unique_ID] = value
|
||||
self.config.set[self.unique_ID]("ratios") = value
|
||||
|
||||
# Update the ratios list if necessary
|
||||
if value not in self.config.get("ratios") and value >= 1:
|
||||
self.config.get("ratios").insert(0, value)
|
||||
self.config.get("ratios").pop()
|
||||
if value not in self.config.get("ratios")[self.unique_ID] and value >= 1:
|
||||
self.config.get("ratios")[self.unique_ID].insert(0, value)
|
||||
self.config.get("ratios")[self.unique_ID].pop()
|
||||
|
||||
def get_torrent_desired_ratio(self):
|
||||
return self.set_ratios.get(self.unique_ID, 1)
|
||||
|
|
|
@ -21,7 +21,9 @@ plugin_author = "Marcos Pinto"
|
|||
plugin_version = "0.1"
|
||||
plugin_description = _("This plugin allows users to move the torrent to a \
|
||||
different directory without having to remove and re-add the torrent. This \
|
||||
feature can be found by right-clicking on a torrent.")
|
||||
feature can be found by right-clicking on a torrent.\nFurthermore, it \
|
||||
allows the user to automatically have finished torrents moved to a different \
|
||||
folder.")
|
||||
|
||||
def deluge_init(deluge_path):
|
||||
global path
|
||||
|
@ -37,6 +39,11 @@ from deluge import dialogs
|
|||
import gtk
|
||||
import os
|
||||
|
||||
DEFAULT_PREFS = {
|
||||
"default_finished_path": os.path.expanduser("~/"),
|
||||
"enable_move_completed": False
|
||||
}
|
||||
|
||||
class movetorrentMenu:
|
||||
|
||||
def __init__(self, path, core, interface):
|
||||
|
@ -44,9 +51,25 @@ class movetorrentMenu:
|
|||
self.path = path
|
||||
self.core = core
|
||||
self.interface = interface
|
||||
self.window = self.interface.window
|
||||
self.dialogs = deluge.dialogs
|
||||
self.core.connect_event(self.core.constants['EVENT_STORAGE_MOVED'], self.handle_event)
|
||||
self.core.connect_event(self.core.constants['EVENT_FINISHED'], self.handle_event)
|
||||
self.glade = gtk.glade.XML(path + "/movetorrent.glade")
|
||||
self.glade.signal_autoconnect({
|
||||
'dialog_ok': self.dialog_ok,
|
||||
'dialog_cancel': self.dialog_cancel
|
||||
})
|
||||
self.dialog = self.glade.get_widget("dialog")
|
||||
self.dialog.set_position(gtk.WIN_POS_CENTER)
|
||||
|
||||
self.config_file = deluge.common.CONFIG_DIR + "/move_torrent.conf"
|
||||
self.config = deluge.pref.Preferences(self.config_file, global_defaults=False, defaults=DEFAULT_PREFS)
|
||||
try:
|
||||
self.config.load()
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
# Add menu item to torrent context menu
|
||||
self.menuitem_image = gtk.Image()
|
||||
self.menuitem_image.set_from_stock(gtk.STOCK_SAVE_AS, gtk.ICON_SIZE_MENU)
|
||||
|
||||
|
@ -60,7 +83,10 @@ class movetorrentMenu:
|
|||
pass
|
||||
|
||||
def unload(self):
|
||||
self.interface.torrent_menu.remove(self.menuitem)
|
||||
self.interface.torrent_menu.remove(self.menuitem)
|
||||
self.core.disconnect_event(self.core.constants['EVENT_STORAGE_MOVED'], self.handle_event)
|
||||
self.core.disconnect_event(self.core.constants['EVENT_FINISHED'], self.handle_event)
|
||||
self.config.save(self.config_file)
|
||||
|
||||
def movetorrent_clicked(self, widget):
|
||||
unique_ids = self.interface.get_selected_torrent_rows()
|
||||
|
@ -70,3 +96,40 @@ class movetorrentMenu:
|
|||
if path:
|
||||
for unique_id in unique_ids:
|
||||
self.core.move_storage(unique_id, path)
|
||||
|
||||
def configure(self, window):
|
||||
import os.path
|
||||
try:
|
||||
self.glade.get_widget("chk_move_completed").set_active(self.config.get("enable_move_completed"))
|
||||
self.glade.get_widget("finished_path_button").set_filename(self.config.get("default_finished_path"))
|
||||
|
||||
except:
|
||||
self.glade.get_widget("chk_move_completed").set_active(False)
|
||||
self.glade.get_widget("default_finished_path").set_active(False)
|
||||
self.dialog.set_transient_for(window)
|
||||
self.dialog.show()
|
||||
|
||||
def dialog_ok(self, source):
|
||||
self.dialog.hide()
|
||||
self.config.set("enable_move_completed", self.glade.get_widget("chk_move_completed").get_active())
|
||||
self.config.set("default_finished_path", self.glade.get_widget("finished_path_button").get_filename())
|
||||
|
||||
def dialog_cancel(self, source):
|
||||
self.dialog.hide()
|
||||
|
||||
def handle_event(self, event):
|
||||
if event['event_type'] is self.core.constants['EVENT_STORAGE_MOVED']:
|
||||
if event['message'] == self.core.unique_IDs[event['unique_ID']].save_dir:
|
||||
self.dialogs.show_popup_warning(self.window, _("You cannot move torrent to a different partition. Please check your preferences. Or perhalps you are trying to move torrent's files to the same directory they are already stored?"))
|
||||
self.core.unique_IDs[event['unique_ID']].save_dir = event['message']
|
||||
self.core.pickle_state()
|
||||
|
||||
elif event['event_type'] is self.core.constants['EVENT_FINISHED']:
|
||||
if event['message'] == "torrent has finished downloading":
|
||||
if self.config.get('enable_move_completed') and \
|
||||
self.config.get('default_finished_path') != \
|
||||
self.core.get_pref('default_download_path') and \
|
||||
self.core.unique_IDs[event['unique_ID']].save_dir != \
|
||||
self.config.get('default_finished_path'):
|
||||
self.core.move_storage(event['unique_ID'],
|
||||
self.config.get('default_finished_path'))
|
||||
|
|
89
plugins/MoveTorrent/movetorrent.glade
Normal file
89
plugins/MoveTorrent/movetorrent.glade
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.2.2 on Sun Aug 19 19:47:19 2007 by markybob@peg-->
|
||||
<glade-interface>
|
||||
<widget class="GtkDialog" id="dialog">
|
||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox1">
|
||||
<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="spacing">2</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<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>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="chk_move_completed">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">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 completed downloads to:</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkFileChooserButton" id="finished_path_button">
|
||||
<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="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
|
||||
<property name="title" translatable="yes">Select A Folder</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<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="layout_style">GTK_BUTTONBOX_END</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">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">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="dialog_cancel"/>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">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">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="dialog_ok"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
|
@ -52,6 +52,13 @@ class webseedMenu:
|
|||
self.menuitem.connect("activate", self.webseed_clicked)
|
||||
self.interface.torrent_menu.append(self.menuitem)
|
||||
self.menuitem.show_all()
|
||||
|
||||
self.config_file = deluge.common.CONFIG_DIR + "/web_seed.conf"
|
||||
self.config = deluge.pref.Preferences(self.config_file, global_defaults=False)
|
||||
try:
|
||||
self.config.load()
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
|
20
src/core.py
20
src/core.py
|
@ -115,9 +115,6 @@ class InvalidEncodingError(DelugeError):
|
|||
class FilesystemError(DelugeError):
|
||||
pass
|
||||
|
||||
class StorageMoveFailed(DelugeError):
|
||||
pass
|
||||
|
||||
# Note: this may be raised both from deluge-core.cpp and deluge.py, for
|
||||
# different reasons, both related to duplicate torrents
|
||||
class DuplicateTorrentError(DelugeError):
|
||||
|
@ -622,23 +619,6 @@ class Manager:
|
|||
for callback in self.event_callbacks[event['event_type']]:
|
||||
callback(event)
|
||||
|
||||
if event['event_type'] is self.constants['EVENT_STORAGE_MOVED']:
|
||||
if event['message'] == self.unique_IDs[event['unique_ID']].save_dir:
|
||||
raise StorageMoveFailed(_("You cannot move torrent to a different partition. Please check your preferences. Or maybe you are trying to move torrent's files to the same directory they are already stored ?"))
|
||||
|
||||
self.unique_IDs[event['unique_ID']].save_dir = event['message']
|
||||
self.pickle_state()
|
||||
|
||||
elif event['event_type'] is self.constants['EVENT_FINISHED']:
|
||||
if event['message'] == "torrent has finished downloading":
|
||||
if self.get_pref('enable_move_completed') and \
|
||||
self.get_pref('default_finished_path') != \
|
||||
self.get_pref('default_download_path') and \
|
||||
self.unique_IDs[event['unique_ID']].save_dir != \
|
||||
self.get_pref('default_finished_path'):
|
||||
self.move_storage(event['unique_ID'],
|
||||
self.get_pref('default_finished_path'))
|
||||
|
||||
# Queue seeding torrent to bottom if needed
|
||||
if self.get_pref('queue_seeds_to_bottom'):
|
||||
self.queue_bottom(event['unique_ID'])
|
||||
|
|
|
@ -94,7 +94,6 @@ class PreferencesDlg:
|
|||
self.glade.get_widget("txt_web_proxy_hostname").set_text(self.preferences.get("web_proxy_hostname"))
|
||||
self.glade.get_widget("txt_web_proxy_username").set_text(self.preferences.get("web_proxy_username"))
|
||||
self.glade.get_widget("txt_web_proxy_password").set_text(self.preferences.get("web_proxy_password"))
|
||||
self.glade.get_widget("finished_path_button").set_filename(self.preferences.get("default_finished_path"))
|
||||
self.glade.get_widget("download_path_button").set_filename(self.preferences.get("default_download_path"))
|
||||
self.glade.get_widget("chk_enable_files_dialog").set_active(self.preferences.get("enable_files_dialog"))
|
||||
self.glade.get_widget("chk_prioritize_first_last_pieces").set_active(self.preferences.get("prioritize_first_last_pieces"))
|
||||
|
@ -127,14 +126,8 @@ class PreferencesDlg:
|
|||
#smart dialog set sensitivities
|
||||
if(self.preferences.get("use_default_dir")):
|
||||
self.glade.get_widget("radio_save_all_to").set_active(True)
|
||||
self.glade.get_widget("chk_move_completed").set_sensitive(True)
|
||||
self.glade.get_widget("finished_path_button").set_sensitive(True)
|
||||
if(self.preferences.get("enable_move_completed")):
|
||||
self.glade.get_widget("chk_move_completed").set_active(True)
|
||||
else:
|
||||
self.glade.get_widget("radio_ask_save").set_active(True)
|
||||
self.glade.get_widget("chk_move_completed").set_sensitive(False)
|
||||
self.glade.get_widget("finished_path_button").set_sensitive(False)
|
||||
|
||||
self.glade.get_widget('chk_min_on_close').set_sensitive(
|
||||
self.glade.get_widget('chk_use_tray').get_active())
|
||||
|
@ -204,8 +197,6 @@ class PreferencesDlg:
|
|||
self.preferences.set("peer_proxy_hostname", self.glade.get_widget("txt_peer_proxy_hostname").get_text())
|
||||
self.preferences.set("use_default_dir", self.glade.get_widget("radio_save_all_to").get_active())
|
||||
self.preferences.set("default_download_path", self.glade.get_widget("download_path_button").get_filename())
|
||||
self.preferences.set("enable_move_completed", self.glade.get_widget("chk_move_completed").get_active())
|
||||
self.preferences.set("default_finished_path", self.glade.get_widget("finished_path_button").get_filename())
|
||||
self.preferences.set("enable_files_dialog", self.glade.get_widget("chk_enable_files_dialog").get_active())
|
||||
self.preferences.set("prioritize_first_last_pieces", self.glade.get_widget("chk_prioritize_first_last_pieces").get_active())
|
||||
self.preferences.set("auto_end_seeding", self.glade.get_widget("chk_autoseed").get_active())
|
||||
|
@ -242,11 +233,6 @@ class PreferencesDlg:
|
|||
value = widget.get_active()
|
||||
if widget == self.glade.get_widget('radio_save_all_to'):
|
||||
self.glade.get_widget('download_path_button').set_sensitive(value)
|
||||
self.glade.get_widget('chk_move_completed').set_sensitive(value)
|
||||
if not value:
|
||||
self.glade.get_widget('chk_move_completed').set_active(value)
|
||||
elif widget == self.glade.get_widget('chk_move_completed'):
|
||||
self.glade.get_widget('finished_path_button').set_sensitive(value)
|
||||
elif widget == self.glade.get_widget('chk_autoseed'):
|
||||
self.glade.get_widget('ratio_spinner').set_sensitive(value)
|
||||
self.glade.get_widget('chk_clear_max_ratio_torrents').set_sensitive(value)
|
||||
|
|
|
@ -864,11 +864,7 @@ class DelugeGTK:
|
|||
self.update_interface = self.window.get_property("visible") and not self.is_minimized
|
||||
|
||||
# Handle the events
|
||||
try:
|
||||
self.manager.handle_events()
|
||||
except core.StorageMoveFailed, e:
|
||||
print "StorageMoveFailed", e
|
||||
dialogs.show_popup_warning(self.window, e.value)
|
||||
self.manager.handle_events()
|
||||
|
||||
# Make sure that the interface still exists
|
||||
try:
|
||||
|
|
|
@ -53,8 +53,6 @@ DEFAULT_PREFS = {
|
|||
"default_download_path" : os.path.expanduser("~/"),
|
||||
"open_torrent_dialog_path" : os.path.expanduser("~/"),
|
||||
"choose_directory_dialog_path": os.path.expanduser("~/"),
|
||||
"default_finished_path" : os.path.expanduser("~/"),
|
||||
"enable_move_completed" : False,
|
||||
"enable_dht" : True,
|
||||
"enable_system_tray" : True,
|
||||
"enabled_plugins" : "",
|
||||
|
|
Loading…
Add table
Reference in a new issue