diff --git a/src/dialogs.py b/src/dialogs.py index 6bdb34232..f0fadd625 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -1537,11 +1537,8 @@ class SoundChooserDialog(FileChooserDialog): def on_ok(widget, callback): '''check if file exists and call callback''' path_to_snd_file = self.get_filename() - try: - path_to_snd_file = path_to_snd_file.decode( - sys.getfilesystemencoding()) - except: - pass + 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) @@ -1576,11 +1573,8 @@ class ImageChooserDialog(FileChooserDialog): def on_ok(widget, callback): '''check if file exists and call callback''' path_to_file = self.get_filename() - try: - path_to_file = path_to_file.decode( - sys.getfilesystemencoding()) - except: - pass + path_to_file = gtkgui_helpers.decode_filechooser_file_paths( + (path_to_file,))[0] if os.path.exists(path_to_file): callback(widget, path_to_file) diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 3f1ecf2e7..8d4a1c681 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -506,7 +506,13 @@ def decode_filechooser_file_paths(file_paths): file_paths_list.append(file_path) else: for file_path in file_paths: - file_path = file_path.decode(sys.getfilesystemencoding()) + try: + file_path = file_path.decode(sys.getfilesystemencoding()) + except: + try: + file_path = file_path.decode('utf-8') + except: + pass file_paths_list.append(file_path) return file_paths_list