Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/gtkutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar/tutorius/gtkutils.py')
-rw-r--r--src/sugar/tutorius/gtkutils.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/sugar/tutorius/gtkutils.py b/src/sugar/tutorius/gtkutils.py
index 7196469..efa6eef 100644
--- a/src/sugar/tutorius/gtkutils.py
+++ b/src/sugar/tutorius/gtkutils.py
@@ -17,6 +17,7 @@
"""
Utility classes and functions that are gtk related
"""
+import gtk
def find_widget(base, target_fqdn):
"""Find a widget by digging into a parent widget's children tree
@@ -39,7 +40,10 @@ def find_widget(base, target_fqdn):
path.pop(0)
while len(path) > 0:
- obj = obj.get_children()[int(path.pop(0))]
+ try:
+ obj = obj.get_children()[int(path.pop(0))]
+ except:
+ break
return obj
@@ -104,7 +108,7 @@ def register_signals_numbered(target, handler, prefix="0", max_depth=None):
ret+=register_signals_numbered(child, handler, pre, dep)
#register events on the target if a widget XXX necessary to check this?
if isinstance(target, gtk.Widget):
- for sig in Tutorial.EVENTS:
+ for sig in EVENTS:
try:
ret.append( \
(target, target.connect(sig, handler, (sig, prefix) ))\
@@ -114,7 +118,7 @@ def register_signals_numbered(target, handler, prefix="0", max_depth=None):
return ret
-def register_signals(self, target, handler, prefix=None, max_depth=None):
+def register_signals(target, handler, prefix=None, max_depth=None):
"""
Recursive function to register event handlers on an target
and it's children. The event handler is called with an extra
@@ -122,19 +126,20 @@ def register_signals(self, target, handler, prefix=None, max_depth=None):
the FQDN-style name of the target that triggered the event.
This function registers all of the events listed in
- Tutorial.EVENTS and omits widgets with a name matching
- Tutorial.IGNORED_WIDGETS from the name hierarchy.
+ EVENTS and omits widgets with a name matching
+ IGNORED_WIDGETS from the name hierarchy.
Example arg tuple added:
("focus", "Activity.Toolbox.Bold")
Side effects:
-Handlers connected on the various targets
- -Handler ID's stored in self.handlers
@param target the target to recurse on
@param handler the handler function to connect
@param prefix name prepended to the target name to form a chain
@param max_depth maximum recursion depth, None for infinity
+
+ @returns list of (object, handler_id)
"""
ret = []
#Gtk Containers have a get_children() function
@@ -145,16 +150,16 @@ def register_signals(self, target, handler, prefix=None, max_depth=None):
#Recurse with a prefix on all children
pre = ".".join( \
[p for p in (prefix, target.get_name()) \
- if not (p is None or p in Tutorial.IGNORED_WIDGETS)] \
+ if not (p is None or p in IGNORED_WIDGETS)] \
)
ret += register_signals(child, handler, pre, max_depth-1)
name = ".".join( \
[p for p in (prefix, target.get_name()) \
- if not (p is None or p in Tutorial.IGNORED_WIDGETS)] \
+ if not (p is None or p in IGNORED_WIDGETS)] \
)
#register events on the target if a widget XXX necessary to check this?
if isinstance(target, gtk.Widget):
- for sig in Tutorial.EVENTS:
+ for sig in EVENTS:
try:
ret.append( \
(target, target.connect(sig, handler, (sig, name) )) \