Implement a get_children() method in our Container widgets to override gtk.Container.get_children() with something that guarantees ordering in the returned list

This commit is contained in:
Chris Jones 2010-03-10 22:51:33 +00:00
parent 4cb4a9bc48
commit 8610a845bc
4 changed files with 24 additions and 0 deletions

View File

@ -87,6 +87,10 @@ class Container(object):
"""Ensure we still have a reason to exist"""
raise NotImplementedError('hoover')
def get_children(self):
"""Return an ordered list of the children of this Container"""
raise NotImplementedError('get_children')
def closeterm(self, widget):
"""Handle the closure of a terminal"""
try:

View File

@ -137,6 +137,13 @@ class Notebook(Container, gtk.Notebook):
self.disconnect_child(widget)
return(True)
def get_children(self):
"""Return an ordered list of our children"""
children = []
for page in xrange(0,self.get_n_pages() - 1):
children.append(self.get_nth_page(page))
return(children)
def newtab(self, widget=None):
"""Add a new tab, optionally supplying a child widget"""
maker = Factory()

View File

@ -126,6 +126,13 @@ class Paned(Container):
self.children.remove(widget)
return(True)
def get_children(self):
"""Return an ordered list of our children"""
children = []
children.append(self.get_child1())
children.append(self.get_child2())
return(children)
def wrapcloseterm(self, widget):
"""A child terminal has closed, so this container must die"""
dbg('Paned::wrapcloseterm: Called on %s' % widget)

View File

@ -281,6 +281,12 @@ class Window(Container, gtk.Window):
self.disconnect_child(widget)
return(True)
def get_children(self):
"""Return a single list of our child"""
children = []
children.append(self.get_child())
return(children)
def hoover(self):
"""Ensure we still have a reason to exist"""
if not self.get_child():