[gnome-terminal] profile: editor: Add encoding to compatibility options
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] profile: editor: Add encoding to compatibility options
- Date: Wed, 2 Apr 2014 19:28:20 +0000 (UTC)
commit 431161507a924ab2c4b18f1049b83c72abb3d20b
Author: Christian Persch <chpe gnome org>
Date: Wed Apr 2 21:24:58 2014 +0200
profile: editor: Add encoding to compatibility options
https://bugzilla.gnome.org/show_bug.cgi?id=108711
src/migration.c | 2 +-
src/profile-editor.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
src/profile-preferences.ui | 31 ++++++++++++++++++++++-
src/terminal-schemas.h | 2 +-
src/terminal-screen.c | 4 +-
5 files changed, 93 insertions(+), 5 deletions(-)
---
diff --git a/src/migration.c b/src/migration.c
index b1e703c..2332259 100644
--- a/src/migration.c
+++ b/src/migration.c
@@ -463,7 +463,7 @@ migrate_profile (TerminalSettingsList *list,
settings, TERMINAL_PROFILE_USE_SYSTEM_FONT_KEY,
FALSE);
migrate_string (client, path, KEY_ENCODING,
- settings, TERMINAL_PROFILE_ENCODING);
+ settings, TERMINAL_PROFILE_ENCODING_KEY);
g_free (path);
g_object_unref (settings);
diff --git a/src/profile-editor.c b/src/profile-editor.c
index 1b3e855..40eabcb 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -466,6 +466,56 @@ init_color_scheme_menu (GtkWidget *widget)
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL);
}
+enum {
+ ENCODINGS_COLUMN_ID,
+ ENCODINGS_COLUMN_MARKUP
+};
+
+static void
+init_encodings_combo (GtkWidget *widget)
+{
+ GtkCellRenderer *renderer;
+ GHashTableIter ht_iter;
+ gpointer key, value;
+ gs_unref_object GtkListStore *store;
+ GtkTreeIter iter;
+
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+ g_hash_table_iter_init (&ht_iter, terminal_app_get_encodings (terminal_app_get ()));
+ while (g_hash_table_iter_next (&ht_iter, &key, &value)) {
+ TerminalEncoding *encoding = value;
+ gs_free char *name;
+
+ name = g_markup_printf_escaped ("%s <span size=\"small\">%s</span>",
+ terminal_encoding_get_charset (encoding),
+ encoding->name);
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ ENCODINGS_COLUMN_MARKUP, name,
+ ENCODINGS_COLUMN_ID, terminal_encoding_get_charset (encoding),
+ -1);
+ }
+
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ ENCODINGS_COLUMN_MARKUP, _("Default"),
+ ENCODINGS_COLUMN_ID, "current",
+ -1);
+
+ /* Now turn on sorting */
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ ENCODINGS_COLUMN_MARKUP,
+ GTK_SORT_ASCENDING);
+
+ gtk_combo_box_set_id_column (GTK_COMBO_BOX (widget), ENCODINGS_COLUMN_ID);
+ gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
+
+ /* Cell renderer */
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer,
+ "markup", ENCODINGS_COLUMN_MARKUP, NULL);
+}
+
static void
editor_response_cb (GtkWidget *editor,
int response,
@@ -1026,6 +1076,15 @@ terminal_profile_edit (GSettings *profile,
gtk_builder_get_object (builder, "rewrap-on-resize-checkbutton"),
"active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ /* Compatibility options */
+ w = (GtkWidget *) gtk_builder_get_object (builder, "encoding-combobox");
+ init_encodings_combo (w);
+ g_settings_bind (profile,
+ TERMINAL_PROFILE_ENCODING_KEY,
+ w,
+ "active-id", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
+ /* Finished! */
terminal_util_bind_mnemonic_label_sensitivity (editor);
terminal_util_dialog_focus_widget (editor, widget_name);
diff --git a/src/profile-preferences.ui b/src/profile-preferences.ui
index f648938..55f3e70 100644
--- a/src/profile-preferences.ui
+++ b/src/profile-preferences.ui
@@ -1839,7 +1839,7 @@
<object class="GtkTable" id="table30">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">2</property>
+ <property name="n_rows">3</property>
<property name="n_columns">3</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -1915,6 +1915,35 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="encoding-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Encoding:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="encoding-combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
index 443cf7b..2a41b3d 100644
--- a/src/terminal-schemas.h
+++ b/src/terminal-schemas.h
@@ -42,7 +42,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_ENCODING_KEY "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 f49d69d..bfd4c61 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -760,12 +760,12 @@ 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))
+ if (!prop_name || prop_name == I_(TERMINAL_PROFILE_ENCODING_KEY))
{
TerminalEncoding *encoding;
gs_free char *str;
- str = g_settings_get_string (profile, TERMINAL_PROFILE_ENCODING);
+ str = g_settings_get_string (profile, TERMINAL_PROFILE_ENCODING_KEY);
encoding = terminal_app_ensure_encoding (terminal_app_get (), str);
vte_terminal_set_encoding (vte_terminal, terminal_encoding_get_charset (encoding));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]