Previous split_axis() changes were insufficient. Apply the changes across all of the Containers and improve the implementation generally

This commit is contained in:
Chris Jones 2010-02-27 13:30:38 +01:00
parent 94a568ee1c
commit 9b6cdcd4ac
4 changed files with 21 additions and 15 deletions

View File

@ -71,7 +71,7 @@ class Container(object):
"""Split this container vertically"""
return(self.split_axis(widget, False))
def split_axis(self, widget, vertical=True, sibling=None):
def split_axis(self, widget, vertical=True, sibling=None, siblinglast=None):
"""Default axis splitter. This should be implemented by subclasses"""
raise NotImplementedError('split_axis')

View File

@ -52,8 +52,9 @@ class Notebook(Container, gtk.Notebook):
self.set_tab_pos(pos)
self.set_show_tabs(not self.config['hide_tabbar'])
def split_axis(self, widget, vertical=True, sibling=None):
def split_axis(self, widget, vertical=True, sibling=None, siblinglast=False):
"""Split the axis of a terminal inside us"""
order = None
page_num = self.page_num(widget)
if page_num == -1:
err('Notebook::split_axis: %s not found in Notebook' % widget)
@ -76,8 +77,12 @@ class Notebook(Container, gtk.Notebook):
self.set_tab_label(container, label)
self.show_all()
container.add(widget)
container.add(sibling)
order = [widget, sibling]
if siblinglast is True:
order.reverse
for terminal in order:
container.add(terminal)
self.set_current_page(page_num)
self.show_all()

View File

@ -43,8 +43,7 @@ class Paned(Container):
def split_axis(self, widget, vertical=True, sibling=None,
siblinglast=False):
"""Default axis splitter. This should be implemented by subclasses"""
first = None
second = None
order = None
maker = Factory()
@ -61,15 +60,12 @@ class Paned(Container):
self.add(container)
self.show_all()
order = [widget, sibling]
if siblinglast is True:
first = widget
second = sibling
else:
first = sibling
second = widget
order.reverse()
container.add(first)
container.add(second)
for terminal in order:
container.add(terminal)
self.show_all()

View File

@ -288,8 +288,9 @@ class Window(Container, gtk.Window):
if len(self.get_children()) == 0:
self.emit('destroy')
def split_axis(self, widget, vertical=True, sibling=None):
def split_axis(self, widget, vertical=True, sibling=None, siblinglast=False):
"""Split the window"""
order = None
maker = Factory()
self.remove(widget)
@ -304,7 +305,11 @@ class Window(Container, gtk.Window):
self.add(container)
container.show_all()
for term in [widget, sibling]:
order = [widget, sibling]
if siblinglast is True:
order.reverse()
for term in order:
container.add(term)
container.show_all()