cleaned up apply_prefs() a bit in interface.py and removed some

unneccesary prefs
This commit is contained in:
Andrew Resch 2007-06-11 19:05:14 +00:00
parent d689b14569
commit 0493996bc5
3 changed files with 25 additions and 36 deletions

View File

@ -55,8 +55,8 @@ class PreferencesDlg:
self.glade.get_widget("download_path_button").set_filename(self.preferences.get("default_download_path", str, default=os.path.expandvars('$HOME')))
self.glade.get_widget("chk_compact").set_active(self.preferences.get("use_compact_storage", bool, default=False))
self.glade.get_widget("active_port_label").set_text(str(self.parent.manager.get_state()['port']))
self.glade.get_widget("spin_port_min").set_value(self.preferences.get("tcp_port_range_lower", int, default=6881))
self.glade.get_widget("spin_port_max").set_value(self.preferences.get("tcp_port_range_upper", int, default=6889))
self.glade.get_widget("spin_port_min").set_value(self.preferences.get("listen_on", default=6881)[0])
self.glade.get_widget("spin_port_max").set_value(self.preferences.get("listen_on", default=6889)[1])
self.glade.get_widget("spin_max_upload").set_value(self.preferences.get("max_upload_rate", int, default=-1))
self.glade.get_widget("spin_num_upload").set_value(self.preferences.get("max_number_uploads", int, default=-1))
self.glade.get_widget("spin_max_download").set_value(self.preferences.get("max_download_rate", int, default=-1))
@ -87,8 +87,7 @@ class PreferencesDlg:
self.preferences.set("auto_end_seeding", self.glade.get_widget("chk_autoseed").get_active())
self.preferences.set("end_seed_ratio", self.glade.get_widget("ratio_spinner").get_value())
self.preferences.set("use_compact_storage", self.glade.get_widget("chk_compact").get_active())
self.preferences.set("tcp_port_range_lower", self.glade.get_widget("spin_port_min").get_value())
self.preferences.set("tcp_port_range_upper", self.glade.get_widget("spin_port_max").get_value())
self.preferences.set("listen_on", [self.glade.get_widget("spin_port_min").get_value(), self.glade.get_widget("spin_port_max").get_value()])
self.preferences.set("max_upload_rate", self.glade.get_widget("spin_max_upload").get_value())
self.preferences.set("max_number_uploads", self.glade.get_widget("spin_num_upload").get_value())
self.preferences.set("max_download_rate", self.glade.get_widget("spin_max_download").get_value())

View File

@ -527,32 +527,24 @@ class DelugeGTK:
self.apply_prefs()
self.config.save_to_file()
def show_plugin_dialog(self, arg=None):
self.plugin_dialog.show()
def apply_prefs(self):
ulrate = self.config.get("max_upload_rate", int, default=-1)
dlrate = self.config.get("max_download_rate", int, default=-1)
if not (ulrate == -1):
ulrate *= 1024
if not (dlrate == -1):
dlrate *= 1024
ports = [self.config.get("tcp_port_range_lower", int, default=6881),
self.config.get("tcp_port_range_upper", int, default=6889)]
if self.config.get("auto_end_seeding", bool, default=False):
auto_seed_ratio = self.config.get("end_seed_ratio", float, default=1.0)
else:
auto_seed_ratio = -1
# Show tray icon if necessary
self.tray_icon.set_visible(self.config.get("enable_system_tray", bool, default=True))
self.manager.set_pref("listen_on", ports)
self.manager.set_pref("max_upload_rate_bps", ulrate)
self.manager.set_pref("max_download_rate_bps", dlrate)
self.manager.set_pref("max_uploads", self.config.get("max_number_uploads", int, default=-1))
self.manager.set_pref("max_connections", self.config.get("max_number_downloads", int, default=-1))
self.manager.set_pref("auto_seed_ratio", auto_seed_ratio)
# '%s %d%%'%(core.STATE_MESSAGES[state['state']], int(state['progress'] * 100))
# Update the max_*_rate_bps prefs
ulrate = self.config.get("max_upload_rate", int, default=-1) * 1024
dlrate = self.config.get("max_download_rate", int, default=-1) * 1024
if not (ulrate < 0):
self.config.set("max_upload_rate_bps", ulrate)
if not (dlrate < 0):
self.config.set("max_download_rate_bps", dlrate)
# Apply the preferences in the core
self.manager.apply_prefs()
def get_message_from_state(self, torrent_state):
state = torrent_state['state']
is_paused = torrent_state['is_paused']

View File

@ -43,7 +43,7 @@ DEFAULT_PREFS = {
"enabled_plugins" : "",
"end_seed_ratio" : 0.0,
"gui_update_interval" : 1.0,
"listen_on" : [6881,9999],
"listen_on" : [6881,6889],
"max_active_torrents" : -1,
"max_connections" : 80,
"max_download_rate" : -1.0,
@ -65,8 +65,6 @@ DEFAULT_PREFS = {
"show_status" : True,
"show_toolbar" : True,
"show_ul" : True,
"tcp_port_range_lower" : 6881,
"tcp_port_range_upper" : 6889,
"use_compact_storage" : False,
"use_default_dir" : False,
"window_height" : 480,