Make tab opening conext menu work
This commit is contained in:
parent
2db2e0f75e
commit
f9725242ec
|
@ -6,7 +6,7 @@
|
||||||
from borg import Borg
|
from borg import Borg
|
||||||
from config import Config
|
from config import Config
|
||||||
from keybindings import Keybindings
|
from keybindings import Keybindings
|
||||||
from util import dbg
|
from util import dbg, get_top_window
|
||||||
|
|
||||||
class Terminator(Borg):
|
class Terminator(Borg):
|
||||||
"""master object for the application"""
|
"""master object for the application"""
|
||||||
|
@ -62,6 +62,7 @@ class Terminator(Borg):
|
||||||
self.terminals.append(terminal)
|
self.terminals.append(terminal)
|
||||||
terminal.connect('ungroup-all', self.ungroup_all)
|
terminal.connect('ungroup-all', self.ungroup_all)
|
||||||
terminal.connect('navigate', self.navigate_terminal)
|
terminal.connect('navigate', self.navigate_terminal)
|
||||||
|
terminal.connect('tab-new', self.tab_new)
|
||||||
|
|
||||||
def deregister_terminal(self, terminal):
|
def deregister_terminal(self, terminal):
|
||||||
"""De-register a terminal widget"""
|
"""De-register a terminal widget"""
|
||||||
|
@ -81,6 +82,12 @@ class Terminator(Borg):
|
||||||
for terminal in self.terminals:
|
for terminal in self.terminals:
|
||||||
terminal.reconfigure()
|
terminal.reconfigure()
|
||||||
|
|
||||||
|
def tab_new(self, terminal):
|
||||||
|
"""A terminal asked for a new tab. This function is an indirection
|
||||||
|
to the Window object"""
|
||||||
|
window = get_top_window(terminal)
|
||||||
|
window.tab_new()
|
||||||
|
|
||||||
def navigate_terminal(self, terminal, direction):
|
def navigate_terminal(self, terminal, direction):
|
||||||
"""Nagivate around the terminals"""
|
"""Nagivate around the terminals"""
|
||||||
current = self.terminals.index(terminal)
|
current = self.terminals.index(terminal)
|
||||||
|
|
|
@ -162,8 +162,12 @@ class Notebook(Container, gtk.Notebook):
|
||||||
if maker.isinstance(child, 'Terminal'):
|
if maker.isinstance(child, 'Terminal'):
|
||||||
child.close()
|
child.close()
|
||||||
elif maker.isinstance(child, 'Container'):
|
elif maker.isinstance(child, 'Container'):
|
||||||
#FIXME: Handle this case
|
dialog = self.construct_confirm_close(self.get_window(), _('tab'))
|
||||||
dbg('Notebook::closetab: Container children not yet handled')
|
result = dialog.run()
|
||||||
|
dialog.destroy()
|
||||||
|
|
||||||
|
if result is True:
|
||||||
|
print child.get_children()
|
||||||
else:
|
else:
|
||||||
err('Notebook::closetab: Unknown child type %s' % child)
|
err('Notebook::closetab: Unknown child type %s' % child)
|
||||||
|
|
||||||
|
|
|
@ -116,13 +116,18 @@ class Window(Container, gtk.Window):
|
||||||
self.on_destroy_event(window,
|
self.on_destroy_event(window,
|
||||||
gtk.gdk.Event(gtk.gdk.DESTROY))
|
gtk.gdk.Event(gtk.gdk.DESTROY))
|
||||||
elif mapping == 'new_tab':
|
elif mapping == 'new_tab':
|
||||||
if not maker.isinstance(self.get_child(), 'Notebook'):
|
self.tab_new()
|
||||||
notebook = maker.make('Notebook', self)
|
|
||||||
self.get_child().newtab()
|
|
||||||
else:
|
else:
|
||||||
return(False)
|
return(False)
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
|
def tab_new(self):
|
||||||
|
"""Make a new tab"""
|
||||||
|
maker = Factory()
|
||||||
|
if not maker.isinstance(self.get_child(), 'Notebook'):
|
||||||
|
notebook = maker.make('Notebook', self)
|
||||||
|
self.get_child().newtab()
|
||||||
|
|
||||||
def on_delete_event(self, window, event, data=None):
|
def on_delete_event(self, window, event, data=None):
|
||||||
"""Handle a window close request"""
|
"""Handle a window close request"""
|
||||||
maker = Factory()
|
maker = Factory()
|
||||||
|
|
Loading…
Reference in New Issue