Apply saved positions to {V,H}Paned widgets. Patch from Glenn Moss. Fixes LP#797953

This commit is contained in:
Chris Jones 2011-08-21 01:25:34 +01:00
parent 845ca998c0
commit fe4f4e0c77

View File

@ -17,6 +17,8 @@ from container import Container
class Paned(Container): class Paned(Container):
"""Base class for Paned Containers""" """Base class for Paned Containers"""
position = None
def __init__(self): def __init__(self):
"""Class initialiser""" """Class initialiser"""
self.terminator = Terminator() self.terminator = Terminator()
@ -30,13 +32,14 @@ class Paned(Container):
# pylint: disable-msg=W0613 # pylint: disable-msg=W0613
def set_initial_position(self, widget, event): def set_initial_position(self, widget, event):
"""Set the initial position of the widget""" """Set the initial position of the widget"""
if isinstance(self, gtk.VPaned): if not self.position:
position = self.allocation.height / 2 if isinstance(self, gtk.VPaned):
else: self.position = self.allocation.height / 2
position = self.allocation.width / 2 else:
self.position = self.allocation.width / 2
dbg("Paned::set_initial_position: Setting position to: %d" % position) dbg("Paned::set_initial_position: Setting position to: %d" % self.position)
self.set_position(position) self.set_position(self.position)
self.cnxids.remove_signal(self, 'expose-event') self.cnxids.remove_signal(self, 'expose-event')
# pylint: disable-msg=W0613 # pylint: disable-msg=W0613
@ -248,9 +251,9 @@ class Paned(Container):
self.get_child1().create_layout(children[keys[0]]) self.get_child1().create_layout(children[keys[0]])
self.get_child2().create_layout(children[keys[1]]) self.get_child2().create_layout(children[keys[1]])
# FIXME: We need a delayed call to set_position, probably on realizing # Store the position for later
# this widget, but it probably needs to start at the deepest widget and if layout['position']:
# work back up. Fun. self.position = int(layout['position'])
def grab_focus(self): def grab_focus(self):
"""We don't want focus, we want a Terminal to have it""" """We don't want focus, we want a Terminal to have it"""