Fix up the startup cwd tracking so self-spawning works in non-absolute paths, and handle the key_new_window => key_new_terminator switch

This commit is contained in:
Chris Jones 2010-01-29 23:52:21 +00:00
parent a5ac05bcc9
commit e3438b3bdf
3 changed files with 11 additions and 1 deletions

View File

@ -19,6 +19,8 @@
"""Terminator by Chris Jones <cmsj@tenshu.net>"""
import sys
import os
ORIGCWD = os.getcwd()
# Check we have simple basics like Gtk+ and a valid $DISPLAY
try:
@ -50,6 +52,7 @@ if __name__ == '__main__':
MAKER = Factory()
TERMINATOR = Terminator()
TERMINATOR.origcwd = ORIGCWD
TERMINATOR.reconfigure()
TERMINATOR.new_window()

View File

@ -76,6 +76,7 @@ class Terminal(gtk.VBox):
group = None
cwd = None
origcwd = None
command = None
clipboard = None
pid = None
@ -109,6 +110,7 @@ class Terminal(gtk.VBox):
self.config = Config()
self.cwd = get_default_cwd()
self.origcwd = self.terminator.origcwd
self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
self.vte = vte.Terminal()
@ -1301,11 +1303,14 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
self.emit('ungroup-tab')
def key_new_window(self):
self.terminator.new_window()
def key_new_terminator(self):
cmd = sys.argv[0]
if not os.path.isabs(cmd):
# Command is not an absolute path. Figure out where we are
cmd = os.path.join (self.cwd, sys.argv[0])
cmd = os.path.join (self.origcwd, sys.argv[0])
if not os.path.isfile(cmd):
# we weren't started as ./terminator in a path. Give up
err('Terminal::key_new_window: Unable to locate Terminator')

View File

@ -21,6 +21,8 @@ class Terminator(Borg):
config = None
keybindings = None
origcwd = None
groupsend = None
groupsend_type = {'all':0, 'group':1, 'off':2}