Make Paned widgets eat themselves when they go from 2 to 1 tabs

This commit is contained in:
Chris Jones 2009-11-25 12:51:14 +00:00
parent 4577c14c6e
commit 05fb49bed6
1 changed files with 15 additions and 5 deletions

View File

@ -47,6 +47,7 @@ class Notebook(Container, gtk.Notebook):
def configure(self): def configure(self):
"""Apply widget-wide settings""" """Apply widget-wide settings"""
# FIXME: Should all of our widgets have this?
#self.connect('page-reordered', self.on_page_reordered) #self.connect('page-reordered', self.on_page_reordered)
self.set_property('homogeneous', not self.config['scroll_tabbar']) self.set_property('homogeneous', not self.config['scroll_tabbar'])
self.set_scrollable(self.config['scroll_tabbar']) self.set_scrollable(self.config['scroll_tabbar'])
@ -95,6 +96,7 @@ class Notebook(Container, gtk.Notebook):
err('Notebook::remove: %s not found in Notebook' % widget) err('Notebook::remove: %s not found in Notebook' % widget)
return(False) return(False)
self.remove_page(page_num) self.remove_page(page_num)
return(True)
def newtab(self, widget=None): def newtab(self, widget=None):
"""Add a new tab, optionally supplying a child widget""" """Add a new tab, optionally supplying a child widget"""
@ -104,10 +106,7 @@ class Notebook(Container, gtk.Notebook):
self.terminator.register_terminal(widget) self.terminator.register_terminal(widget)
widget.spawn_child() widget.spawn_child()
# FIXME: We likely need a wrapcloseterm() to handle signals = {'close-term': self.wrapcloseterm,
# things like removing Notebook when there is only
# one tab left.
signals = {'close-term': self.closeterm,
#'title-change': self.title.set_title, #'title-change': self.title.set_title,
'split-horiz': self.split_horiz, 'split-horiz': self.split_horiz,
'split-vert': self.split_vert, 'split-vert': self.split_vert,
@ -134,6 +133,17 @@ class Notebook(Container, gtk.Notebook):
self.set_current_page(-1) self.set_current_page(-1)
widget.grab_focus() widget.grab_focus()
def wrapcloseterm(self, widget):
"""A child terminal has closed"""
if self.closeterm(widget):
if self.get_n_pages() == 1:
child = self.get_nth_page(0)
self.remove_page(0)
parent = self.get_parent()
parent.remove(self)
parent.add(child)
del(self)
def resizeterm(self, widget, keyname): def resizeterm(self, widget, keyname):
"""Handle a keyboard event requesting a terminal resize""" """Handle a keyboard event requesting a terminal resize"""
raise NotImplementedError('resizeterm') raise NotImplementedError('resizeterm')