[pygobject] Support marshalling GParamSpec signal arguments



commit 0d099bdb3f4bbd962e5e60b583673d9e6f5673cc
Author: Mark Nauwelaerts <mark nauwelaerts collabora co uk>
Date:   Mon Sep 3 16:47:22 2012 +0200

    Support marshalling GParamSpec signal arguments
    
    Fix marshalling GParamSpec arguments from C to Python.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683099
    
    Co-Authored-By: Martin Pitt <martinpitt gnome org>

 gi/pygi-argument.c   |   10 +++++++++-
 tests/test_signal.py |   14 ++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 79a0ec5..38af25b 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1833,6 +1833,11 @@ _pygi_argument_to_object (GIArgument  *arg,
                         break;
                     }
 
+                    if (G_IS_PARAM_SPEC (arg->v_pointer)) {
+                      object = pyg_param_spec_new (arg->v_pointer);
+                      break;
+                    }
+
                     /* since we will unref the object when the
                      * wrapper is destroyed and we don't want
                      * GTK removing the object while the
@@ -2051,7 +2056,10 @@ _pygi_argument_from_g_value(const GValue *value,
                     break;
                 case GI_INFO_TYPE_INTERFACE:
                 case GI_INFO_TYPE_OBJECT:
-                    arg.v_pointer = g_value_get_object (value);
+                    if (G_VALUE_HOLDS_PARAM (value))
+                      arg.v_pointer = g_value_get_param (value);
+                    else
+                      arg.v_pointer = g_value_get_object (value);
                     break;
                 case GI_INFO_TYPE_BOXED:
                 case GI_INFO_TYPE_STRUCT:
diff --git a/tests/test_signal.py b/tests/test_signal.py
index d63d3fc..2002c18 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -362,6 +362,8 @@ class CM(GObject.GObject):
         test_paramspec=(l, GObject.ParamSpec, ()),
     )
 
+    testprop = GObject.Property(type=int)
+
 
 class _TestCMarshaller:
     def setUp(self):
@@ -402,6 +404,18 @@ class _TestCMarshaller:
         self.assertEqual(rv.name, "test-param")
         self.assertEqual(rv.nick, "test")
 
+    def testTestParamSpecArgFromC(self):
+        self.notify_called = False
+
+        def cb_notify(obj, prop):
+            self.notify_called = True
+            self.assertEqual(obj, self.obj)
+            self.assertEqual(prop.name, "testprop")
+
+        self.obj.connect("notify", cb_notify)
+        self.obj.set_property("testprop", 42)
+        self.assertTrue(self.notify_called)
+
 if 'generic-c-marshaller' in GObject.features:
     class TestCMarshaller(_TestCMarshaller, unittest.TestCase):
         pass



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