summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGian Mario Tagliaretti <gianmt@gnome.org>2009-05-24 11:44:24 +0200
committerGian Mario Tagliaretti <gianmt@gnome.org>2009-05-24 11:44:24 +0200
commit59da8cd24ea390b6c983995833ec6b0e5d028b35 (patch)
tree045e523e532e7c3fc7c6aef0610cefee7af2b100
parent84ab6178ed0033f69932df5bc73c86bdff80c953 (diff)
downloadpygobject-59da8cd24ea390b6c983995833ec6b0e5d028b35.tar.gz
pygobject-59da8cd24ea390b6c983995833ec6b0e5d028b35.tar.xz
pygobject-59da8cd24ea390b6c983995833ec6b0e5d028b35.zip
Wrap gio.OutputStream.flush_async()
wrap gio.OutputStream.flush_async() and add a test.
-rw-r--r--gio/goutputstream.override47
-rw-r--r--tests/test_gio.py11
2 files changed, 57 insertions, 1 deletions
diff --git a/gio/goutputstream.override b/gio/goutputstream.override
index 9e2f8c4..e51c6b2 100644
--- a/gio/goutputstream.override
+++ b/gio/goutputstream.override
@@ -209,7 +209,52 @@ _wrap_g_memory_output_stream_get_data(PyGObject *self)
return PyString_FromStringAndSize(g_memory_output_stream_get_data(stream),
g_seekable_tell(G_SEEKABLE(stream)));
}
+%%
+override g_output_stream_flush_async kwargs
+static PyObject *
+_wrap_g_output_stream_flush_async(PyGObject *self,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "callback", "io_priority",
+ "cancellable", "user_data", NULL };
+ int io_priority = G_PRIORITY_DEFAULT;
+ PyGObject *pycancellable = NULL;
+ GCancellable *cancellable;
+ PyGIONotify *notify;
+
+ notify = pygio_notify_new();
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O|iOO:OutputStream.flush_async",
+ kwlist,
+ &notify->callback,
+ &io_priority,
+ &pycancellable,
+ &notify->data))
+ goto error;
+
+ if (!pygio_notify_callback_is_valid(notify))
+ goto error;
+
+ if (!pygio_check_cancellable(pycancellable, &cancellable))
+ goto error;
+
+ pygio_notify_reference_callback(notify);
+
+ g_output_stream_flush_async(G_OUTPUT_STREAM(self->obj),
+ io_priority,
+ cancellable,
+ (GAsyncReadyCallback)async_result_callback_marshal,
+ notify);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+
+ error:
+ pygio_notify_free(notify);
+ return NULL;
+}
/* GOutputStream.write_all: No ArgType for const-void* */
/* GOutputStream.splice_async: No ArgType for GAsyncReadyCallback */
-/* GOutputStream.flush_async: No ArgType for GAsyncReadyCallback */
diff --git a/tests/test_gio.py b/tests/test_gio.py
index d36c213..cf82658 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -804,7 +804,18 @@ class TestOutputStream(unittest.TestCase):
loop = glib.MainLoop()
loop.run()
+
+ def testFlushAsync(self):
+ def callback(stream, result):
+ try:
+ self.failUnless(stream.flush_finish(result))
+ finally:
+ loop.quit()
+
+ self.stream.flush_async(callback)
+ loop = glib.MainLoop()
+ loop.run()
class TestMemoryOutputStream(unittest.TestCase):
def setUp(self):