From 565257672a30199e11c179fe8b1de0e7baf38b46 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 28 Oct 2009 23:07:42 +0000 Subject: [PATCH] fix terminal spawning and font zooming --- terminatorlib/terminal.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 59245370..1f6f1249 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -9,7 +9,9 @@ import pygtk pygtk.require('2.0') import gtk import gobject +import pango import re +import subprocess from util import dbg, err, gerr, widget_pixbuf import util @@ -770,13 +772,39 @@ class Terminal(gtk.VBox): """Feed the supplied text to VTE""" self.vte.feed_child(text) + def zoom_in(self): + """Increase the font size""" + self.zoom_font(True) + + def zoom_out(self): + """Decrease the font size""" + self.zoom_font(False) + + def zoom_font(self, zoom_in): + """Change the font size""" + pangodesc = self.vte.get_font() + fontsize = pangodesc.get_size() + + if fontsize > pango.SCALE and not zoom_in: + fontsize -= pango.SCALE + elif zoom_in: + fontsize += pango.SCALE + + pangodesc.set_size(fontsize) + self.vte.set_font(pangodesc) + + def zoom_orig(self): + """Restore original font size""" + print "restoring font to: %s" % self.config['font'] + self.vte.set_font(pango.FontDescription(self.config['font'])) + # There now begins a great list of keyboard event handlers # FIXME: Probably a bunch of these are wrong. TEST! def key_zoom_in(self): - self.zoom(True) + self.zoom_in() def key_zoom_out(self): - self.zoom(False) + self.zoom_out() def key_copy(self): self.vte.copy_clipboard() @@ -913,7 +941,7 @@ class Terminal(gtk.VBox): if not os.path.isabs(cmd): # Command is not an absolute path. Figure out where we are - cmd = os.path.join (self.terminator.origcwd, sys.argv[0]) + cmd = os.path.join (self.cwd, sys.argv[0]) if not os.path.isfile(cmd): # we weren't started as ./terminator in a path. Give up err('Unable to locate Terminator')