diff options
| author | Johan Dahlin <johan@gnome.org> | 2008-08-01 22:07:03 +0000 |
|---|---|---|
| committer | Johan Dahlin <johan@src.gnome.org> | 2008-08-01 22:07:03 +0000 |
| commit | 3a4235b39c68512f78ab93c9e0cc05b3588c07d5 (patch) | |
| tree | 2b286655b208bfe5754e07ab43ed630d411d15bd | |
| parent | 25a97f8de49ef5b4dcddbc4067bd5c994679e50d (diff) | |
Wrap gio.Volume.mount and gio.Volume.eject
2008-08-02 Johan Dahlin <johan@gnome.org>
* gio/Makefile.am:
* gio/gfile.override:
* gio/gio.defs:
* gio/gio.override:
* gio/gvolume.override:
Wrap gio.Volume.mount and gio.Volume.eject
svn path=/trunk/; revision=907
| -rw-r--r-- | ChangeLog | 9 | ||||
| -rw-r--r-- | gio/Makefile.am | 1 | ||||
| -rw-r--r-- | gio/gfile.override | 76 | ||||
| -rw-r--r-- | gio/gio.defs | 24 | ||||
| -rw-r--r-- | gio/gio.override | 3 | ||||
| -rw-r--r-- | gio/gvolume.override | 135 |
6 files changed, 243 insertions, 5 deletions
@@ -1,3 +1,12 @@ +2008-08-02 Johan Dahlin <johan@gnome.org> + + * gio/Makefile.am: + * gio/gfile.override: + * gio/gio.defs: + * gio/gio.override: + * gio/gvolume.override: + Wrap gio.Volume.mount and gio.Volume.eject + 2008-08-01 Gian Mario Tagliaretti <gianmt@gnome.org> * gio/gio.defs: diff --git a/gio/Makefile.am b/gio/Makefile.am index 4c57b41..af0cda1 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -44,6 +44,7 @@ GIO_OVERRIDES = \ gfileinfo.override \ ginputstream.override \ goutputstream.override \ + gvolume.override \ gvolumemonitor.override GIO_DEFS = gio.defs gio-types.defs $(GIO_OVERRIDES) diff --git a/gio/gfile.override b/gio/gfile.override index b5ecfc8..f95197e 100644 --- a/gio/gfile.override +++ b/gio/gfile.override @@ -408,7 +408,7 @@ _wrap_g_file_unmount_mountable(PyGObject *self, PyGIONotify *notify; PyObject *py_flags = NULL; PyGObject *py_cancellable = NULL; - GMountMountFlags flags = G_MOUNT_MOUNT_NONE; + GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE; GCancellable *cancellable; notify = g_slice_new0(PyGIONotify); @@ -435,7 +435,7 @@ _wrap_g_file_unmount_mountable(PyGObject *self, Py_INCREF(notify->callback); Py_XINCREF(notify->data); - if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_MOUNT_FLAGS, + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, py_flags, (gpointer)&flags)) return NULL; @@ -533,7 +533,7 @@ _wrap_g_file_copy(PyGObject *self, notify = g_slice_new0(PyGIONotify); if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O!|OOOO:File.unmount_mountable", + "O!|OOOO:File.copy", kwlist, &PyGFile_Type, &destination, @@ -581,6 +581,76 @@ _wrap_g_file_copy(PyGObject *self, return PyBool_FromLong(ret); } %% +override g_file_move kwargs +static PyObject * +_wrap_g_file_move(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "destination", "flags", + "cancellable", "progress_callback", + "user_data", NULL }; + PyGIONotify *notify; + PyObject *py_flags = NULL; + PyGObject *destination = NULL; + PyGObject *py_cancellable = NULL; + GFileCopyFlags flags = G_FILE_COPY_NONE; + GCancellable *cancellable; + int ret; + GError *error = NULL; + GFileProgressCallback callback = NULL; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O!|OOOO:File.move", + kwlist, + &PyGFile_Type, + &destination, + ¬ify->callback, + &py_flags, + &py_cancellable, + ¬ify->data)) + + { + g_slice_free(PyGIONotify, notify); + return NULL; + } + + if (notify->callback != NULL) + { + if (!PyCallable_Check(notify->callback)) + { + PyErr_SetString(PyExc_TypeError, "callback argument not callable"); + g_slice_free(PyGIONotify, notify); + return NULL; + } + callback = (GFileProgressCallback)file_progress_callback_marshal; + Py_INCREF(notify->callback); + } + Py_XINCREF(notify->data); + + if (py_flags && pyg_flags_get_value(G_TYPE_FILE_COPY_FLAGS, + py_flags, (gpointer)&flags)) + return NULL; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + return NULL; + + ret = g_file_move(G_FILE(self->obj), + G_FILE(destination->obj), + flags, + cancellable, + callback, + notify, + &error); + + if (pyg_error_check(&error)) + return NULL; + + return PyBool_FromLong(ret); +} +%% override g_file_set_attribute kwargs static PyObject * _wrap_g_file_set_attribute(PyGObject *self, PyObject *args, PyObject *kwargs) diff --git a/gio/gio.defs b/gio/gio.defs index 04c3a92..c1d1f7b 100644 --- a/gio/gio.defs +++ b/gio/gio.defs @@ -2004,7 +2004,7 @@ "operation was cancelled, the error gio.ERROR_CANCELLED will be returned.\n" "\n" "When the operation is finished, callback will be called. You can\n" -"then call g_file_unmount_mountable_finish() to get the\n" +"then call gio.File.unmount_mountable_finish() to get the\n" "result of the operation.\n") (of-object "GFile") (c-name "g_file_unmount_mountable") @@ -3589,6 +3589,16 @@ ) (define-method eject + (docstring +"F.eject(callback, [flags, cancellable, user_data])\n" +"Ejects a volume.\n" +"\n" +"If cancellable is not None, then the operation can be cancelled by\n" +"triggering the cancellable object from another thread. If the\n" +"operation was cancelled, the error gio.ERROR_CANCELLED will be returned.\n" +"\n" +"When the operation is finished, callback will be called. You can\n" +"then call gio.Volume.eject_finish() to get the result of the operation.\n") (of-object "GMount") (c-name "g_mount_eject") (return-type "none") @@ -4397,6 +4407,18 @@ ) (define-method mount + (docstring +"V.mount(mount_operation, callback, [flags, cancellable, user_data])\n" +"Mounts a volume. Using mount_operation, you can request callbacks\n" +"when, for instance, passwords are needed during authentication.\n" +"\n" +"If cancellable is not None, then the operation can be cancelled by\n" +" triggering the cancellable object from another thread. If the\n" +"operation was cancelled, the error gio.ERROR_CANCELLED will be returned.\n" +"\n" +"When the operation is finished, callback will be called. You can then\n" +"call gio.Volume.mount_finish() to get the result of the operation.\n") + (of-object "GVolume") (c-name "g_volume_mount") (return-type "none") diff --git a/gio/gio.override b/gio/gio.override index 46fc6a6..74ae6f7 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -2,7 +2,7 @@ * pygtk- Python bindings for the GTK toolkit. * Copyright (C) 2008 Johan Dahlin * - * giomodule.c: module wrapping the GIO library + * gio.override: 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 @@ -87,6 +87,7 @@ include gfileinfo.override ginputstream.override goutputstream.override + gvolume.override gvolumemonitor.override %% ignore-glob diff --git a/gio/gvolume.override b/gio/gvolume.override new file mode 100644 index 0000000..3345ced --- /dev/null +++ b/gio/gvolume.override @@ -0,0 +1,135 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * pygobject - Python bindings for GObject + * Copyright (C) 2008 Johan Dahlin + * + * gvolume.override: module overrides for GVolume + * + * 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 + */ +%% +override g_volume_mount kwargs +static PyObject * +_wrap_g_volume_mount(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "flags", "mount_operation", + "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyObject *py_flags = NULL; + PyGObject *mount_operation; + PyGObject *py_cancellable = NULL; + GMountMountFlags flags = G_MOUNT_MOUNT_NONE; + GCancellable *cancellable; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O!O|OOO:Volume.mount", + kwlist, + &PyGMountOperation_Type, + &mount_operation, + ¬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; + } + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_MOUNT_FLAGS, + py_flags, (gpointer)&flags)) + return NULL; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + return NULL; + + g_volume_mount(G_VOLUME(self->obj), + flags, + G_MOUNT_OPERATION(mount_operation->obj), + cancellable, + (GAsyncReadyCallback)async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override g_volume_eject kwargs +static PyObject * +_wrap_g_volume_eject(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "flags", + "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyObject *py_flags = NULL; + PyGObject *py_cancellable = NULL; + GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE; + GCancellable *cancellable; + + notify = g_slice_new0(PyGIONotify); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOO:Volume.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; + } + Py_INCREF(notify->callback); + Py_XINCREF(notify->data); + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, + py_flags, (gpointer)&flags)) + return NULL; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + return NULL; + + g_volume_eject(G_VOLUME(self->obj), + flags, + cancellable, + (GAsyncReadyCallback)async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; +} |
