[meld] ui.filechooser: Force default to UTF-8 on Windows (#337)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] ui.filechooser: Force default to UTF-8 on Windows (#337)
- Date: Thu, 20 Jun 2019 23:10:29 +0000 (UTC)
commit 798371b76ad69940c0a8ac3579f95c94b76e363d
Author: Kai Willadsen <kai willadsen gmail com>
Date: Fri Jun 21 08:59:23 2019 +1000
ui.filechooser: Force default to UTF-8 on Windows (#337)
On Unix, the current charset is a sensible default for the file chooser,
because it represents the user's environment properly. On Windows, this
is always the ANSI code page, even if the user reasonably thinks they're
using UTF-8 or similar.
meld/ui/filechooser.py | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/meld/ui/filechooser.py b/meld/ui/filechooser.py
index 01eba394..9ef2d1ad 100644
--- a/meld/ui/filechooser.py
+++ b/meld/ui/filechooser.py
@@ -15,6 +15,8 @@
"""This module provides file choosers that let users select a text encoding."""
+import sys
+
from gi.repository import Gtk
from gi.repository import GtkSource
@@ -53,10 +55,19 @@ class MeldFileChooserDialog(Gtk.FileChooserDialog):
def make_encoding_combo(self):
"""Create the combo box for text encoding selection"""
- codecs = []
- current = GtkSource.encoding_get_current()
- codecs.append((current.to_string(), current.get_charset()))
- codecs.append((None, None))
+
+ # On Windows, the "current" encoding is the "system default
+ # ANSI code-page", which is probably not what the user wants,
+ # so we default to UTF-8.
+ if sys.platform == 'win32':
+ current = GtkSource.encoding_get_utf8()
+ else:
+ current = GtkSource.encoding_get_current()
+
+ codecs = [
+ (current.to_string(), current.get_charset()),
+ (None, None),
+ ]
for encoding in GtkSource.encoding_get_all():
codecs.append((encoding.to_string(), encoding.get_charset()))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]