make signal registration more robust, and add a function to walk up the widget tree to find the top-level Window object

This commit is contained in:
Chris Jones 2009-11-14 18:54:12 +00:00
parent e5301362e4
commit 0190f2dea9
1 changed files with 19 additions and 6 deletions

View File

@ -6,7 +6,7 @@
import gobject import gobject
from config import Config from config import Config
from util import dbg from util import dbg, err
# pylint: disable-msg=R0921 # pylint: disable-msg=R0921
class Container(object): class Container(object):
@ -39,16 +39,29 @@ class Container(object):
signal['name'], widget)) signal['name'], widget))
else: else:
dbg('Container:: registering signal for %s on %s' % (signal['name'], widget)) dbg('Container:: registering signal for %s on %s' % (signal['name'], widget))
gobject.signal_new(signal['name'], try:
widget, gobject.signal_new(signal['name'],
signal['flags'], widget,
signal['return_type'], signal['flags'],
signal['param_types']) signal['return_type'],
signal['param_types'])
except RuntimeError:
err('Container:: registering signal for %s on %s failed' %
(signal['name'], widget))
def get_offspring(self): def get_offspring(self):
"""Return a list of child widgets, if any""" """Return a list of child widgets, if any"""
return(self.children) return(self.children)
def get_top_window(self, startpoint):
"""Return the Window instance this container belongs to"""
widget = startpoint
parent = widget.get_parent()
while parent:
widget = parent
parent = widget.get_parent()
return(widget)
def split_horiz(self, widget): def split_horiz(self, widget):
"""Split this container horizontally""" """Split this container horizontally"""
return(self.split_axis(widget, True)) return(self.split_axis(widget, True))