fix stupid bug that registered all Paned widgets as HPaned ones. Fix ordering of adding children so things are never de-parented. Hook up terminal zooming signals.

This commit is contained in:
Chris Jones 2009-11-14 18:55:07 +00:00
parent 0190f2dea9
commit 6f93a51b5f
1 changed files with 18 additions and 6 deletions

View File

@ -7,6 +7,7 @@ variants"""
import gobject import gobject
import gtk import gtk
from util import dbg, err
from newterminator import Terminator from newterminator import Terminator
from terminal import Terminal from terminal import Terminal
from container import Container from container import Container
@ -27,8 +28,6 @@ class Paned(Container):
'param_types': (gobject.TYPE_STRING,)}) 'param_types': (gobject.TYPE_STRING,)})
Container.__init__(self) Container.__init__(self)
gobject.type_register(HPaned)
self.register_signals(HPaned)
# pylint: disable-msg=W0613 # pylint: disable-msg=W0613
def set_initial_position(self, widget, event): def set_initial_position(self, widget, event):
@ -38,7 +37,7 @@ class Paned(Container):
else: else:
position = self.allocation.width / 2 position = self.allocation.width / 2
print "Setting position to: %d" % position dbg("Paned::set_initial_position: Setting position to: %d" % position)
self.set_position(position) self.set_position(position)
self.disconnect(self.cnxids['init']) self.disconnect(self.cnxids['init'])
del(self.cnxids['init']) del(self.cnxids['init'])
@ -56,10 +55,12 @@ class Paned(Container):
self.terminator.register_terminal(sibling) self.terminator.register_terminal(sibling)
sibling.spawn_child() sibling.spawn_child()
self.add(container)
self.show_all()
container.add(widget) container.add(widget)
container.add(sibling) container.add(sibling)
self.add(container)
self.show_all() self.show_all()
def add(self, widget): def add(self, widget):
@ -87,9 +88,18 @@ class Paned(Container):
self.split_vert)) self.split_vert))
self.cnxids[widget].append(widget.connect('resize-term', self.cnxids[widget].append(widget.connect('resize-term',
self.resizeterm)) self.resizeterm))
top_window = self.get_top_window(self)
self.cnxids[widget].append(widget.connect('zoom',
top_window.terminal_zoom))
self.cnxids[widget].append(widget.connect('maximise',
top_window.terminal_zoom,
False))
elif isinstance(widget, gtk.Paned): elif isinstance(widget, gtk.Paned):
try:
self.cnxids[widget].append(widget.connect('resize-term', self.cnxids[widget].append(widget.connect('resize-term',
self.resizeterm)) self.resizeterm))
except TypeError:
err('Paned::add: %s has no signal resize-term' % widget)
def remove(self, widget): def remove(self, widget):
"""Remove a widget from the container""" """Remove a widget from the container"""
@ -112,7 +122,7 @@ class Paned(Container):
parent.add(sibling) parent.add(sibling)
del(self) del(self)
else: else:
print "self.closeterm failed" dbg("Paned::wrapcloseterm: self.closeterm failed")
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"""
@ -152,6 +162,7 @@ class HPaned(Paned, gtk.HPaned):
"""Class initialiser""" """Class initialiser"""
Paned.__init__(self) Paned.__init__(self)
gtk.HPaned.__init__(self) gtk.HPaned.__init__(self)
self.register_signals(HPaned)
self.cnxids['init'] = self.connect('expose-event', self.cnxids['init'] = self.connect('expose-event',
self.set_initial_position) self.set_initial_position)
@ -161,6 +172,7 @@ class VPaned(Paned, gtk.VPaned):
"""Class initialiser""" """Class initialiser"""
Paned.__init__(self) Paned.__init__(self)
gtk.VPaned.__init__(self) gtk.VPaned.__init__(self)
self.register_signals(VPaned)
self.cnxids['init'] = self.connect('expose-event', self.cnxids['init'] = self.connect('expose-event',
self.set_initial_position) self.set_initial_position)