Remove encoding from the Context menu
This commit is contained in:
parent
9f7ed7ee21
commit
308c8d81a2
|
@ -245,8 +245,6 @@ DEFAULTS = {
|
||||||
'use_theme_colors' : False,
|
'use_theme_colors' : False,
|
||||||
'bold_is_bright' : False,
|
'bold_is_bright' : False,
|
||||||
'line_height' : 1.0,
|
'line_height' : 1.0,
|
||||||
'encoding' : 'UTF-8',
|
|
||||||
'active_encodings' : ['UTF-8', 'ISO-8859-1'],
|
|
||||||
'focus_on_close' : 'auto',
|
'focus_on_close' : 'auto',
|
||||||
'force_no_bell' : False,
|
'force_no_bell' : False,
|
||||||
'cycle_term_tab' : True,
|
'cycle_term_tab' : True,
|
||||||
|
|
|
@ -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 <chantra@debuntu.org>
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
|
@ -98,8 +98,6 @@ class Terminal(Gtk.VBox):
|
||||||
matches = None
|
matches = None
|
||||||
regex_flags = None
|
regex_flags = None
|
||||||
config = None
|
config = None
|
||||||
default_encoding = None
|
|
||||||
custom_encoding = None
|
|
||||||
custom_font_size = None
|
custom_font_size = None
|
||||||
layout_command = None
|
layout_command = None
|
||||||
relaunch_command = None
|
relaunch_command = None
|
||||||
|
@ -165,7 +163,6 @@ class Terminal(Gtk.VBox):
|
||||||
|
|
||||||
|
|
||||||
self.vte.show()
|
self.vte.show()
|
||||||
self.default_encoding = self.vte.get_encoding()
|
|
||||||
self.update_url_matches()
|
self.update_url_matches()
|
||||||
|
|
||||||
self.terminalbox = self.create_terminalbox()
|
self.terminalbox = self.create_terminalbox()
|
||||||
|
@ -1075,14 +1072,6 @@ class Terminal(Gtk.VBox):
|
||||||
else:
|
else:
|
||||||
widget.show()
|
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):
|
def on_drag_begin(self, widget, drag_context, _data):
|
||||||
"""Handle the start of a drag event"""
|
"""Handle the start of a drag event"""
|
||||||
Gtk.drag_set_icon_pixbuf(drag_context, util.widget_pixbuf(self, 512), 0, 0)
|
Gtk.drag_set_icon_pixbuf(drag_context, util.widget_pixbuf(self, 512), 0, 0)
|
||||||
|
|
|
@ -7,7 +7,6 @@ from gi.repository import Gtk
|
||||||
|
|
||||||
from .version import APP_NAME
|
from .version import APP_NAME
|
||||||
from .translation import _
|
from .translation import _
|
||||||
from .encoding import TerminatorEncoding
|
|
||||||
from .terminator import Terminator
|
from .terminator import Terminator
|
||||||
from .util import err, dbg, spawn_new_terminator
|
from .util import err, dbg, spawn_new_terminator
|
||||||
from .config import Config
|
from .config import Config
|
||||||
|
@ -221,7 +220,6 @@ class TerminalPopupMenu(object):
|
||||||
item.connect('activate', terminal.force_set_profile, profile)
|
item.connect('activate', terminal.force_set_profile, profile)
|
||||||
submenu.append(item)
|
submenu.append(item)
|
||||||
|
|
||||||
self.add_encoding_items(menu)
|
|
||||||
self.add_layout_launcher(menu)
|
self.add_layout_launcher(menu)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -256,69 +254,3 @@ class TerminalPopupMenu(object):
|
||||||
item = Gtk.MenuItem(layout)
|
item = Gtk.MenuItem(layout)
|
||||||
item.connect('activate', lambda x: spawn_new_terminator(self.terminator.origcwd, ['-u', '-l', layout]))
|
item.connect('activate', lambda x: spawn_new_terminator(self.terminator.origcwd, ['-u', '-l', layout]))
|
||||||
submenu.append(item)
|
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)
|
|
||||||
|
|
Loading…
Reference in New Issue