From 93e1647681cd69e0b0b702dc0c8779ebc6f2756c Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Wed, 18 Mar 2009 18:33:00 +0000 Subject: Fix a few errors in gtkutils: -import gtk -remove references to Tutorial --- (limited to 'src/sugar/tutorius/gtkutils.py') diff --git a/src/sugar/tutorius/gtkutils.py b/src/sugar/tutorius/gtkutils.py index 7196469..6841299 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 @@ -104,7 +105,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 +115,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 +123,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 +147,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) )) \ -- cgit v0.9.1