[pyclutter/wip/introspection] script: Add override for connect_signals()
- From: Bastian Winkler <bwinkler src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pyclutter/wip/introspection] script: Add override for connect_signals()
- Date: Tue, 6 Dec 2011 18:24:38 +0000 (UTC)
commit fb7834089d021308e33e1a2c72c8eb47d5d52c7f
Author: Bastian Winkler <buz netbuz org>
Date: Tue Dec 6 08:58:39 2011 -0600
script: Add override for connect_signals()
introspection/Clutter.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/introspection/Clutter.py b/introspection/Clutter.py
index 7118710..0062b42 100644
--- a/introspection/Clutter.py
+++ b/introspection/Clutter.py
@@ -30,6 +30,14 @@ Clutter = modules['Clutter']._introspection_module
__all__ = []
+if sys.version_info >= (3, 0):
+ _basestring = str
+ _callable = lambda c: hasattr(c, '__call__')
+else:
+ _basestring = basestring
+ _callable = callable
+
+
class Color(Clutter.Color):
def __new__(cls, *args, **kwargs):
return Clutter.Color.__new__(cls)
@@ -837,6 +845,9 @@ __all__.append('BehaviourPath')
class Script(Clutter.Script):
+ def load_from_data(self, data, length=-1):
+ return Clutter.Script.load_from_data(self, data, length)
+
def get_objects(self, *objects):
ret = []
for name in objects:
@@ -844,6 +855,37 @@ class Script(Clutter.Script):
ret.append(obj)
return ret
+ def connect_signals(self, obj_or_map):
+ def _full_callback(builder, gobj, signal_name, handler_name,
+ connect_obj, flags, obj_or_map):
+ handler = None
+ if isinstance(obj_or_map, dict):
+ handler = obj_or_map.get(handler_name, None)
+ else:
+ handler = getattr(obj_or_map, handler_name, None)
+
+ if handler is None:
+ raise AttributeError('Handler %s not found' % handler_name)
+
+ if not _callable(handler):
+ raise TypeError('Handler %s is not a method or function' %
+ handler_name)
+
+ after = flags or GObject.ConnectFlags.AFTER
+ if connect_obj is not None:
+ if after:
+ gobj.connect_object_after(signal_name, handler,
+ connect_obj)
+ else:
+ gobj.connect_object(signal_name, handler, connect_obj)
+ else:
+ if after:
+ gobj.connect_after(signal_name, handler)
+ else:
+ gobj.connect(signal_name, handler)
+
+ self.connect_signals_full(_full_callback, obj_or_map)
+
Script = override(Script)
__all__.append('Script')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]