From 9f7ed7ee21f223f93c6c85be514d316e82dc9782 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 6 Nov 2021 11:43:23 +0100 Subject: [PATCH 1/2] Remove encoding from the Preferences menu --- terminatorlib/preferences.glade | 49 ++------------------------------- terminatorlib/prefseditor.py | 27 ------------------ terminatorlib/terminal.py | 2 -- 3 files changed, 2 insertions(+), 76 deletions(-) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 9ed10183..2c73f5e5 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -137,14 +137,6 @@ - - - - - - - - @@ -2955,7 +2947,7 @@ - + True False @@ -3051,42 +3043,6 @@ 2 - - - True - False - end - Encoding: - True - center - end - 0 - - - 0 - 3 - - - - - True - False - start - True - EncodingListStore - - - - - 0 - - - - - 1 - 3 - - _Reset Compatibility Options to Defaults @@ -3101,7 +3057,7 @@ 0 - 4 + 3 2 @@ -4127,7 +4083,6 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding - diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 7d4d1c31..23325940 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -14,7 +14,6 @@ from .util import dbg, err from . import config from .keybindings import Keybindings, KeymapError from .translation import _ -from .encoding import TerminatorEncoding from .terminator import Terminator from .plugin import PluginRegistry from .version import APP_NAME @@ -687,23 +686,6 @@ 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(key=lambda x: x[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) ## Titlebar tab # Titlebar colors @@ -924,15 +906,6 @@ 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() diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 70ff6984..3c877b08 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -660,8 +660,6 @@ class Terminal(Gtk.VBox): self.cnxids.new(self.vte, 'child-exited', lambda x, y: self.emit('close-term')) - if self.custom_encoding != True: - self.vte.set_encoding(self.config['encoding']) # Word char support was missing from vte 0.38, silently skip this setting if hasattr(self.vte, 'set_word_char_exceptions'): self.vte.set_word_char_exceptions(self.config['word_chars']) From 308c8d81a2e7695f359ab9580a884bbfb627aace Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 6 Nov 2021 11:55:33 +0100 Subject: [PATCH 2/2] Remove encoding from the Context menu --- terminatorlib/config.py | 2 - terminatorlib/encoding.py | 118 --------------------------- terminatorlib/terminal.py | 11 --- terminatorlib/terminal_popup_menu.py | 68 --------------- 4 files changed, 199 deletions(-) delete mode 100644 terminatorlib/encoding.py diff --git a/terminatorlib/config.py b/terminatorlib/config.py index ed0c8757..b0888a71 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -245,8 +245,6 @@ DEFAULTS = { 'use_theme_colors' : False, 'bold_is_bright' : False, 'line_height' : 1.0, - 'encoding' : 'UTF-8', - 'active_encodings' : ['UTF-8', 'ISO-8859-1'], 'focus_on_close' : 'auto', 'force_no_bell' : False, 'cycle_term_tab' : True, diff --git a/terminatorlib/encoding.py b/terminatorlib/encoding.py deleted file mode 100644 index 1368d973..00000000 --- a/terminatorlib/encoding.py +++ /dev/null @@ -1,118 +0,0 @@ -# TerminatorEncoding - charset encoding classes -# Copyright (C) 2006-2010 chantra@debuntu.org -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 2 only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -"""TerminatorEncoding by Emmanuel Bretelle - -TerminatorEncoding supplies a list of possible encoding - values. -This list is taken from gnome-terminal's src/terminal-encoding.c - and src/encoding.c -""" - -from .translation import _ - -#pylint: disable-msg=R0903 -class TerminatorEncoding: - """Class to store encoding details""" - -# The commented out entries below are so marked because gnome-terminal has done -# the same. - encodings = [ - [True, None, _("Current Locale")], - [False, "ISO-8859-1", _("Western")], - [False, "ISO-8859-2", _("Central European")], - [False, "ISO-8859-3", _("South European") ], - [False, "ISO-8859-4", _("Baltic") ], - [False, "ISO-8859-5", _("Cyrillic") ], - [False, "ISO-8859-6", _("Arabic") ], - [False, "ISO-8859-7", _("Greek") ], - [False, "ISO-8859-8", _("Hebrew Visual") ], - [False, "ISO-8859-8-I", _("Hebrew") ], - [False, "ISO-8859-9", _("Turkish") ], - [False, "ISO-8859-10", _("Nordic") ], - [False, "ISO-8859-13", _("Baltic") ], - [False, "ISO-8859-14", _("Celtic") ], - [False, "ISO-8859-15", _("Western") ], - [False, "ISO-8859-16", _("Romanian") ], - # [False, "UTF-7", _("Unicode") ], - [False, "UTF-8", _("Unicode") ], - # [False, "UTF-16", _("Unicode") ], - # [False, "UCS-2", _("Unicode") ], - # [False, "UCS-4", _("Unicode") ], - [False, "ARMSCII-8", _("Armenian") ], - [False, "BIG5", _("Chinese Traditional") ], - [False, "BIG5-HKSCS", _("Chinese Traditional") ], - [False, "CP866", _("Cyrillic/Russian") ], - [False, "EUC-JP", _("Japanese") ], - [False, "EUC-KR", _("Korean") ], - [False, "EUC-TW", _("Chinese Traditional") ], - [False, "GB18030", _("Chinese Simplified") ], - [False, "GB2312", _("Chinese Simplified") ], - [False, "GBK", _("Chinese Simplified") ], - [False, "GEORGIAN-PS", _("Georgian") ], - [False, "HZ", _("Chinese Simplified") ], - [False, "IBM850", _("Western") ], - [False, "IBM852", _("Central European") ], - [False, "IBM855", _("Cyrillic") ], - [False, "IBM857", _("Turkish") ], - [False, "IBM862", _("Hebrew") ], - [False, "IBM864", _("Arabic") ], - [False, "ISO-2022-JP", _("Japanese") ], - [False, "ISO-2022-KR", _("Korean") ], - [False, "ISO-IR-111", _("Cyrillic") ], - # [False, "JOHAB", _("Korean") ], - [False, "KOI8-R", _("Cyrillic") ], - [False, "KOI8-U", _("Cyrillic/Ukrainian") ], - [False, "MAC_ARABIC", _("Arabic") ], - [False, "MAC_CE", _("Central European") ], - [False, "MAC_CROATIAN", _("Croatian") ], - [False, "MAC-CYRILLIC", _("Cyrillic") ], - [False, "MAC_DEVANAGARI", _("Hindi") ], - [False, "MAC_FARSI", _("Persian") ], - [False, "MAC_GREEK", _("Greek") ], - [False, "MAC_GUJARATI", _("Gujarati") ], - [False, "MAC_GURMUKHI", _("Gurmukhi") ], - [False, "MAC_HEBREW", _("Hebrew") ], - [False, "MAC_ICELANDIC", _("Icelandic") ], - [False, "MAC_ROMAN", _("Western") ], - [False, "MAC_ROMANIAN", _("Romanian") ], - [False, "MAC_TURKISH", _("Turkish") ], - [False, "MAC_UKRAINIAN", _("Cyrillic/Ukrainian") ], - [False, "SHIFT-JIS", _("Japanese") ], - [False, "TCVN", _("Vietnamese") ], - [False, "TIS-620", _("Thai") ], - [False, "UHC", _("Korean") ], - [False, "VISCII", _("Vietnamese") ], - [False, "WINDOWS-1250", _("Central European") ], - [False, "WINDOWS-1251", _("Cyrillic") ], - [False, "WINDOWS-1252", _("Western") ], - [False, "WINDOWS-1253", _("Greek") ], - [False, "WINDOWS-1254", _("Turkish") ], - [False, "WINDOWS-1255", _("Hebrew") ], - [False, "WINDOWS-1256", _("Arabic") ], - [False, "WINDOWS-1257", _("Baltic") ], - [False, "WINDOWS-1258", _("Vietnamese") ] - ] - - def __init__(self): - pass - - def get_list(): - """Return a list of supported encodings""" - return TerminatorEncoding.encodings - - get_list = staticmethod(get_list) - diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 3c877b08..6c224b94 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -98,8 +98,6 @@ class Terminal(Gtk.VBox): matches = None regex_flags = None config = None - default_encoding = None - custom_encoding = None custom_font_size = None layout_command = None relaunch_command = None @@ -165,7 +163,6 @@ class Terminal(Gtk.VBox): self.vte.show() - self.default_encoding = self.vte.get_encoding() self.update_url_matches() self.terminalbox = self.create_terminalbox() @@ -1075,14 +1072,6 @@ class Terminal(Gtk.VBox): else: widget.show() - def on_encoding_change(self, _widget, encoding): - """Handle the encoding changing""" - current = self.vte.get_encoding() - if current != encoding: - dbg('on_encoding_change: setting encoding to: %s' % encoding) - self.custom_encoding = not (encoding == self.config['encoding']) - self.vte.set_encoding(encoding) - def on_drag_begin(self, widget, drag_context, _data): """Handle the start of a drag event""" Gtk.drag_set_icon_pixbuf(drag_context, util.widget_pixbuf(self, 512), 0, 0) diff --git a/terminatorlib/terminal_popup_menu.py b/terminatorlib/terminal_popup_menu.py index 9682c176..7c483fda 100644 --- a/terminatorlib/terminal_popup_menu.py +++ b/terminatorlib/terminal_popup_menu.py @@ -7,7 +7,6 @@ from gi.repository import Gtk from .version import APP_NAME from .translation import _ -from .encoding import TerminatorEncoding from .terminator import Terminator from .util import err, dbg, spawn_new_terminator from .config import Config @@ -221,7 +220,6 @@ class TerminalPopupMenu(object): item.connect('activate', terminal.force_set_profile, profile) submenu.append(item) - self.add_encoding_items(menu) self.add_layout_launcher(menu) try: @@ -256,69 +254,3 @@ class TerminalPopupMenu(object): item = Gtk.MenuItem(layout) item.connect('activate', lambda x: spawn_new_terminator(self.terminator.origcwd, ['-u', '-l', layout])) submenu.append(item) - - def add_encoding_items(self, menu): - """Add the encoding list to the menu""" - terminal = self.terminal - active_encodings = terminal.config['active_encodings'] - item = Gtk.MenuItem.new_with_mnemonic(_("Encodings")) - menu.append (item) - submenu = Gtk.Menu () - item.set_submenu (submenu) - encodings = TerminatorEncoding ().get_list () - encodings.sort (key=lambda x: x[2].lower ()) - - current_encoding = terminal.vte.get_encoding () - group = None - - if current_encoding not in active_encodings: - active_encodings.insert (0, _(current_encoding)) - - for encoding in active_encodings: - if encoding == terminal.default_encoding: - extratext = " (%s)" % _("Default") - elif encoding == current_encoding and \ - terminal.custom_encoding == True: - extratext = " (%s)" % _("User defined") - else: - extratext = "" - - radioitem = Gtk.RadioMenuItem (_(encoding) + extratext, group) - - if encoding == current_encoding: - radioitem.set_active (True) - - if group is None: - group = radioitem - - radioitem.connect ('activate', terminal.on_encoding_change, - encoding) - submenu.append (radioitem) - - item = Gtk.MenuItem.new_with_mnemonic(_("Other Encodings")) - submenu.append (item) - #second level - - submenu = Gtk.Menu () - item.set_submenu (submenu) - group = None - - for encoding in encodings: - if encoding[1] in active_encodings: - continue - - if encoding[1] is None: - label = "%s %s" % (encoding[2], terminal.vte.get_encoding ()) - else: - label = "%s %s" % (encoding[2], encoding[1]) - - radioitem = Gtk.RadioMenuItem (label, group) - if group is None: - group = radioitem - - if encoding[1] == current_encoding: - radioitem.set_active (True) - - radioitem.connect ('activate', terminal.on_encoding_change, - encoding[1]) - submenu.append (radioitem)