Improve some error message and switch to using new Container methods for handling child signals.
This commit is contained in:
parent
29d661b26a
commit
0f7a9aa40b
|
@ -16,18 +16,16 @@ from container import Container
|
||||||
# pylint: disable-msg=E1101
|
# pylint: disable-msg=E1101
|
||||||
class Paned(Container):
|
class Paned(Container):
|
||||||
"""Base class for Paned Containers"""
|
"""Base class for Paned Containers"""
|
||||||
cnxids = None
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
self.terminator = Terminator()
|
self.terminator = Terminator()
|
||||||
self.cnxids = {}
|
Container.__init__(self)
|
||||||
self.signals.append({'name': 'resize-term',
|
self.signals.append({'name': 'resize-term',
|
||||||
'flags': gobject.SIGNAL_RUN_LAST,
|
'flags': gobject.SIGNAL_RUN_LAST,
|
||||||
'return_type': gobject.TYPE_NONE,
|
'return_type': gobject.TYPE_NONE,
|
||||||
'param_types': (gobject.TYPE_STRING,)})
|
'param_types': (gobject.TYPE_STRING,)})
|
||||||
|
|
||||||
Container.__init__(self)
|
|
||||||
|
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
def set_initial_position(self, widget, event):
|
def set_initial_position(self, widget, event):
|
||||||
|
@ -75,38 +73,35 @@ class Paned(Container):
|
||||||
self.pack1(widget, True, True)
|
self.pack1(widget, True, True)
|
||||||
self.children.append(widget)
|
self.children.append(widget)
|
||||||
else:
|
else:
|
||||||
raise ValueError('already have two children')
|
raise ValueError('Paned widgets can only have two children')
|
||||||
|
|
||||||
self.cnxids[widget] = []
|
self.cnxids[widget] = []
|
||||||
if isinstance(widget, Terminal):
|
if isinstance(widget, Terminal):
|
||||||
self.cnxids[widget].append(widget.connect('close-term',
|
|
||||||
self.wrapcloseterm))
|
|
||||||
# FIXME: somehow propagate the title-change signal to the Window
|
|
||||||
self.cnxids[widget].append(widget.connect('split-horiz',
|
|
||||||
self.split_horiz))
|
|
||||||
self.cnxids[widget].append(widget.connect('split-vert',
|
|
||||||
self.split_vert))
|
|
||||||
self.cnxids[widget].append(widget.connect('resize-term',
|
|
||||||
self.resizeterm))
|
|
||||||
top_window = self.get_top_window(self)
|
top_window = self.get_top_window(self)
|
||||||
self.cnxids[widget].append(widget.connect('zoom',
|
|
||||||
top_window.terminal_zoom))
|
# FIXME: somehow propagate the title-change signal to the Window
|
||||||
self.cnxids[widget].append(widget.connect('maximise',
|
signals = {'close-term': self.wrapcloseterm,
|
||||||
top_window.terminal_zoom,
|
'split-horiz': self.split_horiz,
|
||||||
False))
|
'split-vert': self.split_vert,
|
||||||
|
'resize-term': self.resizeterm,
|
||||||
|
'zoom': top_window.terminal_zoom}
|
||||||
|
|
||||||
|
for signal in signals:
|
||||||
|
self.connect_child(widget, signal, signals[signal])
|
||||||
|
|
||||||
|
self.connect_child(widget, 'maximise', top_window.terminal_zoom,
|
||||||
|
False)
|
||||||
|
|
||||||
elif isinstance(widget, gtk.Paned):
|
elif isinstance(widget, gtk.Paned):
|
||||||
try:
|
try:
|
||||||
self.cnxids[widget].append(widget.connect('resize-term',
|
self.connect_child(widget, 'resize-term', self.resizeterm)
|
||||||
self.resizeterm))
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
err('Paned::add: %s has no signal resize-term' % widget)
|
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"""
|
||||||
gtk.Paned.remove(self, widget)
|
gtk.Paned.remove(self, widget)
|
||||||
for cnxid in self.cnxids[widget]:
|
self.disconnect_child(widget)
|
||||||
widget.disconnect(cnxid)
|
|
||||||
del(self.cnxids[widget])
|
|
||||||
self.children.remove(widget)
|
self.children.remove(widget)
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue