Windows need to commit suicide when their last terminal exits. Previously there was an assumption of only having one window, so monitoring the global terminal list was acceptable. no more

This commit is contained in:
Chris Jones 2010-01-29 23:37:25 +00:00
parent 4b58b0c738
commit 1236a85370
2 changed files with 17 additions and 2 deletions

View File

@ -58,7 +58,11 @@ class Terminator(Borg):
"""de-register a window widget"""
dbg('Terminator::deregister_window: de-registering %s:%s' %
(id(window), type(window)))
self.windows.remove(window)
if window in self.windows:
self.windows.remove(window)
else:
err('%s is not in registered window list' % window)
if len(self.windows) == 0:
# We have no windows left, we should exit
dbg('no windows remain, quitting')

View File

@ -171,7 +171,10 @@ class Window(Container, gtk.Window):
if maker.isinstance(self.get_child(), 'Terminal'):
dbg('Window::on_delete_event: Only one child, closing is fine')
return(False)
return(self.confirm_close(window, _('window')))
elif maker.isinstance(self.get_child(), 'Container'):
return(self.confirm_close(window, _('window')))
else:
dbg('unknown child: %s' % self.get_child())
def confirm_close(self, window, type):
"""Display a confirmation dialog when the user is closing multiple
@ -183,6 +186,7 @@ class Window(Container, gtk.Window):
def on_destroy_event(self, widget, data=None):
"""Handle window descruction"""
dbg('destroying self')
self.cnxids.remove_all()
self.terminator.deregister_window(self)
self.destroy()
@ -276,6 +280,13 @@ class Window(Container, gtk.Window):
self.disconnect_child(widget)
return(True)
def closeterm(self, widget):
"""Handle a terminal closing"""
Container.closeterm(self, widget)
if len(self.get_children()) == 0:
self.emit('destroy')
def split_axis(self, widget, vertical=True, sibling=None):
"""Split the window"""
maker = Factory()