Fix addtorrentdialog due to config class changes

This commit is contained in:
Andrew Resch 2008-11-07 06:49:00 +00:00
parent e0137b6a4c
commit 35e41e3b17
1 changed files with 16 additions and 16 deletions

View File

@ -200,12 +200,12 @@ class AddTorrentDialog(component.Component):
def add_from_magnets(self, uris): def add_from_magnets(self, uris):
import base64 import base64
new_row = None new_row = None
for uri in uris: for uri in uris:
info_hash = base64.b32decode(uri.split("&")[0][20:]).encode("hex") info_hash = base64.b32decode(uri.split("&")[0][20:]).encode("hex")
if info_hash in self.infos: if info_hash in self.infos:
log.debug("Torrent already in list!") log.debug("Torrent already in list!")
continue continue
name = None name = None
for i in uri.split("&"): for i in uri.split("&"):
if i[:3] == "dn=": if i[:3] == "dn=":
@ -229,7 +229,7 @@ class AddTorrentDialog(component.Component):
# Save the previous torrents options # Save the previous torrents options
self.save_torrent_options() self.save_torrent_options()
# Update files list # Update files list
files_list = self.files[model.get_value(row, 0)] files_list = self.files[model.get_value(row, 0)]
@ -254,7 +254,7 @@ class AddTorrentDialog(component.Component):
self.add_files(None, split_files) self.add_files(None, split_files)
self.listview_files.set_model(self.files_treestore) self.listview_files.set_model(self.files_treestore)
self.listview_files.expand_row("0", False) self.listview_files.expand_row("0", False)
def prepare_file(self, file, file_name, file_num, download, files_storage): def prepare_file(self, file, file_name, file_num, download, files_storage):
first_slash_index = file_name.find("/") first_slash_index = file_name.find("/")
if first_slash_index == -1: if first_slash_index == -1:
@ -289,17 +289,17 @@ class AddTorrentDialog(component.Component):
while itr: while itr:
download.append(self.files_treestore.get_value(itr, 0)) download.append(self.files_treestore.get_value(itr, 0))
itr = self.files_treestore.iter_next(itr) itr = self.files_treestore.iter_next(itr)
if sum(download) == len(download): if sum(download) == len(download):
download_value = True download_value = True
elif sum(download) == 0: elif sum(download) == 0:
download_value = False download_value = False
else: else:
inconsistent = True inconsistent = True
self.files_treestore.set_value(parent_iter, 0, download_value) self.files_treestore.set_value(parent_iter, 0, download_value)
self.files_treestore.set_value(parent_iter, 4, inconsistent) self.files_treestore.set_value(parent_iter, 4, inconsistent)
ret += value[1]["size"] ret += value[1]["size"]
return ret return ret
@ -369,8 +369,8 @@ class AddTorrentDialog(component.Component):
# Save the file priorities # Save the file priorities
files_priorities = self.build_priorities( files_priorities = self.build_priorities(
self.files_treestore.get_iter_first(), {}) self.files_treestore.get_iter_first(), {})
if len(files_priorities) > 0: if len(files_priorities) > 0:
for i, file_dict in enumerate(self.files[torrent_id]): for i, file_dict in enumerate(self.files[torrent_id]):
file_dict["download"] = files_priorities[i] file_dict["download"] = files_priorities[i]
@ -487,8 +487,8 @@ class AddTorrentDialog(component.Component):
# Load the 'default_load_path' from the config # Load the 'default_load_path' from the config
self.config = ConfigManager("gtkui.conf") self.config = ConfigManager("gtkui.conf")
if self.config.get("default_load_path") is not None: if self.config["default_load_path"] is not None:
chooser.set_current_folder(self.config.get("default_load_path")) chooser.set_current_folder(self.config["default_load_path"])
# Run the dialog # Run the dialog
response = chooser.run() response = chooser.run()
@ -589,7 +589,7 @@ class AddTorrentDialog(component.Component):
entry.set_text("") entry.set_text("")
textview.get_buffer().set_text("") textview.get_buffer().set_text("")
dialog.hide() dialog.hide()
def _on_button_remove_clicked(self, widget): def _on_button_remove_clicked(self, widget):
log.debug("_on_button_remove_clicked") log.debug("_on_button_remove_clicked")
(model, row) = self.listview_torrents.get_selection().get_selected() (model, row) = self.listview_torrents.get_selection().get_selected()
@ -633,22 +633,22 @@ class AddTorrentDialog(component.Component):
file_priorities = self.get_file_priorities(torrent_id) file_priorities = self.get_file_priorities(torrent_id)
if options != None: if options != None:
options["file_priorities"] = file_priorities options["file_priorities"] = file_priorities
if deluge.common.is_magnet(filename): if deluge.common.is_magnet(filename):
torrent_magnets.append(filename) torrent_magnets.append(filename)
del options["file_priorities"] del options["file_priorities"]
torrent_magnet_options.append(options) torrent_magnet_options.append(options)
else: else:
torrent_filenames.append(filename) torrent_filenames.append(filename)
torrent_options.append(options) torrent_options.append(options)
row = self.torrent_liststore.iter_next(row) row = self.torrent_liststore.iter_next(row)
if torrent_filenames: if torrent_filenames:
client.add_torrent_file(torrent_filenames, torrent_options) client.add_torrent_file(torrent_filenames, torrent_options)
if torrent_magnets: if torrent_magnets:
client.add_torrent_magnets(torrent_magnets, torrent_magnet_options) client.add_torrent_magnets(torrent_magnets, torrent_magnet_options)
client.force_call(False) client.force_call(False)
self.hide() self.hide()