fix terminal spawning and font zooming

This commit is contained in:
Chris Jones 2009-10-28 23:07:42 +00:00
parent 6f2fd988b4
commit 565257672a
1 changed files with 31 additions and 3 deletions

View File

@ -9,7 +9,9 @@ import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import gobject import gobject
import pango
import re import re
import subprocess
from util import dbg, err, gerr, widget_pixbuf from util import dbg, err, gerr, widget_pixbuf
import util import util
@ -770,13 +772,39 @@ class Terminal(gtk.VBox):
"""Feed the supplied text to VTE""" """Feed the supplied text to VTE"""
self.vte.feed_child(text) 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 # There now begins a great list of keyboard event handlers
# FIXME: Probably a bunch of these are wrong. TEST! # FIXME: Probably a bunch of these are wrong. TEST!
def key_zoom_in(self): def key_zoom_in(self):
self.zoom(True) self.zoom_in()
def key_zoom_out(self): def key_zoom_out(self):
self.zoom(False) self.zoom_out()
def key_copy(self): def key_copy(self):
self.vte.copy_clipboard() self.vte.copy_clipboard()
@ -913,7 +941,7 @@ class Terminal(gtk.VBox):
if not os.path.isabs(cmd): if not os.path.isabs(cmd):
# Command is not an absolute path. Figure out where we are # 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): if not os.path.isfile(cmd):
# we weren't started as ./terminator in a path. Give up # we weren't started as ./terminator in a path. Give up
err('Unable to locate Terminator') err('Unable to locate Terminator')