From d292dd4f624f2a08afc228f82a5f72e77593864e Mon Sep 17 00:00:00 2001 From: Gian Mario Tagliaretti Date: Wed, 29 Apr 2009 21:28:44 +0200 Subject: Wrap three gio.Mount methods the following methods of gio.Mount have been wrapped including docs (_wrap_g_mount_guess_content_type) (_wrap_g_mount_guess_content_type_finish) (_wrap_g_mount_guess_content_type_sync) --- docs/reference/pygio-mount.xml | 152 +++++++++++++++++++++++++++++++++++++++++ gio/gio.override | 1 + gio/gmount.override | 142 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 295 insertions(+) create mode 100644 gio/gmount.override diff --git a/docs/reference/pygio-mount.xml b/docs/reference/pygio-mount.xml index 0ea320df..f5688c59 100644 --- a/docs/reference/pygio-mount.xml +++ b/docs/reference/pygio-mount.xml @@ -57,6 +57,22 @@ get_volume + + guess_content_type + callback + force_rescan + cancellableNone + user_dataNone + + + guess_content_type_finish + result + + + guess_content_type_sync + force_rescan + cancellableNone + remount callback @@ -424,6 +440,132 @@ + + gio.Mount.guess_content_type + + + guess_content_type + callback + force_rescan + cancellableNone + user_dataNone + + + + + callback : + A GAsyncReadyCallback to call when the request is satisfied. + + + + force_rescan : + Whether to force a rescan of the content. Otherwise a cached result will be used if available. + + + + cancellable : + Optional + gio.Cancellable + object, None to ignore. + + + + user_data : + The data to pass to callback function. + + + + + + The guess_content_type() method asynchronously tries to guess the type of + content stored on mount. Returns one or more textual identifiers of well-known content + types (typically prefixed with "x-content/"), e.g. x-content/image-dcf for camera memory + cards. See the shared-mime-info specification for more on x-content types. + + + If cancellable is not None, then the operation can be cancelled + by triggering the cancellable object from another thread. If the operation was cancelled, + the error gio.IO_ERROR_CANCELLED will be returned. + + + When the operation is finished, callback will be called. You can then call + gio.Mount.guess_content_type_finish() + to obtain the result of the operation. + + + + + gio.Mount.guess_content_type_finish + + + guess_content_type_finish + result + + + + + result : + a gio.AsyncResult. + + + + Returns : + A list of types or None on error. + + + + + + The guess_content_type_finish() method finishes guessing content + types of mount. If any errors occured during the operation, error will be set to + contain the errors and FALSE will be returned. In particular, you may get an + gio.IO_ERROR_NOT_SUPPORTED if the mount does not support content guessing. + + + + + gio.Mount.guess_content_type_sync + + + guess_content_type_sync + force_rescan + cancellableNone + + + + + force_rescan : + Whether to force a rescan of the content. Otherwise a cached result will be used if available. + + + + cancellable : + Optional + gio.Cancellable + object, None to ignore. + + + + + + The guess_content_type_sync() method tries to guess + the type of content stored on mount. Returns one or more textual identifiers + of well-known content types (typically prefixed with "x-content/"), e.g. + x-content/image-dcf for camera memory cards. See the shared-mime-info specification + for more on x-content types. + + + If cancellable is not None, then the operation can be cancelled + by triggering the cancellable object from another thread. If the operation was cancelled, + the error gio.IO_ERROR_CANCELLED will be returned. + + + This is an synchronous operation and as such may block doing IO; see + gio.Mount.guess_content_type() + for the asynchronous version. + + + gio.Mount.remount @@ -471,6 +613,11 @@ The remount() method asynchronously remounts a mount. + + If cancellable is not None, then the operation can be cancelled + by triggering the cancellable object from another thread. If the operation was cancelled, + the error gio.IO_ERROR_CANCELLED will be returned. + When the operation is finished, callback will be called. You can then call gio.Mount.remount_finish() @@ -545,6 +692,11 @@ The unmount() method asynchronously unmounts a mount. + + If cancellable is not None, then the operation can be cancelled + by triggering the cancellable object from another thread. If the operation was cancelled, + the error gio.IO_ERROR_CANCELLED will be returned. + When the operation is finished, callback will be called. You can then call gio.Mount.unmount_finish() diff --git a/gio/gio.override b/gio/gio.override index 0d5da96b..c117fdf6 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -236,6 +236,7 @@ include gfileenumerator.override gfileinfo.override gicon.override + gmount.override ginputstream.override goutputstream.override gvolume.override diff --git a/gio/gmount.override b/gio/gmount.override new file mode 100644 index 00000000..43eca140 --- /dev/null +++ b/gio/gmount.override @@ -0,0 +1,142 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * pygobject - Python bindings for GObject + * Copyright (C) 2009 Gian Mario Tagliaretti + * + * gmount.override: module overrides for GMount + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ +%% +override g_mount_guess_content_type kwargs +static PyObject * +_wrap_g_mount_guess_content_type(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "callback", "force_rescan", + "cancellable", "user_data", NULL }; + PyGIONotify *notify; + PyGObject *py_cancellable = NULL; + GCancellable *cancellable; + gboolean force_rescan; + + notify = pygio_notify_new(); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oi|OO:Mount.guess_content_type", + kwlist, + ¬ify->callback, + &force_rescan, + &py_cancellable, + ¬ify->data)) + goto error; + + if (!pygio_notify_callback_is_valid(notify)) + goto error; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + goto error; + + pygio_notify_reference_callback(notify); + + g_mount_guess_content_type(G_MOUNT(self->obj), + force_rescan, + cancellable, + (GAsyncReadyCallback)async_result_callback_marshal, + notify); + + Py_INCREF(Py_None); + return Py_None; + + error: + pygio_notify_free(notify); + return NULL; +} +%% +override g_mount_guess_content_type_finish kwargs +static PyObject * +_wrap_g_mount_guess_content_type_finish(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "result", NULL }; + PyGObject *result; + GError *error = NULL; + char **ret; + PyObject *py_ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O!:Mount.guess_content_type_finish", + kwlist, + &PyGAsyncResult_Type, + &result)) + return NULL; + + ret = g_mount_guess_content_type_finish(G_MOUNT(self->obj), + G_ASYNC_RESULT(result->obj), &error); + + if (pyg_error_check(&error)) + return NULL; + + if (ret && ret[0] != NULL) { + py_ret = strv_to_pylist(ret); + g_strfreev (ret); + } else { + py_ret = Py_None; + Py_INCREF(py_ret); + } + return py_ret; +} +%% +override g_mount_guess_content_type_sync kwargs +static PyObject * +_wrap_g_mount_guess_content_type_sync(PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "force_rescan", "cancellable", NULL }; + gboolean force_rescan; + PyGObject *py_cancellable = NULL; + GCancellable *cancellable; + GError *error = NULL; + char **ret; + PyObject *py_ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i|O:Mount.guess_content_type_sync", + kwlist, + &force_rescan, + &py_cancellable)) + return NULL; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + return NULL; + + ret = g_mount_guess_content_type_sync(G_MOUNT(self->obj), force_rescan, + cancellable, &error); + + if (pyg_error_check(&error)) + return NULL; + + if (ret && ret[0] != NULL) { + py_ret = strv_to_pylist(ret); + g_strfreev (ret); + } else { + py_ret = Py_None; + Py_INCREF(py_ret); + } + return py_ret; +} -- cgit v1.2.1