mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-04 23:53:23 +00:00
[GTK] Fix adding non-ascii torrents and paths on Py2
Added decode_bytes to all widgets returning text to ensure unicode on Python 2.
This commit is contained in:
parent
25cfd58792
commit
bf4244e8b2
@ -515,8 +515,12 @@ class AddTorrentDialog(component.Component):
|
|||||||
else:
|
else:
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
options['download_location'] = self.download_location_path_chooser.get_text()
|
options['download_location'] = decode_bytes(
|
||||||
options['move_completed_path'] = self.move_completed_path_chooser.get_text()
|
self.download_location_path_chooser.get_text()
|
||||||
|
)
|
||||||
|
options['move_completed_path'] = decode_bytes(
|
||||||
|
self.move_completed_path_chooser.get_text()
|
||||||
|
)
|
||||||
options['pre_allocate_storage'] = self.builder.get_object(
|
options['pre_allocate_storage'] = self.builder.get_object(
|
||||||
'chk_pre_alloc'
|
'chk_pre_alloc'
|
||||||
).get_active()
|
).get_active()
|
||||||
@ -709,8 +713,10 @@ class AddTorrentDialog(component.Component):
|
|||||||
response = chooser.run()
|
response = chooser.run()
|
||||||
|
|
||||||
if response == Gtk.ResponseType.OK:
|
if response == Gtk.ResponseType.OK:
|
||||||
result = chooser.get_filenames()
|
result = [decode_bytes(f) for f in chooser.get_filenames()]
|
||||||
self.config['default_load_path'] = chooser.get_current_folder()
|
self.config['default_load_path'] = decode_bytes(
|
||||||
|
chooser.get_current_folder()
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
chooser.destroy()
|
chooser.destroy()
|
||||||
return
|
return
|
||||||
@ -821,12 +827,12 @@ class AddTorrentDialog(component.Component):
|
|||||||
|
|
||||||
dialog.show_all()
|
dialog.show_all()
|
||||||
response = dialog.run()
|
response = dialog.run()
|
||||||
infohash = entry.get_text().strip()
|
infohash = decode_bytes(entry.get_text()).strip()
|
||||||
if response == Gtk.ResponseType.OK and is_infohash(infohash):
|
if response == Gtk.ResponseType.OK and is_infohash(infohash):
|
||||||
# Create a list of trackers from the textview buffer
|
# Create a list of trackers from the textview buffer
|
||||||
tview_buf = textview.get_buffer()
|
tview_buf = textview.get_buffer()
|
||||||
trackers_text = tview_buf.get_text(
|
trackers_text = decode_bytes(
|
||||||
*tview_buf.get_bounds(), include_hidden_chars=False
|
tview_buf.get_text(*tview_buf.get_bounds(), include_hidden_chars=False)
|
||||||
)
|
)
|
||||||
log.debug('Create torrent tracker lines: %s', trackers_text)
|
log.debug('Create torrent tracker lines: %s', trackers_text)
|
||||||
trackers = list(trackers_tiers_from_text(trackers_text).keys())
|
trackers = list(trackers_tiers_from_text(trackers_text).keys())
|
||||||
@ -876,7 +882,9 @@ class AddTorrentDialog(component.Component):
|
|||||||
row = self.torrent_liststore.get_iter_first()
|
row = self.torrent_liststore.get_iter_first()
|
||||||
while row is not None:
|
while row is not None:
|
||||||
torrent_id = self.torrent_liststore.get_value(row, 0)
|
torrent_id = self.torrent_liststore.get_value(row, 0)
|
||||||
filename = xml_unescape(self.torrent_liststore.get_value(row, 2))
|
filename = xml_unescape(
|
||||||
|
decode_bytes(self.torrent_liststore.get_value(row, 2))
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
options = self.options[torrent_id]
|
options = self.options[torrent_id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user