diff options
author | Paul Pogonyshev <pogonyshev@gmx.net> | 2008-08-12 21:11:07 +0000 |
---|---|---|
committer | Paul Pogonyshev <paulp@src.gnome.org> | 2008-08-12 21:11:07 +0000 |
commit | 4991c857b02660f070a9819a82e8d90f5ae0ed91 (patch) | |
tree | 1626e20bf23e74c0d9b07346656656fb91b8668d | |
parent | bb8fa613012bfa6337e1ae1bb6eb0bbfa00e397c (diff) | |
download | pygobject-4991c857b02660f070a9819a82e8d90f5ae0ed91.tar.gz pygobject-4991c857b02660f070a9819a82e8d90f5ae0ed91.tar.xz pygobject-4991c857b02660f070a9819a82e8d90f5ae0ed91.zip |
Bug 547495 – wrap four important asynchronous methods in gio.Drive and
2008-08-13 Paul Pogonyshev <pogonyshev@gmx.net>
Bug 547495 – wrap four important asynchronous methods in gio.Drive
and gio.Mount
* gio/gio.defs (gio.Drive.eject, gio.Drive.poll_for_media)
(gio.Mount.remount): Document.
* gio/gio.override (_wrap_g_drive_eject)
(_wrap_g_drive_poll_for_media, _wrap_g_mount_eject)
(_wrap_g_mount_remount): New functions.
svn path=/trunk/; revision=948
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | gio/gio.defs | 16 | ||||
-rw-r--r-- | gio/gio.override | 222 |
3 files changed, 252 insertions, 1 deletions
@@ -1,10 +1,23 @@ +2008-08-13 Paul Pogonyshev <pogonyshev@gmx.net> + + Bug 547495 – wrap four important asynchronous methods in gio.Drive + and gio.Mount + + * gio/gio.defs (gio.Drive.eject, gio.Drive.poll_for_media) + (gio.Mount.remount): Document. + + * gio/gio.override (_wrap_g_drive_eject) + (_wrap_g_drive_poll_for_media, _wrap_g_mount_eject) + (_wrap_g_mount_remount): New functions. + 2008-08-12 Paul Pogonyshev <pogonyshev@gmx.net> Bug 547484 – wrap gio.DataInputStream.read_line and ...read_until * tests/test_gio.py (TestDataInputStream): New test case. - * gio/gio.defs (read_line, read_until): Document. + * gio/gio.defs (gio.DataInputStream.read_line) + (gio.DataInputStream.read_until): Document. * gio/ginputstream.override (_wrap_g_data_input_stream_read_line) (_wrap_g_data_input_stream_read_until): New functions. diff --git a/gio/gio.defs b/gio/gio.defs index 1d7cde0..9ca1397 100644 --- a/gio/gio.defs +++ b/gio/gio.defs @@ -932,6 +932,11 @@ (define-method eject (of-object "GDrive") + (docstring + "D.eject(callback, [flags, [cancellable, [user_data]]]) -> start ejecting\n" + "Asynchronously ejects a drive. When the operation is finished, callback\n" + "will be called. You can then call gio.Drive.eject_finish to obtain the\n" + "result of the operation.") (c-name "g_drive_eject") (return-type "none") (parameters @@ -954,6 +959,12 @@ (define-method poll_for_media (of-object "GDrive") + (docstring + "D.poll_for_media(callback, [cancellable, [user_data]]) -> start polling\n" + "Asynchronously polls drive to see if media has been inserted or removed.\n" + "When the operation is finished, callback will be called. You can then\n" + "call gio.Drive.poll_for_media_finish to obtain the result of the\n" + "operation.") (c-name "g_drive_poll_for_media") (return-type "none") (parameters @@ -3808,6 +3819,11 @@ (define-method remount (of-object "GMount") + (docstring + "M.remount(callback, [flags, [mount_operation, [cancellable, [user_data]]]])\n" + "Remounts a mount. This is an asynchronous operation, and is finished by\n" + "calling gio.Mount.remount_finish with the mount and gio.AsyncResults data\n" + "returned in the callback.") (c-name "g_mount_remount") (return-type "none") (parameters diff --git a/gio/gio.override b/gio/gio.override index 9ea02f4..86009cb 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -140,6 +140,104 @@ _wrap_g_drive_get_volumes (PyGObject *self) return ret; } %% +override g_drive_eject kwargs +static PyObject * +_wrap_g_drive_eject(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "flags", "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyObject *py_flags = NULL; + GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE; + PyGObject *py_cancellable = NULL; + GCancellable *cancellable; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOO:gio.Drive.eject", + kwlist, + ¬ify->callback, + &py_flags, + &py_cancellable, + ¬ify->data)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!PyCallable_Check(notify->callback)) { + PyErr_SetString(PyExc_TypeError, "callback argument not callable"); + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, + py_flags, (gpointer) &flags)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + g_drive_eject(G_DRIVE(self->obj), + flags, + cancellable, + (GAsyncReadyCallback) async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override g_drive_poll_for_media kwargs +static PyObject * +_wrap_g_drive_poll_for_media(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyGObject *py_cancellable = NULL; + GCancellable *cancellable; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OO:gio.Drive.eject", + kwlist, + ¬ify->callback, + &py_cancellable, + ¬ify->data)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!PyCallable_Check(notify->callback)) { + PyErr_SetString(PyExc_TypeError, "callback argument not callable"); + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + g_drive_poll_for_media(G_DRIVE(self->obj), + cancellable, + (GAsyncReadyCallback) async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% override g_app_info_get_all noargs static PyObject * _wrap_g_app_info_get_all (PyGObject *self) @@ -271,6 +369,130 @@ _wrap_g_mount_unmount(PyGObject *self, return Py_None; } %% +override g_mount_eject kwargs +static PyObject * +_wrap_g_mount_eject(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "flags", "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyObject *py_flags = NULL; + GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE; + PyGObject *py_cancellable = NULL; + GCancellable *cancellable; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOO:gio.Mount.eject", + kwlist, + ¬ify->callback, + &py_flags, + &py_cancellable, + ¬ify->data)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!PyCallable_Check(notify->callback)) { + PyErr_SetString(PyExc_TypeError, "callback argument not callable"); + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, + py_flags, (gpointer) &flags)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + g_mount_eject(G_MOUNT(self->obj), + flags, + cancellable, + (GAsyncReadyCallback) async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override g_mount_remount kwargs +static PyObject * +_wrap_g_mount_remount(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "flags", "mount_operation", + "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyObject *py_flags = NULL; + GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE; + PyObject *py_mount_operation = Py_None; + GMountOperation *mount_operation = NULL; + PyGObject *py_cancellable = NULL; + GCancellable *cancellable; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOOO:gio.Mount.remount", + kwlist, + ¬ify->callback, + &py_flags, + &py_mount_operation, + &py_cancellable, + ¬ify->data)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!PyCallable_Check(notify->callback)) { + PyErr_SetString(PyExc_TypeError, "callback argument not callable"); + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (py_mount_operation != Py_None) { + if (!pygobject_check(py_mount_operation, &PyGMountOperation_Type)) { + PyErr_SetString(PyExc_TypeError, + "mount_operation must be a gio.MountOperation or None"); + g_slice_free(PyGIONotify, notify); + return NULL; + } + + mount_operation = G_MOUNT_OPERATION(pygobject_get(py_mount_operation)); + } + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, + py_flags, (gpointer) &flags)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + g_mount_remount(G_MOUNT(self->obj), + flags, + mount_operation, + cancellable, + (GAsyncReadyCallback) async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% override g_vfs_get_supported_uri_schemes noargs static PyObject * _wrap_g_vfs_get_supported_uri_schemes(PyGObject *self) |