From 24278a3be06a2870140116a5c422e08a9e5e169b Mon Sep 17 00:00:00 2001 From: Emmanuel Bretelle Date: Thu, 15 May 2008 07:41:00 +0100 Subject: [PATCH] starting with encoding --- TODO | 4 ++++ terminator | 37 ++++++++++++++++++++++++++++++++++--- terminatorconfig.py | 8 +++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 3e66cca9..2ef0b4e7 100644 --- a/TODO +++ b/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 diff --git a/terminator b/terminator index 2f5034cc..932e32f7 100755 --- a/terminator +++ b/terminator @@ -103,6 +103,7 @@ class TerminatorTerm: self._box.show() self._box.pack_start(self._titlebox, False) self._box.pack_start(self._termbox) + if len(self.terminator.term_list) > 0 and self.conf.titlebars: if len(self.terminator.term_list) == 1: self.terminator.term_list[0]._titlebox.show() @@ -310,7 +311,13 @@ class TerminatorTerm: # Set our sloppiness self.focus = self.conf.focus - + + def on_encoding_change (self, widget, encoding): + current = self._vte.get_encoding() + if current != encoding: + print ('Setting Encoding to ' + encoding) + self._vte.set_encoding(encoding) + def on_composited_changed (self, widget): self.reconfigure_vte () @@ -487,16 +494,40 @@ class TerminatorTerm: item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, True)) menu.append (item) + self._do_encoding_items(menu) + item = gtk.MenuItem () menu.append (item) - + item = gtk.ImageMenuItem (gtk.STOCK_CLOSE) item.connect ("activate", lambda menu_item: self.terminator.closeterm (self)) menu.append (item) menu.show_all () return menu - + + def _do_encoding_items(self, menu): + + + item = gtk.MenuItem (_("Encoding")) + menu.append(item) + submenu = gtk.Menu() + item.set_submenu(submenu) + + + current_encoding = self._vte.get_encoding () + group = None + for encoding in self.conf.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) + def on_vte_title_change(self, vte): if self.conf.titletips: vte.set_property ("has-tooltip", True) diff --git a/terminatorconfig.py b/terminatorconfig.py index e056c952..337b7ed2 100755 --- a/terminatorconfig.py +++ b/terminatorconfig.py @@ -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): @@ -212,7 +214,7 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore): value = None dbg (' VSGConf: preparing: %s/%s'%(self.profile, key)) - + # FIXME: Ugly special cases we should look to fix in some other way. if key == 'font' and self.use_system_font: value = self.client.get ('/desktop/gnome/interface/monospace_font_name') @@ -234,8 +236,12 @@ class TerminatorConfValuestoreGConf (TerminatorConfValuestore): value = 'http://%s:%s/'%( self.client.get_string ('/system/http_proxy/host'), self.client.get_int ('/system/http_proxy/port')) + elif key == 'active_encodings': + value = self.client.get_list (self._gt_dir + '/global/active_encodings', 'string') else: value = self.client.get ('%s/%s'%(self.profile, key)) + + if value: funcname = "get_" + self.defaults[key].__class__.__name__