[farsight2/master] Port python bindings to new api

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:23:35 PST 2008


---
 python/pyfarsight.defs     |   12 ++-------
 python/pyfarsight.override |   56 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/python/pyfarsight.defs b/python/pyfarsight.defs
index 4a7dca8..bccdc59 100644
--- a/python/pyfarsight.defs
+++ b/python/pyfarsight.defs
@@ -483,22 +483,16 @@
   (return-type "GType")
 )
 
-(define-method add_remote_candidate
+(define-method set_remote_candidates
   (of-object "FsStream")
-  (c-name "fs_stream_add_remote_candidate")
+  (c-name "fs_stream_set_remote_candidates")
   (return-type "gboolean")
   (parameters
-    '("FsCandidate*" "candidate")
+    '("GList*" "candidates")
     '("GError**" "error")
   )
 )
 
-(define-method remote_candidates_added
-  (of-object "FsStream")
-  (c-name "fs_stream_remote_candidates_added")
-  (return-type "none")
-)
-
 (define-method select_candidate_pair
   (of-object "FsStream")
   (c-name "fs_stream_select_candidate_pair")
diff --git a/python/pyfarsight.override b/python/pyfarsight.override
index 536ae1d..ebab5d7 100644
--- a/python/pyfarsight.override
+++ b/python/pyfarsight.override
@@ -657,6 +657,62 @@ _wrap_fs_candidate_tp_getattr(PyObject *self, char *attr)
 #undef CHECK_NULL
 }
 %%
+override fs_stream_set_remote_candidates onearg
+static PyObject *
+_wrap_fs_stream_set_remote_candidates (PyGObject *self, PyObject *arg)
+{
+  gboolean ret = FALSE;
+  GError *error = NULL;
+  GList *candidates = NULL;
+  int i;
+
+  if (!PySequence_Check (arg))
+  {
+    PyErr_SetString (PyExc_TypeError,
+        "The parameter must be a List of FsCandidate");
+    return NULL;
+  }
+
+  if (PySequence_Size (arg) == 0)
+  {
+    PyErr_SetString (PyExc_TypeError,
+        "Empty list invalid");
+    return NULL;
+  }
+
+  for (i = 0; i < PySequence_Size (arg); i++)
+  {
+    PyObject *item = PySequence_GetItem (arg, i);
+
+    if (!pyg_boxed_check (item, FS_TYPE_CANDIDATE))
+    {
+      PyErr_SetString(PyExc_TypeError,
+          "The parameter must be a List of FsCandidate");
+      return NULL;
+    }
+  }
+
+  for (i = 0; i < PySequence_Size (arg); i++)
+  {
+    PyObject *item = PySequence_GetItem (arg, i);
+
+    candidates = g_list_append (candidates, pyg_boxed_get (item, FsCandidate));
+  }
+
+
+  Py_BEGIN_ALLOW_THREADS
+  ret = fs_stream_set_remote_candidates (FS_STREAM(self->obj), candidates,
+      &error);
+  Py_END_ALLOW_THREADS
+
+  g_list_free (candidates);
+
+  if (pyg_error_check(&error))
+    return NULL;
+
+  return PyBool_FromLong (ret);
+}
+%%
 override fs_stream_set_remote_codecs onearg
 static PyObject *
 _wrap_fs_stream_set_remote_codecs (PyGObject *self, PyObject *arg)
-- 
1.5.6.5




More information about the farsight-commits mailing list