start working on a set of methods to walk the widget tree to find the visible ones, and collect their gtk allocation (i.e. where they are and how big they are). This is expected to form the basis of directional navigation and layout display/saving

This commit is contained in:
Chris Jones 2010-01-19 13:06:09 +00:00
parent 5cad06295e
commit ac95dddfbe
3 changed files with 45 additions and 1 deletions

View File

@ -173,4 +173,20 @@ the %s will also close all terminals within it.') % (reqtype, reqtype))
if maker.isinstance(parent, 'Container'):
parent.propagate_title_change(widget, title)
def get_visible_terminals(self):
"""Walk the widget tree to find all of the visible terminals. That is,
any terminals which are not hidden in another Notebook pane"""
maker = Factory()
terminals = {}
for child in self.get_offspring():
if maker.isinstance(child, 'Terminal'):
terminals[child] = child.get_allocation()
elif maker.isinstance(child, 'Container'):
terminals.update(child.get_visible_terminals())
else:
err('Unknown child type %s' % type(child))
return(terminals)
# vim: set expandtab ts=4 sw=4:

View File

@ -123,8 +123,12 @@ class Terminator(Borg):
if next < 0:
next = length - 1
else:
window = get_top_window(terminal)
layout = window.get_visible_terminals()
# FIXME: Do the directional navigation, don't just print the layout
import pprint
pprint.pprint(layout)
raise NotImplementedError
# FIXME: Do the directional navigation
if next is not None:
self.terminals[next].grab_focus()

View File

@ -318,6 +318,30 @@ class Window(Container, gtk.Window):
self.zoom_data = None
self.set_property('term_zoomed', False)
def get_visible_terminals(self):
"""Walk down the widget tree to find all of the visible terminals.
Mostly using Container::get_visible_terminals()"""
maker = Factory()
child = self.get_child()
terminals = {}
# If our child is a Notebook, reset to work from its visible child
if maker.isinstance(child, 'Notebook'):
pagenum = child.get_current_page()
child = child.get_nth_page(pagenum)
if maker.isinstance(child, 'Container'):
terminals.update(child.get_visible_terminals())
elif maker.isnstance(child, 'Terminal'):
# This branch is only possible if we started out as a Notebook. We
# wouldn't have been called if there was really only one Terminal
# child.
terminals[child] = child.get_allocation()
else:
err('Unknown child type %s' % type(child))
return(terminals)
class WindowTitle(object):
"""Class to handle the setting of the window title"""