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
from config import Config
from util import dbg
from util import dbg, err
# pylint: disable-msg=R0921
class Container(object):
@ -39,16 +39,29 @@ class Container(object):
signal['name'], widget))
else:
dbg('Container:: registering signal for %s on %s' % (signal['name'], widget))
gobject.signal_new(signal['name'],
widget,
signal['flags'],
signal['return_type'],
signal['param_types'])
try:
gobject.signal_new(signal['name'],
widget,
signal['flags'],
signal['return_type'],
signal['param_types'])
except RuntimeError:
err('Container:: registering signal for %s on %s failed' %
(signal['name'], widget))
def get_offspring(self):
"""Return a list of child widgets, if any"""
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):
"""Split this container horizontally"""
return(self.split_axis(widget, True))