changeset f092ab1bd74b in /home/hg/repos/gajim
author: Nathalie Rud nathalier@gmail.com branches: details:http://hg.gajim.org/gajim?cmd=changeset;node=f092ab1bd74b description: Fix file chooser dialog on Windows
Dropped decode_filechooser_file_paths() as with Python 3 it raised AttributeError: 'str' object has no attribute 'decode' on Windows, and silently handled exceptions effectively doing nothing on *nix systems.
diffstat:
src/dialogs.py | 9 --------- src/filetransfers_window.py | 4 ---- src/gtkgui_helpers.py | 25 ------------------------- 3 files changed, 0 insertions(+), 38 deletions(-)
diffs (103 lines):
diff -r 756d78be6ab2 -r f092ab1bd74b src/dialogs.py --- a/src/dialogs.py Tue Apr 19 23:48:10 2016 +0200 +++ b/src/dialogs.py Wed Apr 27 02:44:13 2016 +0300 @@ -4712,9 +4712,6 @@ check if file exists and call callback ''' path_to_clientcert_file = self.get_filename() - path_to_clientcert_file = \ - gtkgui_helpers.decode_filechooser_file_paths( - (path_to_clientcert_file,))[0] if os.path.exists(path_to_clientcert_file): callback(widget, path_to_clientcert_file)
@@ -4757,8 +4754,6 @@ Check if file exists and call callback """ path_to_snd_file = self.get_filename() - path_to_snd_file = gtkgui_helpers.decode_filechooser_file_paths( - (path_to_snd_file,))[0] if os.path.exists(path_to_snd_file): callback(widget, path_to_snd_file)
@@ -4799,8 +4794,6 @@ path_to_file = self.get_filename() if not path_to_file: return - path_to_file = gtkgui_helpers.decode_filechooser_file_paths( - (path_to_file,))[0] if os.path.exists(path_to_file): if isinstance(callback, tuple): callback[0](widget, path_to_file, *callback[1:]) @@ -4892,8 +4885,6 @@ path_to_file = self.get_filename() if not path_to_file: return - path_to_file = gtkgui_helpers.decode_filechooser_file_paths( - (path_to_file,))[0] if os.path.exists(path_to_file): if isinstance(callback, tuple): callback[0](path_to_file, *callback[1:]) diff -r 756d78be6ab2 -r f092ab1bd74b src/filetransfers_window.py --- a/src/filetransfers_window.py Tue Apr 19 23:48:10 2016 +0200 +++ b/src/filetransfers_window.py Wed Apr 27 02:44:13 2016 +0300 @@ -297,8 +297,6 @@ def on_ok(widget): file_dir = None files_path_list = dialog.get_filenames() - files_path_list = gtkgui_helpers.decode_filechooser_file_paths( - files_path_list) text_buffer = desc_entry.get_buffer() desc = text_buffer.get_text(text_buffer.get_start_iter(), text_buffer.get_end_iter(), True) @@ -379,8 +377,6 @@ def on_file_request_accepted(self, account, contact, file_props): def on_ok(widget, account, contact, file_props): file_path = dialog2.get_filename() - file_path = gtkgui_helpers.decode_filechooser_file_paths( - (file_path,))[0] if os.path.exists(file_path): # check if we have write permissions if not os.access(file_path, os.W_OK): diff -r 756d78be6ab2 -r f092ab1bd74b src/gtkgui_helpers.py --- a/src/gtkgui_helpers.py Tue Apr 19 23:48:10 2016 +0200 +++ b/src/gtkgui_helpers.py Wed Apr 27 02:44:13 2016 +0300 @@ -679,30 +679,6 @@ pixbuf.saturate_and_pixelate(pixbuf2, 0.0, False) return pixbuf2
-def decode_filechooser_file_paths(file_paths): - """ - Decode as UTF-8 under Windows and ask sys.getfilesystemencoding() in POSIX - file_paths MUST be LIST - """ - file_paths_list = list() - - if os.name == 'nt': # decode as UTF-8 under Windows - for file_path in file_paths: - file_path = file_path.decode('utf8') - file_paths_list.append(file_path) - else: - for file_path in file_paths: - try: - file_path = file_path.decode(sys.getfilesystemencoding()) - except Exception: - try: - file_path = file_path - except Exception: - pass - file_paths_list.append(file_path) - - return file_paths_list - def escape_underscore(s): """ Escape underlines to prevent them from being interpreted as keyboard @@ -771,7 +747,6 @@
def on_ok(widget): file_path = dialog.get_filename() - file_path = decode_filechooser_file_paths((file_path,))[0] if os.path.exists(file_path): # check if we have write permissions if not os.access(file_path, os.W_OK):