diff --git a/ChangeLog b/ChangeLog index 4fab4f35c..cd6fc14c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ Deluge 0.5.7 (xx November 2007) * Blocklist plugin will now display errors, instead of just crashing on a bad list + * Add preference for the location of torrent files Deluge 0.5.6.2 (31 October 2007) * Set default piece size to 256-KiB in TorrentCreator plugin and add 2048KiB diff --git a/TODO b/TODO index e74ee58ec..6e3152c62 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ for 0.5.7 - 1. manual recheck - 2. preference for .torrent location - 4. add auto-pickup folder - 5. remap filenames + * manual recheck + * add auto-pickup folder + * remap filenames diff --git a/glade/preferences_dialog.glade b/glade/preferences_dialog.glade index 1f510370a..2d88b00cc 100644 --- a/glade/preferences_dialog.glade +++ b/glade/preferences_dialog.glade @@ -98,6 +98,43 @@ 1 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Store all torrent files in: + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 15 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER + Select A Folder + + + + + 1 + 2 + + + + + 2 + + diff --git a/src/core.py b/src/core.py index 7b0f97bbc..ae1f38552 100644 --- a/src/core.py +++ b/src/core.py @@ -190,10 +190,17 @@ class Manager: # completely fresh. When quitting, the old files will be overwritten def __init__(self, client_ID, version, user_agent, base_dir, blank_slate=False): self.base_dir = base_dir + # Keeps track of DHT running state + self.dht_running = False + + # Load the preferences + self.config = pref.Preferences(os.path.join(self.base_dir, PREFS_FILENAME)) + + TORRENTS_SUBDIR = self.config.get("default_torrent_path") # Ensure directories exist - if not TORRENTS_SUBDIR in os.listdir(self.base_dir): - os.mkdir(os.path.join(self.base_dir, TORRENTS_SUBDIR)) + if not os.path.exists(TORRENTS_SUBDIR): + os.mkdir(TORRENTS_SUBDIR) # Pre-initialize the core's data structures deluge_core.pre_init(DelugeError, @@ -233,16 +240,10 @@ class Manager: # manner. self.cached_core_torrent_file_infos = \ cached_data(deluge_core.get_file_info) - - # Keeps track of DHT running state - self.dht_running = False - # Load the preferences - self.config = pref.Preferences(os.path.join(self.base_dir, PREFS_FILENAME)) - # Apply preferences. Note that this is before any torrents are added self.apply_prefs() - + # Event callbacks for use with plugins self.event_callbacks = {} @@ -368,10 +369,10 @@ class Manager: # A function to try and reload a torrent from a previous session. This is # used in the event that Deluge crashes and a blank state is loaded. def add_old_torrent(self, filename, save_dir, compact): - if not filename in os.listdir(os.path.join(self.base_dir, TORRENTS_SUBDIR)): + if not filename in os.listdir(self.config.get("default_torrent_path")): raise InvalidTorrentError(_("File was not found") + ": " + filename) - full_new_name = os.path.join(self.base_dir, TORRENTS_SUBDIR, filename) + full_new_name = os.path.join(self.config.get("default_torrent_path"), filename) # Create torrent object new_torrent = torrent_info(full_new_name, save_dir, compact) @@ -801,7 +802,7 @@ class Manager: # if filename_short in os.listdir(self.base_dir + "/" + TORRENTS_SUBDIR): # raise DuplicateTorrentError("Duplicate Torrent, it appears: " + filename_short) - full_new_name = os.path.join(self.base_dir, TORRENTS_SUBDIR, filename_short) + full_new_name = os.path.join(self.config.get("default_torrent_path"), filename_short) try: shutil.copy(filename, full_new_name) diff --git a/src/dialogs.py b/src/dialogs.py index a62d1177c..9ac27aa36 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -121,6 +121,7 @@ class PreferencesDlg: 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("download_path_button").set_filename(self.preferences.get("default_download_path")) + self.glade.get_widget("torrent_path_button").set_filename(self.preferences.get("default_torrent_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")) self.glade.get_widget("radio_compact_allocation").set_active(self.preferences.get("use_compact_storage")) @@ -238,6 +239,7 @@ 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("default_torrent_path", self.glade.get_widget("torrent_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()) diff --git a/src/pref.py b/src/pref.py index 0a3b88fe9..48d2ccec2 100644 --- a/src/pref.py +++ b/src/pref.py @@ -37,8 +37,10 @@ import cPickle as pickle import common import os.path +import xdg -DEFAULT_PREFS = { +if common.windows_check(): + DEFAULT_PREFS = { "enabled_plugins" : "Torrent Files:Torrent Peers", "file_manager" : common.FileManager.xdg, "open_folder_stock" : True, @@ -50,6 +52,113 @@ DEFAULT_PREFS = { "enable_files_dialog" : False, "queue_above_completed" : False, "clear_max_ratio_torrents" : False, + "default_torrent_path" : os.path.join(os.path.expanduser("~"), 'deluge', 'torrentfiles'), + "default_download_path" : os.path.expanduser("~"), + "open_torrent_dialog_path" : os.path.expanduser("~"), + "choose_directory_dialog_path": os.path.expanduser("~"), + "enable_dht" : True, + "enable_system_tray" : True, + "enabled_plugins" : "Torrent Files:Torrent Peers", + "encin_state" : common.EncState.enabled, + "encout_state" : common.EncState.enabled, + "enclevel_type" : common.EncLevel.both, + "end_seed_ratio" : 0.0, + "gui_update_interval" : 1.0, + "listen_on" : [6881,6889], + "lock_tray" : False, + "max_half_open" : 8, + "max_active_torrents" : 8, + "max_connections_global" : 200, + "max_connections_per_torrent" : -1, + "max_download_speed" : -1, + "max_download_speed_bps": -1, + "max_upload_slots_global" : 4, + "max_upload_slots_per_torrent" : -1, + "max_upload_speed" : -1, + "max_upload_speed_bps" : -1, + "pref_rc4" : True, + "prioritize_first_last_pieces" : False, + "web_proxy_type" : common.ProxyType.none, + "peer_proxy_type" : common.ProxyType.none, + "dht_proxy_type" : common.ProxyType.none, + "tracker_proxy_type" : common.ProxyType.none, + "peer_proxy" : False, + "tracker_proxy" : False, + "dht_proxy" : False, + "peer_proxy_hostname" : "", + "peer_proxy_username" : "", + "peer_proxy_password" : "", + "peer_proxy_port": 8080, + "dht_proxy_hostname" : "", + "dht_proxy_username" : "", + "dht_proxy_password" : "", + "dht_proxy_port": 8080, + "web_proxy_hostname" : "", + "web_proxy_username" : "", + "web_proxy_password" : "", + "web_proxy_port": 8080, + "tracker_proxy_hostname" : "", + "tracker_proxy_username" : "", + "tracker_proxy_password" : "", + "tracker_proxy_port": 8080, + "queue_seeds_to_bottom" : False, + "random_port" : False, + "show_availability" : True, + "show_dl" : True, + "show_eta" : True, + "show_infopane" : True, + "show_peers" : True, + "show_seeders" : True, + "show_share" : True, + "show_size" : True, + "show_status" : True, + "show_toolbar" : True, + "show_ul" : True, + "start_in_tray" : False, + "tray_downloadspeedlist" : [5.0, 10.0, 30.0, 80.0, 300.0], + "tray_passwd" : "", + "tray_uploadspeedlist" : [5.0, 10.0, 30.0, 80.0, 300.0], + "use_compact_storage" : False, + "use_default_dir" : False, + "use_natpmp" : False, + "use_upnp" : True, + "use_utpex" : True, + "new_releases" : True, + "window_height" : 480, + "window_maximized" : False, + "window_pane_position" : -1, + "window_width" : 640, + "window_x_pos" : 0, + "window_y_pos" : 0, + "availability_width" : 50, + "queue_width" : 40, + "name_width" : 175, + "dl_width" : 110, + "ul_width" : 110, + "eta_width" : 65, + "peer_width" : 85, + "seed_width" : 85, + "share_width" : 60, + "size_width" : 71, + "status_width" : 150, + "filename_f_width" : 220, + "size_f_width" : 90, + "priority_f_width" : 140 +} +else: + DEFAULT_PREFS = { + "enabled_plugins" : "Torrent Files:Torrent Peers", + "file_manager" : common.FileManager.xdg, + "open_folder_stock" : True, + "open_folder_location": "", + "send_info" : True, + "auto_end_seeding" : False, + "auto_seed_ratio" : 0, + "close_to_tray" : False, + "enable_files_dialog" : False, + "queue_above_completed" : False, + "clear_max_ratio_torrents" : False, + "default_torrent_path" : os.path.join(xdg.BaseDirectory.save_config_path('deluge'), 'torrentfiles'), "default_download_path" : os.path.expanduser("~"), "open_torrent_dialog_path" : os.path.expanduser("~"), "choose_directory_dialog_path": os.path.expanduser("~"),