land encoding support branch
This commit is contained in:
commit
5a221d1572
4
TODO
4
TODO
|
@ -1,2 +1,6 @@
|
|||
* Edit doc/terminatorrc.5 manpage to contain the information about the options
|
||||
* Write a Tab feature for terminator
|
||||
|
||||
* handling encoding
|
||||
print self._vte.get_encoding ()
|
||||
actually defaults to UTF-8
|
||||
|
|
2
setup.py
2
setup.py
|
@ -84,7 +84,7 @@ setup(name='Terminator',
|
|||
('share/icons/hicolor/24x24/apps', glob.glob('data/icons/24x24/apps/*.png')),
|
||||
('share/icons/hicolor/48x48/apps', glob.glob('data/icons/48x48/apps/*.png')),
|
||||
],
|
||||
py_modules=['terminatorconfig'],
|
||||
py_modules=['terminatorconfig', 'terminatorencoding'],
|
||||
cmdclass={'build': BuildData, 'install_data': InstallData}
|
||||
)
|
||||
|
||||
|
|
60
terminator
60
terminator
|
@ -38,6 +38,9 @@ import pwd
|
|||
# import our configuration loader
|
||||
import terminatorconfig
|
||||
|
||||
#import encoding list
|
||||
from terminatorencoding import TerminatorEncoding
|
||||
|
||||
# import gtk libs
|
||||
# check just in case anyone runs it on a non-gnome system.
|
||||
try:
|
||||
|
@ -520,6 +523,8 @@ class TerminatorTerm (gtk.VBox):
|
|||
item.connect ("toggled", lambda menu_item: self.do_title_toggle ())
|
||||
menu.append (item)
|
||||
|
||||
self._do_encoding_items (menu)
|
||||
|
||||
item = gtk.MenuItem ()
|
||||
menu.append (item)
|
||||
|
||||
|
@ -541,6 +546,61 @@ class TerminatorTerm (gtk.VBox):
|
|||
menu.show_all ()
|
||||
return menu
|
||||
|
||||
def on_encoding_change (self, widget, encoding):
|
||||
current = self._vte.get_encoding ()
|
||||
if current != encoding:
|
||||
dbg ('Setting Encoding to: %s'%encoding)
|
||||
self._vte.set_encoding (encoding)
|
||||
|
||||
def _do_encoding_items (self, menu):
|
||||
active_encodings = self.conf.active_encodings
|
||||
item = gtk.MenuItem (_("Encodings"))
|
||||
menu.append (item)
|
||||
submenu = gtk.Menu ()
|
||||
item.set_submenu (submenu)
|
||||
|
||||
current_encoding = self._vte.get_encoding ()
|
||||
group = None
|
||||
for encoding in active_encodings:
|
||||
radioitem = gtk.RadioMenuItem (group, _(encoding))
|
||||
if group is None:
|
||||
group = radioitem
|
||||
|
||||
if encoding == current_encoding:
|
||||
radioitem.set_active (True)
|
||||
|
||||
radioitem.connect ('activate', self.on_encoding_change, encoding)
|
||||
submenu.append (radioitem)
|
||||
|
||||
item = gtk.MenuItem (_("Other Encodings"))
|
||||
submenu.append (item)
|
||||
#second level
|
||||
|
||||
submenu = gtk.Menu ()
|
||||
item.set_submenu (submenu)
|
||||
encodings = TerminatorEncoding ().get_list ()
|
||||
encodings.sort (lambda x, y: cmp (x[2].lower (), y[2].lower ()))
|
||||
group = None
|
||||
|
||||
for encoding in encodings:
|
||||
if encoding[1] in active_encodings:
|
||||
continue
|
||||
|
||||
if encoding[1] is None:
|
||||
label = "%s %s"%(encoding[2], self._vte.get_encoding ())
|
||||
else:
|
||||
label = "%s %s"%(encoding[2], encoding[1])
|
||||
|
||||
radioitem = gtk.RadioMenuItem (group, label)
|
||||
if group is None:
|
||||
group = radioitem
|
||||
|
||||
if encoding[1] == current_encoding:
|
||||
radioitem.set_active (True)
|
||||
|
||||
radioitem.connect ('activate', self.on_encoding_change, encoding[1])
|
||||
submenu.append (radioitem)
|
||||
|
||||
def on_vte_title_change(self, vte):
|
||||
if self.conf.titletips:
|
||||
vte.set_property ("has-tooltip", True)
|
||||
|
|
|
@ -110,6 +110,8 @@ class TerminatorConfValuestore:
|
|||
'use_theme_colors' : True,
|
||||
'http_proxy' : '',
|
||||
'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'],
|
||||
'encoding' : 'UTF-8',
|
||||
'active_encodings' : ['UTF-8', 'ISO-8859-1'],
|
||||
}
|
||||
|
||||
def __getattr__ (self, keyname):
|
||||
|
@ -169,6 +171,10 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
|
|||
profile = self.client.get_string (self._gt_dir + '/global/default_profile')
|
||||
profiles = self.client.get_list (self._gt_dir + '/global/profile_list','string')
|
||||
|
||||
#set up the active encoding list
|
||||
self.active_encodings = self.client.get_list (self._gt_dir + '/global/active_encodings', 'string')
|
||||
|
||||
#need to handle the list of Gconf.value
|
||||
if profile in profiles:
|
||||
dbg (" VSGConf: Found profile '%s' in profile_list"%profile)
|
||||
self.profile = '%s/%s'%(self._profile_dir, profile)
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
#!/usr/bin/python
|
||||
# TerminatorEncoding - charset encoding classes
|
||||
# Copyright (C) 2006-2008 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/encoding.h
|
||||
and src/encoding.c
|
||||
"""
|
||||
|
||||
class TerminatorEncoding:
|
||||
|
||||
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, "ISO2022JP", _("Japanese") ],
|
||||
[False, "ISO2022KR", _("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 get_list():
|
||||
return TerminatorEncoding.encodings
|
||||
get_list = staticmethod(get_list)
|
||||
|
Loading…
Reference in New Issue