Add support for preserving cwd across tab creation events. Fixes a regression reported by jkaker
This commit is contained in:
parent
c8e654d0a8
commit
364a833324
|
@ -148,13 +148,15 @@ class Notebook(Container, gtk.Notebook):
|
|||
children.append(self.get_nth_page(page))
|
||||
return(children)
|
||||
|
||||
def newtab(self, debugtab=False, widget=None):
|
||||
def newtab(self, debugtab=False, widget=None, cwd=None):
|
||||
"""Add a new tab, optionally supplying a child widget"""
|
||||
maker = Factory()
|
||||
top_window = get_top_window(self)
|
||||
|
||||
if not widget:
|
||||
widget = maker.make('Terminal')
|
||||
if cwd:
|
||||
widget.set_cwd(cwd)
|
||||
widget.spawn_child(debugserver=debugtab)
|
||||
|
||||
signals = {'close-term': self.wrapcloseterm,
|
||||
|
@ -168,12 +170,17 @@ class Notebook(Container, gtk.Notebook):
|
|||
'group-tab': top_window.group_tab,
|
||||
'ungroup-tab': top_window.ungroup_tab,
|
||||
'move-tab': top_window.move_tab,
|
||||
'tab-new': top_window.tab_new,
|
||||
'tab-new': [top_window.tab_new, widget],
|
||||
'navigate': top_window.navigate_terminal}
|
||||
|
||||
if maker.isinstance(widget, 'Terminal'):
|
||||
for signal in signals:
|
||||
self.connect_child(widget, signal, signals[signal])
|
||||
args = []
|
||||
handler = signals[signal]
|
||||
if isinstance(handler, list):
|
||||
args = handler[1:]
|
||||
handler = handler[0]
|
||||
self.connect_child(widget, signal, handler, *args)
|
||||
|
||||
self.set_tab_reorderable(widget, True)
|
||||
label = TabLabel(self.window.get_title(), self)
|
||||
|
|
|
@ -100,7 +100,7 @@ class Paned(Container):
|
|||
'ungroup-tab': top_window.ungroup_tab,
|
||||
'move-tab': top_window.move_tab,
|
||||
'maximise': [top_window.zoom, False],
|
||||
'tab-new': top_window.tab_new,
|
||||
'tab-new': [top_window.tab_new, widget],
|
||||
'navigate': top_window.navigate_terminal}
|
||||
|
||||
for signal in signals:
|
||||
|
|
|
@ -52,7 +52,7 @@ class Terminal(gtk.VBox):
|
|||
'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
(gobject.TYPE_STRING,)),
|
||||
'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
(gobject.TYPE_BOOLEAN,)),
|
||||
(gobject.TYPE_BOOLEAN, gobject.TYPE_OBJECT)),
|
||||
'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||
'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||
'zoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||
|
@ -168,6 +168,10 @@ class Terminal(gtk.VBox):
|
|||
"""Return our profile name"""
|
||||
return(self.config.profile)
|
||||
|
||||
def get_cwd(self):
|
||||
"""Return our cwd"""
|
||||
return(self.terminator.pid_cwd(self.pid))
|
||||
|
||||
def close(self):
|
||||
"""Close ourselves"""
|
||||
dbg('Terminal::close: emitting close-term')
|
||||
|
|
|
@ -100,13 +100,14 @@ class TerminalPopupMenu(object):
|
|||
menu.append(item)
|
||||
|
||||
item = gtk.MenuItem(_('Open _Tab'))
|
||||
item.connect('activate', lambda x: terminal.emit('tab-new', False))
|
||||
item.connect('activate', lambda x: terminal.emit('tab-new', False,
|
||||
terminal))
|
||||
menu.append(item)
|
||||
|
||||
if self.terminator.debug_address or True:
|
||||
if self.terminator.debug_address is not None:
|
||||
item = gtk.MenuItem(_('Open _Debug Tab'))
|
||||
item.connect('activate', lambda x:
|
||||
terminal.emit('tab-new', True))
|
||||
terminal.emit('tab-new', True, terminal))
|
||||
menu.append(item)
|
||||
|
||||
menu.append(gtk.MenuItem())
|
||||
|
|
|
@ -324,6 +324,13 @@ class Terminator(Borg):
|
|||
else:
|
||||
return([widget])
|
||||
|
||||
def get_focussed_terminal(self):
|
||||
"""iterate over all the terminals to find which, if any, has focus"""
|
||||
for terminal in self.terminals:
|
||||
if terminal.has_focus():
|
||||
return(terminal)
|
||||
return(None)
|
||||
|
||||
def focus_changed(self, widget):
|
||||
"""We just moved focus to a new terminal"""
|
||||
for terminal in self.terminals:
|
||||
|
|
|
@ -149,7 +149,7 @@ class Window(Container, gtk.Window):
|
|||
self.on_destroy_event(window,
|
||||
gtk.gdk.Event(gtk.gdk.DESTROY))
|
||||
elif mapping == 'new_tab':
|
||||
self.tab_new()
|
||||
self.tab_new(self.get_focussed_terminal())
|
||||
else:
|
||||
return(False)
|
||||
return(True)
|
||||
|
@ -159,12 +159,16 @@ class Window(Container, gtk.Window):
|
|||
maker = Factory()
|
||||
return(maker.isinstance(self.get_child(), 'Notebook'))
|
||||
|
||||
def tab_new(self, widget=None, debugtab=False):
|
||||
def tab_new(self, widget=None, debugtab=False, _param1=None, _param2=None):
|
||||
"""Make a new tab"""
|
||||
cwd = None
|
||||
|
||||
if widget:
|
||||
cwd = widget.get_cwd()
|
||||
maker = Factory()
|
||||
if not self.is_child_notebook():
|
||||
notebook = maker.make('Notebook', window=self)
|
||||
self.get_child().newtab(debugtab)
|
||||
self.get_child().newtab(debugtab, cwd=cwd)
|
||||
|
||||
def on_delete_event(self, window, event, data=None):
|
||||
"""Handle a window close request"""
|
||||
|
@ -267,11 +271,16 @@ class Window(Container, gtk.Window):
|
|||
'group-tab': self.group_tab,
|
||||
'ungroup-tab': self.ungroup_tab,
|
||||
'move-tab': self.move_tab,
|
||||
'tab-new': self.tab_new,
|
||||
'tab-new': [self.tab_new, widget],
|
||||
'navigate': self.navigate_terminal}
|
||||
|
||||
for signal in signals:
|
||||
self.connect_child(widget, signal, signals[signal])
|
||||
args = []
|
||||
handler = signals[signal]
|
||||
if isinstance(handler, list):
|
||||
args = handler[1:]
|
||||
handler = handler[0]
|
||||
self.connect_child(widget, signal, handler, *args)
|
||||
|
||||
widget.grab_focus()
|
||||
|
||||
|
@ -387,6 +396,14 @@ class Window(Container, gtk.Window):
|
|||
|
||||
return(terminals)
|
||||
|
||||
def get_focussed_terminal(self):
|
||||
"""Find which terminal we want to have focus"""
|
||||
terminals = self.get_visible_terminals()
|
||||
for terminal in terminals:
|
||||
if terminal.vte.is_focus():
|
||||
return(terminal)
|
||||
return(None)
|
||||
|
||||
def set_rough_geometry_hints(self):
|
||||
"""Walk all the terminals along the top and left edges to fake up how
|
||||
many columns/rows we sort of have"""
|
||||
|
|
Loading…
Reference in New Issue