[gnome-terminal/gsettings] Add 'encoding' profile setting



commit 7997a2719989c67e46bd7a07c8e5b13238295cd3
Author: Christian Persch <chpe gnome org>
Date:   Fri Jan 20 22:21:25 2012 +0100

    Add 'encoding' profile setting
    
    By special request, implement this feature, but without UI for now.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=108711

 src/org.gnome.Terminal.Preferences.gschema.xml.in |   74 +++++++++++++++++++++
 src/terminal-app.c                                |   11 ++-
 src/terminal-schemas.h                            |    1 +
 src/terminal-screen.c                             |    9 +++
 4 files changed, 92 insertions(+), 3 deletions(-)
---
diff --git a/src/org.gnome.Terminal.Preferences.gschema.xml.in b/src/org.gnome.Terminal.Preferences.gschema.xml.in
index 15d4b7f..0986328 100644
--- a/src/org.gnome.Terminal.Preferences.gschema.xml.in
+++ b/src/org.gnome.Terminal.Preferences.gschema.xml.in
@@ -236,6 +236,80 @@
       <default>true</default>
       <_summary>Whether to use the system monospace font</_summary>
     </key>
+    <key name="encoding" type="s">
+      <choices>
+        <choice value="current" />
+        <choice value="ISO-8859-1" />
+        <choice value="ISO-8859-2" />
+        <choice value="ISO-8859-3" />
+        <choice value="ISO-8859-4" />
+        <choice value="ISO-8859-5" />
+        <choice value="ISO-8859-6" />
+        <choice value="ISO-8859-7" />
+        <choice value="ISO-8859-8" />
+        <choice value="ISO-8859-8-I" />
+        <choice value="ISO-8859-9" />
+        <choice value="ISO-8859-10" />
+        <choice value="ISO-8859-13" />
+        <choice value="ISO-8859-14" />
+        <choice value="ISO-8859-15" />
+        <choice value="ISO-8859-16" />
+        <choice value="UTF-8" />
+        <choice value="ARMSCII-8" />
+        <choice value="BIG5" />
+        <choice value="BIG5-HKSCS" />
+        <choice value="CP866" />
+        <choice value="EUC-JP" />
+        <choice value="EUC-KR" />
+        <choice value="EUC-TW" />
+        <choice value="GB18030" />
+        <choice value="GB2312" />
+        <choice value="GBK" />
+        <choice value="GEORGIAN-PS" />
+        <choice value="IBM850" />
+        <choice value="IBM852" />
+        <choice value="IBM855" />
+        <choice value="IBM857" />
+        <choice value="IBM862" />
+        <choice value="IBM864" />
+        <choice value="ISO-2022-JP" />
+        <choice value="ISO-2022-KR" />
+        <choice value="ISO-IR-111" />
+        <choice value="KOI8-R" />
+        <choice value="KOI8-U" />
+        <choice value="MAC_ARABIC" />
+        <choice value="MAC_CE" />
+        <choice value="MAC_CROATIAN" />
+        <choice value="MAC-CYRILLIC" />
+        <choice value="MAC_DEVANAGARI" />
+        <choice value="MAC_FARSI" />
+        <choice value="MAC_GREEK" />
+        <choice value="MAC_GUJARATI" />
+        <choice value="MAC_GURMUKHI" />
+        <choice value="MAC_HEBREW" />
+        <choice value="MAC_ICELANDIC" />
+        <choice value="MAC_ROMAN" />
+        <choice value="MAC_ROMANIAN" />
+        <choice value="MAC_TURKISH" />
+        <choice value="MAC_UKRAINIAN" />
+        <choice value="SHIFT_JIS" />
+        <choice value="TCVN" />
+        <choice value="TIS-620" />
+        <choice value="UHC" />
+        <choice value="VISCII" />
+        <choice value="WINDOWS-1250" />
+        <choice value="WINDOWS-1251" />
+        <choice value="WINDOWS-1252" />
+        <choice value="WINDOWS-1253" />
+        <choice value="WINDOWS-1254" />
+        <choice value="WINDOWS-1255" />
+        <choice value="WINDOWS-1256" />
+        <choice value="WINDOWS-1257" />
+        <choice value="WINDOWS-1258" />
+      </choices>
+      <default>'current'</default>
+      <_summary>Which encoding to use</_summary>
+    </key>
   </schema>
 
   <!-- Profiles list -->
diff --git a/src/terminal-app.c b/src/terminal-app.c
index dab8533..8809530 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -1548,9 +1548,14 @@ terminal_app_get_encodings (TerminalApp *app)
 /**
  * terminal_app_ensure_encoding:
  * @app:
- * @charset:
+ * @charset: (allow-none): a charset, or %NULL
  *
- * Ensures there's a #TerminalEncoding for @charset available.
+ * Ensures there's a #TerminalEncoding for @charset available. If @charset
+ * is %NULL, returns the #TerminalEncoding for the locale's charset. If
+ * @charset is not a known charset, returns a #TerminalEncoding for a 
+ * custom charset.
+ * 
+ * Returns: (transfer none): a #TerminalEncoding
  */
 TerminalEncoding *
 terminal_app_ensure_encoding (TerminalApp *app,
@@ -1558,7 +1563,7 @@ terminal_app_ensure_encoding (TerminalApp *app,
 {
   TerminalEncoding *encoding;
 
-  encoding = g_hash_table_lookup (app->encodings, charset);
+  encoding = g_hash_table_lookup (app->encodings, charset ? charset : "current");
   if (encoding == NULL)
     {
       encoding = terminal_encoding_new (charset,
diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
index 3e8f8e3..fd0f18f 100644
--- a/src/terminal-schemas.h
+++ b/src/terminal-schemas.h
@@ -39,6 +39,7 @@ G_BEGIN_DECLS
 #define TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS_KEY       "default-size-columns"
 #define TERMINAL_PROFILE_DEFAULT_SIZE_ROWS_KEY          "default-size-rows"
 #define TERMINAL_PROFILE_DELETE_BINDING_KEY             "delete-binding"
+#define TERMINAL_PROFILE_ENCODING                       "encoding"
 #define TERMINAL_PROFILE_EXIT_ACTION_KEY                "exit-action"
 #define TERMINAL_PROFILE_FONT_KEY                       "font"
 #define TERMINAL_PROFILE_FOREGROUND_COLOR_KEY           "foreground-color"
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 7b3ed26..231eac3 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -892,6 +892,15 @@ terminal_screen_profile_changed_cb (GSettings     *profile,
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLLBAR_POLICY_KEY))
     _terminal_screen_update_scrollbar (screen);
 
+  if (!prop_name || prop_name == I_(TERMINAL_PROFILE_ENCODING))
+    {
+      TerminalEncoding *encoding;
+
+      encoding = terminal_app_ensure_encoding (terminal_app_get (),
+                                               g_settings_get_string (profile, TERMINAL_PROFILE_ENCODING));
+      vte_terminal_set_encoding (vte_terminal, terminal_encoding_get_charset (encoding));
+    }
+
   if (!prop_name ||
       prop_name == I_(TERMINAL_PROFILE_TITLE_MODE_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_TITLE_KEY))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]