1 /* -*- Mode: C; c-basic-offset: 4 -*-
2 * pygobject - Python bindings for GObject
3 * Copyright (C) 2008 Johan Dahlin
5 * goutputstream.override: module overrides for GOutputStream
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
23 override g_output_stream_write kwargs
25 _wrap_g_output_stream_write(PyGObject *self,
29 static char *kwlist[] = { "buffer", "cancellable", NULL };
30 PyGObject *pycancellable = NULL;
33 GCancellable *cancellable;
37 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
38 "s#|O!:OutputStream.write",
39 kwlist, &buffer, &count,
40 &PyGCancellable_Type, &pycancellable))
43 if (!pygio_check_cancellable(pycancellable, &cancellable))
46 pyg_begin_allow_threads;
47 written = g_output_stream_write(G_OUTPUT_STREAM(self->obj),
48 buffer, count, cancellable, &error);
49 pyg_end_allow_threads;
51 if (pyg_error_check(&error))
54 return PyInt_FromLong(written);
57 override g_output_stream_write_all kwargs
59 _wrap_g_output_stream_write_all(PyGObject *self,
63 static char *kwlist[] = { "buffer", "cancellable", NULL };
64 PyGObject *pycancellable = NULL;
67 GCancellable *cancellable;
71 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
72 "s#|O!:OutputStream.write",
73 kwlist, &buffer, &count,
74 &PyGCancellable_Type, &pycancellable))
77 if (!pygio_check_cancellable(pycancellable, &cancellable))
80 pyg_begin_allow_threads;
81 g_output_stream_write_all(G_OUTPUT_STREAM(self->obj),
82 buffer, count, &written, cancellable, &error);
83 pyg_end_allow_threads;
85 if (pyg_error_check(&error))
88 return PyInt_FromLong(written);
91 override g_output_stream_write_async kwargs
93 _wrap_g_output_stream_write_async(PyGObject *self,
97 static char *kwlist[] = { "buffer", "callback", "io_priority", "cancellable",
101 int io_priority = G_PRIORITY_DEFAULT;
102 PyGObject *pycancellable = NULL;
103 GCancellable *cancellable;
106 notify = pygio_notify_new();
108 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
109 "s#O|iOO:OutputStream.write_async",
118 if (!pygio_notify_callback_is_valid(notify))
121 if (!pygio_check_cancellable(pycancellable, &cancellable))
124 pygio_notify_reference_callback(notify);
125 pygio_notify_copy_buffer(notify, buffer, count);
127 g_output_stream_write_async(G_OUTPUT_STREAM(self->obj),
132 (GAsyncReadyCallback)async_result_callback_marshal,
139 pygio_notify_free(notify);
143 override g_output_stream_close_async kwargs
145 _wrap_g_output_stream_close_async(PyGObject *self,
149 static char *kwlist[] = { "callback", "io_priority",
150 "cancellable", "user_data", NULL };
151 int io_priority = G_PRIORITY_DEFAULT;
152 PyGObject *pycancellable = NULL;
153 GCancellable *cancellable;
156 notify = pygio_notify_new();
158 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
159 "O|iOO:OutputStream.close_async",
167 if (!pygio_notify_callback_is_valid(notify))
170 if (!pygio_check_cancellable(pycancellable, &cancellable))
173 pygio_notify_reference_callback(notify);
175 g_output_stream_close_async(G_OUTPUT_STREAM(self->obj),
178 (GAsyncReadyCallback)async_result_callback_marshal,
185 pygio_notify_free(notify);
189 override g_output_stream_flush_async kwargs
191 _wrap_g_output_stream_flush_async(PyGObject *self,
195 static char *kwlist[] = { "callback", "io_priority",
196 "cancellable", "user_data", NULL };
197 int io_priority = G_PRIORITY_DEFAULT;
198 PyGObject *pycancellable = NULL;
199 GCancellable *cancellable;
202 notify = pygio_notify_new();
204 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
205 "O|iOO:OutputStream.flush_async",
213 if (!pygio_notify_callback_is_valid(notify))
216 if (!pygio_check_cancellable(pycancellable, &cancellable))
219 pygio_notify_reference_callback(notify);
221 g_output_stream_flush_async(G_OUTPUT_STREAM(self->obj),
224 (GAsyncReadyCallback)async_result_callback_marshal,
231 pygio_notify_free(notify);
235 override g_output_stream_splice_async kwargs
237 _wrap_g_output_stream_splice_async(PyGObject *self,
241 static char *kwlist[] = { "source", "callback", "flags", "io_priority",
242 "cancellable", "user_data", NULL };
244 int io_priority = G_PRIORITY_DEFAULT;
245 GOutputStreamSpliceFlags flags = G_OUTPUT_STREAM_SPLICE_NONE;
246 PyObject *py_flags = NULL;
248 PyGObject *pycancellable = NULL;
249 GCancellable *cancellable;
252 notify = pygio_notify_new();
254 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
255 "O!O|OiOO:OutputStream.splice_async",
257 &PyGInputStream_Type,
266 if (!pygio_notify_callback_is_valid(notify))
269 if (py_flags && pyg_flags_get_value(G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS,
270 py_flags, (gpointer)&flags))
273 if (!pygio_check_cancellable(pycancellable, &cancellable))
276 pygio_notify_reference_callback(notify);
278 g_output_stream_splice_async(G_OUTPUT_STREAM(self->obj),
279 G_INPUT_STREAM(source->obj), flags, io_priority,
281 (GAsyncReadyCallback)async_result_callback_marshal,
288 pygio_notify_free(notify);
292 /* GOutputStream.write_all: No ArgType for const-void* */