Set cwd when spawning new shells to be that of the shell being split. Does not currently persist across tab creations

This commit is contained in:
Chris Jones 2010-03-05 22:44:38 +00:00
parent b8703fdecb
commit 706180976e
6 changed files with 26 additions and 12 deletions

View File

@ -63,15 +63,15 @@ class Container(object):
"""Return a list of direct child widgets, if any""" """Return a list of direct child widgets, if any"""
return(self.children) return(self.children)
def split_horiz(self, widget): def split_horiz(self, widget, cwd=None):
"""Split this container horizontally""" """Split this container horizontally"""
return(self.split_axis(widget, True)) return(self.split_axis(widget, True, cwd))
def split_vert(self, widget): def split_vert(self, widget, cwd=None):
"""Split this container vertically""" """Split this container vertically"""
return(self.split_axis(widget, False)) return(self.split_axis(widget, False, cwd))
def split_axis(self, widget, vertical=True, sibling=None, siblinglast=None): def split_axis(self, widget, vertical=True, cwd=None, sibling=None, siblinglast=None):
"""Default axis splitter. This should be implemented by subclasses""" """Default axis splitter. This should be implemented by subclasses"""
raise NotImplementedError('split_axis') raise NotImplementedError('split_axis')

View File

@ -86,7 +86,7 @@ class Notebook(Container, gtk.Notebook):
page.create_layout(children[child_key]) page.create_layout(children[child_key])
num = num + 1 num = num + 1
def split_axis(self, widget, vertical=True, sibling=None, widgetfirst=True): def split_axis(self, widget, vertical=True, cwd=None, sibling=None, widgetfirst=True):
"""Split the axis of a terminal inside us""" """Split the axis of a terminal inside us"""
order = None order = None
page_num = self.page_num(widget) page_num = self.page_num(widget)
@ -105,6 +105,7 @@ class Notebook(Container, gtk.Notebook):
if not sibling: if not sibling:
sibling = maker.make('terminal') sibling = maker.make('terminal')
sibling.set_cwd(cwd)
sibling.spawn_child() sibling.spawn_child()
self.insert_page(container, None, page_num) self.insert_page(container, None, page_num)

View File

@ -40,7 +40,7 @@ class Paned(Container):
self.cnxids.remove_signal(self, 'expose-event') self.cnxids.remove_signal(self, 'expose-event')
# pylint: disable-msg=W0613 # pylint: disable-msg=W0613
def split_axis(self, widget, vertical=True, sibling=None, def split_axis(self, widget, vertical=True, cwd=None, sibling=None,
widgetfirst=True): widgetfirst=True):
"""Default axis splitter. This should be implemented by subclasses""" """Default axis splitter. This should be implemented by subclasses"""
order = None order = None
@ -55,6 +55,7 @@ class Paned(Container):
if not sibling: if not sibling:
sibling = maker.make('terminal') sibling = maker.make('terminal')
sibling.set_cwd(cwd)
sibling.spawn_child() sibling.spawn_child()
self.add(container) self.add(container)

View File

@ -47,8 +47,10 @@ class Terminal(gtk.VBox):
'group-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'group-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'ungroup-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'ungroup-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'split-horiz': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'split-horiz': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), (gobject.TYPE_STRING,)),
'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
@ -1037,6 +1039,11 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
"""Restore normal layout""" """Restore normal layout"""
self.emit('unzoom') self.emit('unzoom')
def set_cwd(self, cwd=None):
"""Set our cwd"""
if cwd is not None:
self.cwd = cwd
def spawn_child(self, widget=None, respawn=False): def spawn_child(self, widget=None, respawn=False):
update_records = self.config['update_records'] update_records = self.config['update_records']
login = self.config['login_shell'] login = self.config['login_shell']
@ -1275,10 +1282,10 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
self.emit('navigate', 'right') self.emit('navigate', 'right')
def key_split_horiz(self): def key_split_horiz(self):
self.emit('split-horiz') self.emit('split-horiz', self.terminator.pid_cwd(self.pid))
def key_split_vert(self): def key_split_vert(self):
self.emit('split-vert') self.emit('split-vert', self.terminator.pid_cwd(self.pid))
def key_close_term(self): def key_close_term(self):
self.close() self.close()

View File

@ -10,6 +10,7 @@ from config import Config
from keybindings import Keybindings from keybindings import Keybindings
from util import dbg, err from util import dbg, err
from factory import Factory from factory import Factory
from cwd import get_pid_cwd
class Terminator(Borg): class Terminator(Borg):
"""master object for the application""" """master object for the application"""
@ -22,6 +23,7 @@ class Terminator(Borg):
keybindings = None keybindings = None
origcwd = None origcwd = None
pid_cwd = None
doing_layout = None doing_layout = None
@ -52,6 +54,8 @@ class Terminator(Borg):
self.keybindings.configure(self.config['keybindings']) self.keybindings.configure(self.config['keybindings'])
if not self.doing_layout: if not self.doing_layout:
self.doing_layout = False self.doing_layout = False
if not self.pid_cwd:
self.pid_cwd = get_pid_cwd()
def register_window(self, window): def register_window(self, window):
"""Register a new window widget""" """Register a new window widget"""

View File

@ -291,7 +291,7 @@ class Window(Container, gtk.Window):
Container.closeterm(self, widget) Container.closeterm(self, widget)
self.hoover() self.hoover()
def split_axis(self, widget, vertical=True, sibling=None, widgetfirst=True): def split_axis(self, widget, vertical=True, cwd=None, sibling=None, widgetfirst=True):
"""Split the window""" """Split the window"""
order = None order = None
maker = Factory() maker = Factory()
@ -304,6 +304,7 @@ class Window(Container, gtk.Window):
if not sibling: if not sibling:
sibling = maker.make('Terminal') sibling = maker.make('Terminal')
sibling.set_cwd(cwd)
sibling.spawn_child() sibling.spawn_child()
self.add(container) self.add(container)
container.show_all() container.show_all()