diff options
author | Johan Dahlin <johan@gnome.org> | 2008-01-20 15:29:23 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-01-20 15:29:23 +0000 |
commit | 702ed9b73e4f596aadf86cdfbf3655cee97b4cb6 (patch) | |
tree | ac70db328b47db266c01f4e9488d6dae4d00b2b8 /gio/gio.override | |
parent | 5df2f97e4db1dfefc1ff933758e9b580d796c53c (diff) | |
download | pygobject-702ed9b73e4f596aadf86cdfbf3655cee97b4cb6.tar.gz pygobject-702ed9b73e4f596aadf86cdfbf3655cee97b4cb6.tar.xz pygobject-702ed9b73e4f596aadf86cdfbf3655cee97b4cb6.zip |
Split out overrides into more files. Fix up module description in comment
2008-01-20 Johan Dahlin <johan@gnome.org>
* gio/Makefile.am:
* gio/ginputstream.override:
* gio/gio.override:
* gio/giomodule.c:
* gio/goutputstream.override:
* gio/gvolumemonitor.override:
* gio/unix.override:
* gio/unixmodule.c:
Split out overrides into more files. Fix up module description in
comment
svn path=/trunk/; revision=741
Diffstat (limited to 'gio/gio.override')
-rw-r--r-- | gio/gio.override | 268 |
1 files changed, 29 insertions, 239 deletions
diff --git a/gio/gio.override b/gio/gio.override index 904791b..8e6f167 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -1,4 +1,28 @@ -/* -*- Mode: C; c-basic-offset: 4 -*- */ +/* -*- Mode: C; c-basic-offset: 4 -*- + * pygtk- Python bindings for the GTK toolkit. + * Copyright (C) 2008 Johan Dahlin + * + * giomodule.c: module wrapping the GIO library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ +%% +modulename gio +%% +import gobject.GObject as PyGObject_Type %% headers #define NO_IMPORT_PYGOBJECT @@ -60,79 +84,16 @@ async_result_callback_marshal(GObject *source_object, pyg_gil_state_release(state); } - -%% -modulename gio %% -import gobject.GObject as PyGObject_Type +include + ginputstream.override + goutputstream.override + gvolumemonitor.override %% ignore-glob *_get_type *free %% -override g_volume_monitor_get_connected_drives noargs -static PyObject * -_wrap_g_volume_monitor_get_connected_drives (PyGObject *self) -{ - GList *list, *l; - PyObject *ret; - - list = g_volume_monitor_get_connected_drives (G_VOLUME_MONITOR (self->obj)); - - ret = PyList_New(0); - for (l = list; l; l = l->next) { - GDrive *drive = l->data; - PyObject *item = pygobject_new((GObject *)drive); - PyList_Append(ret, item); - Py_DECREF(item); - } - g_list_free(list); - - return ret; -} -%% -override g_volume_monitor_get_volumes noargs -static PyObject * -_wrap_g_volume_monitor_get_volumes (PyGObject *self) -{ - GList *list, *l; - PyObject *ret; - - list = g_volume_monitor_get_volumes (G_VOLUME_MONITOR (self->obj)); - - ret = PyList_New(0); - for (l = list; l; l = l->next) { - GVolume *volume = l->data; - PyObject *item = pygobject_new((GObject *)volume); - PyList_Append(ret, item); - Py_DECREF(item); - } - g_list_free(list); - - return ret; -} -%% -override g_volume_monitor_get_mounts noargs -static PyObject * -_wrap_g_volume_monitor_get_mounts (PyGObject *self) -{ - GList *list, *l; - PyObject *ret; - - list = g_volume_monitor_get_mounts (G_VOLUME_MONITOR (self->obj)); - - ret = PyList_New(0); - for (l = list; l; l = l->next) { - GMount *mount = l->data; - PyObject *item = pygobject_new((GObject *)mount); - PyList_Append(ret, item); - Py_DECREF(item); - } - g_list_free(list); - - return ret; -} -%% override g_drive_get_volumes noargs static PyObject * _wrap_g_drive_get_volumes (PyGObject *self) @@ -200,177 +161,6 @@ _wrap_g_app_info_get_all_for_type (PyGObject *self, PyObject *args) return ret; } %% -override g_input_stream_read kwargs -static PyObject * -_wrap_g_input_stream_read(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "count", "cancellable", NULL }; - PyGObject *pycancellable = NULL; - PyObject *v; - - GCancellable *cancellable; - long count = -1; - GError *error = NULL; - size_t bytesread, buffersize, chunksize; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|iO!:InputStream.read", - kwlist, &count, - &PyGCancellable_Type, &pycancellable)) - return NULL; - - buffersize = BUFSIZE; - - cancellable = pycancellable ? G_CANCELLABLE(pycancellable->obj) : NULL; - - v = PyString_FromStringAndSize((char *)NULL, buffersize); - if (v == NULL) - return NULL; - - bytesread = 0; - for (;;) - { - pyg_begin_allow_threads; - errno = 0; - chunksize = g_input_stream_read(G_INPUT_STREAM(self->obj), - PyString_AS_STRING((PyStringObject *)v) + bytesread, - buffersize - bytesread, cancellable, - &error); - pyg_end_allow_threads; - - if (pyg_error_check(&error)) - { - Py_DECREF(v); - return NULL; - } - else if (chunksize == 0) - { - PyErr_SetFromErrno(PyExc_IOError); - Py_DECREF(v); - return NULL; - } - - bytesread += chunksize; - if (bytesread < buffersize) - break; - - if (count < 0) - { - buffersize += BUFSIZE; - if (_PyString_Resize(&v, buffersize) < 0) - return NULL; - } - else - /* Got what was requested. */ - break; - } - - if (bytesread != buffersize) - _PyString_Resize(&v, bytesread); - - return v; -} -%% -override g_input_stream_read_async kwargs -static PyObject * -_wrap_g_input_stream_read_async(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "count", "io_priority", "cancellable", "callback", - "user_data", NULL }; - long count = -1; - int io_priority = G_PRIORITY_DEFAULT; - PyGObject *pycancellable; - GCancellable *cancellable; - PyGAsyncRequestNotify *notify; - - notify = g_slice_new0(PyGAsyncRequestNotify); - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "iiOO|O:InputStream.read_async", - kwlist, &count, - &io_priority, - &pycancellable, - ¬ify->callback, - ¬ify->data)) - { - g_slice_free(PyGAsyncRequestNotify, notify); - return NULL; - } - - if ((PyObject*)pycancellable == Py_None) - cancellable = NULL; - else if (pygobject_check(pycancellable, &PyGCancellable_Type)) - cancellable = G_CANCELLABLE(pycancellable->obj); - else - { - PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable"); - return NULL; - } - - if (!PyCallable_Check(notify->callback)) - { - PyErr_SetString(PyExc_TypeError, "callback argument not callable"); - g_slice_free(PyGAsyncRequestNotify, notify); - return NULL; - } - Py_INCREF(notify->callback); - Py_XINCREF(notify->data); - - notify->buffer = PyString_FromStringAndSize((char *)NULL, count); - if (notify->buffer == NULL) - return NULL; - - g_input_stream_read_async(G_INPUT_STREAM(self->obj), - PyString_AS_STRING((PyStringObject *)notify->buffer), - count, - io_priority, - cancellable, - (GAsyncReadyCallback)async_result_callback_marshal, - notify); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override g_output_stream_write kwargs -static PyObject * -_wrap_g_output_stream_write(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "buffer", "cancellable", NULL }; - PyGObject *pycancellable = NULL; - gchar *buffer; - long count = 0; - GCancellable *cancellable; - GError *error = NULL; - gssize written; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "s#|O!:OutputStream.write", - kwlist, &buffer, &count, - &PyGCancellable_Type, &pycancellable)) - return NULL; - - if (!pycancellable) - cancellable = NULL; - else if (pygobject_check(pycancellable, &PyGCancellable_Type)) - cancellable = G_CANCELLABLE(pycancellable->obj); - else - { - PyErr_SetString(PyExc_TypeError, "cancellable should be a gio.Cancellable"); - return NULL; - } - - pyg_begin_allow_threads; - written = g_output_stream_write(G_OUTPUT_STREAM(self->obj), - buffer, count, cancellable, &error); - pyg_end_allow_threads; - - if (pyg_error_check(&error)) - return NULL; - - return PyInt_FromLong(written); -} -%% define GSimpleAsyncResult.get_buffer noargs static PyObject * _wrap_g_simple_async_result_get_buffer(PyGObject *self) |