From 0533af23ae1ac5adc1cd13f252fbb80f14f16920 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 23 Jun 2010 12:03:04 +0100 Subject: [PATCH] Enable selecting a profile's encoding via the prefs UI. Closes LP #597340 --- terminatorlib/preferences.glade | 81 +++++++++++++++++++++++++++++++++ terminatorlib/prefseditor.py | 27 +++++++++++ 2 files changed, 108 insertions(+) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 74eae78b..d741d0cc 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -263,6 +263,14 @@ + + + + + + + + 5 normal @@ -2516,6 +2524,79 @@ 2 + + + True + 6 + + + True + 0 + <b>Encoding</b> + True + + + False + False + 0 + + + + + True + 12 + + + True + 2 + 12 + 6 + + + True + 0 + Default: + True + center + color_scheme_combobox + + + GTK_FILL + + + + + + True + EncodingListStore + + + + + 0 + + + + + 1 + 2 + GTK_FILL + + + + + + + False + 1 + + + + + False + 3 + + 5 diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index f60259b4..70796a85 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -14,6 +14,7 @@ from util import dbg, err import config from keybindings import Keybindings, KeymapError from translation import _ +from encoding import TerminatorEncoding from terminator import Terminator from plugin import PluginRegistry @@ -499,6 +500,23 @@ class PrefsEditor: widget.set_active(3) else: widget.set_active(0) + # Encoding + rowiter = None + widget = guiget('encoding_combobox') + encodingstore = guiget('EncodingListStore') + value = self.config['encoding'] + encodings = TerminatorEncoding().get_list() + encodings.sort(lambda x, y: cmp(x[2].lower(), y[2].lower())) + + for encoding in encodings: + if encoding[1] is None: + continue + + label = "%s %s" % (encoding[2], encoding[1]) + rowiter = encodingstore.append([label, encoding[1]]) + + if encoding[1] == value: + widget.set_active_iter(rowiter) def set_layout(self, layout_name): """Set a layout""" @@ -607,6 +625,15 @@ class PrefsEditor: self.config['backspace_binding'] = value self.config.save() + def on_encoding_combobox_changed(self, widget): + """Encoding setting changed""" + selected = widget.get_active_iter() + liststore = widget.get_model() + value = liststore.get_value(selected, 1) + + self.config['encoding'] = value + self.config.save() + def on_scrollback_lines_spinbutton_value_changed(self, widget): """Scrollback lines setting changed""" value = widget.get_value_as_int()