From ac56c185015182db8c40ffe8dbe435f0ef1bc963 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 28 May 2009 10:29:56 +0200 Subject: [PATCH] Add support for spawning new windows as new Terminator processes. Closes LP #381193 --- ChangeLog | 2 ++ doc/terminator.1 | 3 +++ doc/terminator_config.5 | 4 ++++ terminator | 3 +++ terminatorlib/config.py | 1 + terminatorlib/terminator.py | 1 + terminatorlib/terminatorterm.py | 14 ++++++++++++++ 7 files changed, 28 insertions(+) diff --git a/ChangeLog b/ChangeLog index 56b5b759..346f1f4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ terminator 0.13: * Add configurability of cursor colour and shape * Support various VoIP URIs * Addcommand line option to force a particular window title + * Add a hotkey for spawning a new Terminator instance + (emulates a "new window" feature) terminator 0.12: * Bug fixes diff --git a/doc/terminator.1 b/doc/terminator.1 index 2b2c0303..500ca2b9 100644 --- a/doc/terminator.1 +++ b/doc/terminator.1 @@ -174,6 +174,9 @@ Group all terminals in the current tab so input sent to one of them, goes to all .TP .B Super+Shift+T Remove grouping from all terminals in the current tab. +.TP +.B Ctrl+Shift+I +Spawn a new Terminator process and thus get a new window .SH "Drag and Drop" The layout can be modified by moving terminals with Drag and Drop. To start dragging a terminal, hold down \fBCtrl\fP, click and hold the \fBright\fP mouse button. diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index 5a5bbbad..06055fe9 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -388,5 +388,9 @@ Default value: \fBt\fR .B ungroup_tab Remove grouping from all terminals in the current tab. Default value: \fBT\fR +.TP +.B new_window +Spawn a new instance of Terminator and thus get a new window. +Default value: \fBI\fR .SH "SEE ALSO" .BR gnome\-terminal(1) diff --git a/terminator b/terminator index 650b762d..3ffb1a09 100755 --- a/terminator +++ b/terminator @@ -20,6 +20,7 @@ # import standard python libs import os, sys +origcwd = os.getcwd() from optparse import OptionParser, SUPPRESS_HELP import terminatorlib.translation @@ -161,6 +162,8 @@ See the following bug report for more details: options.maximise, options.borderless, options.no_gconf, options.geometry, options.hidden, options.forcedtitle) + term.origcwd = origcwd + if options.debug > 1: import terminatorlib.debugserver as debugserver import threading diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 81115f48..cc35ed84 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -169,6 +169,7 @@ DEFAULTS = { 'ungroup_all' : 'g', 'group_tab' : 't', 'ungroup_tab' : 'T', + 'new_window' : 'I', } } diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 1177c6fd..1485d87c 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -210,6 +210,7 @@ class Terminator: options = None groupings = None _urgency = False + origcwd = None def __init__ (self, profile = None, command = None, fullscreen = False, maximise = False, borderless = False, no_gconf = False, diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index 0c91f2fb..3c1a5cfd 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -1033,6 +1033,20 @@ text/plain def key_ungroup_tab(self): self.ungroup_tab(self) + + def key_new_window(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.terminator.origcwd, 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') + return False + + dbg("Spawning: %s" % cmd) + subprocess.Popen([cmd,]) # End key events def zoom_orig (self):