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:
parent
e5301362e4
commit
0190f2dea9
|
@ -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))
|
||||||
|
try:
|
||||||
gobject.signal_new(signal['name'],
|
gobject.signal_new(signal['name'],
|
||||||
widget,
|
widget,
|
||||||
signal['flags'],
|
signal['flags'],
|
||||||
signal['return_type'],
|
signal['return_type'],
|
||||||
signal['param_types'])
|
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))
|
||||||
|
|
Loading…
Reference in New Issue