diff options
| author | Mads Chr. Olesen <gnome-bugzilla@shiyee.dk> | 2009-01-04 22:01:20 +0000 |
|---|---|---|
| committer | Paul Pogonyshev <paulp@src.gnome.org> | 2009-01-04 22:01:20 +0000 |
| commit | d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db (patch) | |
| tree | 78bd5148d5a76c1e346cbbe3d333e77aea14ae7c /gio | |
| parent | 9359060516f5dfea236fbf147815e48d54dac18a (diff) | |
| download | pygobject-d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db.tar.gz pygobject-d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db.tar.xz pygobject-d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db.zip | |
Define methods.
2009-01-04 Mads Chr. Olesen <gnome-bugzilla@shiyee.dk>
* gio/gio.defs (gio.File.copy_async, gio.File.copy_finish): Define
methods.
* gio/gfile.override (_wrap_g_file_copy_async): New function.
* tests/test_gio.py (TestFile.test_copy_async): Test the methods.
svn path=/trunk/; revision=990
Diffstat (limited to 'gio')
| -rw-r--r-- | gio/gfile.override | 86 | ||||
| -rw-r--r-- | gio/gio.defs | 37 |
2 files changed, 123 insertions, 0 deletions
diff --git a/gio/gfile.override b/gio/gfile.override index deb43e8..f484b08 100644 --- a/gio/gfile.override +++ b/gio/gfile.override @@ -579,6 +579,92 @@ _wrap_g_file_copy(PyGObject *self, return PyBool_FromLong(ret); } %% +override g_file_copy_async kwargs +static PyObject * +_wrap_g_file_copy_async(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "destination", "callback", "flags", "io_priority", + "user_data", "cancellable", "progress_callback", + "progress_callback_data", NULL }; + PyGIONotify *notify, *progress_callback; + PyObject *py_flags = NULL; + PyGObject *destination = NULL; + PyGObject *py_cancellable = NULL; + GFileCopyFlags flags = G_FILE_COPY_NONE; + int io_priority = G_PRIORITY_DEFAULT; + PyGObject *pycancellable = NULL; + GCancellable *cancellable; + GFileProgressCallback callback = NULL; + + notify = g_slice_new0(PyGIONotify); + progress_callback = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O!O|OiOOOO:File.copy_async", + kwlist, + &PyGFile_Type, + &destination, + ¬ify->callback, + &py_flags, + &io_priority, + ¬ify->data, + &pycancellable, + &progress_callback->callback, + &progress_callback->data + )) + { + g_slice_free(PyGIONotify, notify); + g_slice_free(PyGIONotify, progress_callback); + return NULL; + } + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + return NULL; + if (progress_callback->callback != NULL) + { + if (!PyCallable_Check(progress_callback->callback)) + { + PyErr_SetString(PyExc_TypeError, "progress_callback argument not callable"); + g_slice_free(PyGIONotify, notify); + g_slice_free(PyGIONotify, progress_callback); + return NULL; + } + callback = (GFileProgressCallback)file_progress_callback_marshal; + Py_INCREF(progress_callback->callback); + Py_XINCREF(progress_callback->data); + } + if (!PyCallable_Check(notify->callback)) + { + PyErr_SetString(PyExc_TypeError, "callback argument not callable"); + Py_DECREF(progress_callback->callback); + Py_XDECREF(progress_callback->data); + g_slice_free(PyGIONotify, notify); + g_slice_free(PyGIONotify, progress_callback); + return NULL; + } + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + + if (!pygio_check_cancellable(pycancellable, &cancellable)) + return NULL; + + g_file_copy_async(G_FILE(self->obj), + G_FILE(destination->obj), + flags, + io_priority, + cancellable, + callback, + progress_callback, + (GAsyncReadyCallback)async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% override g_file_move kwargs static PyObject * _wrap_g_file_move(PyGObject *self, diff --git a/gio/gio.defs b/gio/gio.defs index ce4ee5a..3c84048 100644 --- a/gio/gio.defs +++ b/gio/gio.defs @@ -1788,6 +1788,43 @@ ) ) +(define-method copy_async + (of-object "GFile") + (docstring + "F.copy_async(destination, callback, [flags, io_priority, user_data, cancellable, progress_callback])\n" + "-> start copy\n" + "\n" + "For more details, see gio.File.copy() which is the synchronous\n" + "version of this call. Asynchronously copies file.\n" + "When the operation is finished, callback will be called.\n" + "You can then call g_file_copy_finish() to get the result of the\n" + "operation.\n" + ) + (c-name "g_file_copy_async") + (return-type "none") + (parameters + '("GFile*" "destination") + '("GFileCopyFlags" "flags" (default "G_FILE_COPY_NONE")) + '("int" "io_priority" (default "G_PRIORITY_DEFAULT")) + '("GCancellable*" "cancellable" (null-ok) (default "NULL")) + '("GFileProgressCallback" "progress_callback") + '("gpointer" "progress_callback_data") + '("GAsyncReadyCallback" "callback") + '("gpointer" "user_data") + ) +) + +(define-method copy_finish + (of-object "GFile") + (c-name "g_file_copy_finish") + (return-type "gboolean") + (parameters + '("GAsyncResult*" "res") + '("GError**" "error") + ) +) + + (define-method move (docstring "F.move(destination, [callback, flags, cancellable, user_data])\n" |
