[gobject-introspection] Make sure signal works when there isn't one specified



commit a8b700e2d9c7b63bd351f4194820680f4da3da8a
Author: Johan Dahlin <jdahlin litl com>
Date:   Sat Aug 13 12:45:12 2011 -0300

    Make sure signal works when there isn't one specified

 giscanner/ast.py         |    2 +-
 giscanner/gdumpparser.py |    2 +-
 giscanner/girparser.py   |    2 +-
 giscanner/girwriter.py   |    5 +++--
 4 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 2b1c6f5..d63fdb8 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -874,7 +874,7 @@ class Boxed(Node, Registered):
 
 class Signal(Callable):
 
-    def __init__(self, name, retval, parameters, when="first",
+    def __init__(self, name, retval, parameters, when=None,
                  no_recurse=False, detailed=False, action=False,
                  no_hooks=False):
         Callable.__init__(self, name, retval, parameters, False)
diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py
index be25d61..f94917e 100644
--- a/giscanner/gdumpparser.py
+++ b/giscanner/gdumpparser.py
@@ -453,7 +453,7 @@ different --identifier-prefix.""" % (xmlnode.attrib['name'], self._namespace.ide
             rtype = ast.Type.create_from_gtype_name(rctype)
             return_ = ast.Return(rtype)
             parameters = []
-            when = signal_info.attrib['when']
+            when = signal_info.attrib.get('when')
             no_recurse = signal_info.attrib.get('no-recurse', '0') == '1'
             detailed = signal_info.attrib.get('detailed', '0') == '1'
             action = signal_info.attrib.get('action', '0') == '1'
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 5e1866d..d7a59b8 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -300,7 +300,7 @@ class GIRParser(object):
             func = klass(name, retval, parameters, throws)
         elif klass is ast.Signal:
             func = klass(name, retval, parameters,
-                         when=node.attrib.get('when', 'first'),
+                         when=node.attrib.get('when'),
                          no_recurse=node.attrib.get('no-recurse', '0') == '1',
                          detailed=node.attrib.get('detailed', '0') == '1',
                          action=node.attrib.get('action', '0') == '1',
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 591c7ae..f993729 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -554,8 +554,9 @@ and/or use gtk-doc annotations. ''')
                 self._write_type(field.type)
 
     def _write_signal(self, signal):
-        attrs = [('name', signal.name),
-                 ('when', signal.when)]
+        attrs = [('name', signal.name)]
+        if signal.when:
+            attrs.append(('when', signal.when))
         if signal.no_recurse:
             attrs.append(('no-recurse', '1'))
         if signal.detailed:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]