Make tab opening conext menu work

This commit is contained in:
Chris Jones 2009-12-08 13:01:13 +00:00
parent 2db2e0f75e
commit f9725242ec
3 changed files with 22 additions and 6 deletions

View File

@ -6,7 +6,7 @@
from borg import Borg
from config import Config
from keybindings import Keybindings
from util import dbg
from util import dbg, get_top_window
class Terminator(Borg):
"""master object for the application"""
@ -62,6 +62,7 @@ class Terminator(Borg):
self.terminals.append(terminal)
terminal.connect('ungroup-all', self.ungroup_all)
terminal.connect('navigate', self.navigate_terminal)
terminal.connect('tab-new', self.tab_new)
def deregister_terminal(self, terminal):
"""De-register a terminal widget"""
@ -81,6 +82,12 @@ class Terminator(Borg):
for terminal in self.terminals:
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):
"""Nagivate around the terminals"""
current = self.terminals.index(terminal)

View File

@ -162,8 +162,12 @@ class Notebook(Container, gtk.Notebook):
if maker.isinstance(child, 'Terminal'):
child.close()
elif maker.isinstance(child, 'Container'):
#FIXME: Handle this case
dbg('Notebook::closetab: Container children not yet handled')
dialog = self.construct_confirm_close(self.get_window(), _('tab'))
result = dialog.run()
dialog.destroy()
if result is True:
print child.get_children()
else:
err('Notebook::closetab: Unknown child type %s' % child)

View File

@ -116,13 +116,18 @@ class Window(Container, gtk.Window):
self.on_destroy_event(window,
gtk.gdk.Event(gtk.gdk.DESTROY))
elif mapping == 'new_tab':
if not maker.isinstance(self.get_child(), 'Notebook'):
notebook = maker.make('Notebook', self)
self.get_child().newtab()
self.tab_new()
else:
return(False)
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):
"""Handle a window close request"""
maker = Factory()