diff options
author | Paul Pogonyshev <pogonyshev@gmx.net> | 2009-05-31 18:25:47 +0300 |
---|---|---|
committer | Paul Pogonyshev <pogonyshev@gmx.net> | 2009-06-12 23:56:24 +0300 |
commit | 7766daa59b0e2b85413cee368bf2ebd2afe198e1 (patch) | |
tree | b13c148760f10ed00008c0c5b899617f85cd5b2d /gio/gmount.override | |
parent | 07e9c18dc092f6546230168b6b69c1b3454e120a (diff) | |
download | pygobject-7766daa59b0e2b85413cee368bf2ebd2afe198e1.tar.gz pygobject-7766daa59b0e2b85413cee368bf2ebd2afe198e1.tar.xz pygobject-7766daa59b0e2b85413cee368bf2ebd2afe198e1.zip |
Cleanup GIO overrides to use Python function/method names
Also move several gio.Mount overrides over from 'gio.override' to
existing 'gmount.override'. Part of bug #584289.
Diffstat (limited to 'gio/gmount.override')
-rw-r--r-- | gio/gmount.override | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/gio/gmount.override b/gio/gmount.override index 43eca14..ba88a19 100644 --- a/gio/gmount.override +++ b/gio/gmount.override @@ -140,3 +140,207 @@ _wrap_g_mount_guess_content_type_sync(PyGObject *self, } return py_ret; } +%% +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 = pygio_notify_new(); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOOO:gio.Mount.remount", + kwlist, + ¬ify->callback, + &py_flags, + &py_mount_operation, + &py_cancellable, + ¬ify->data)) + goto error; + + if (!pygio_notify_callback_is_valid(notify)) + goto error; + + 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"); + goto error; + } + + 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)) + goto error; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + goto error; + + pygio_notify_reference_callback(notify); + + pyg_begin_allow_threads; + + g_mount_remount(G_MOUNT(self->obj), + flags, + mount_operation, + cancellable, + (GAsyncReadyCallback) async_result_callback_marshal, + notify); + + pyg_end_allow_threads; + + Py_INCREF(Py_None); + return Py_None; + + error: + pygio_notify_free(notify); + return NULL; +} +%% +override g_mount_unmount kwargs +static PyObject * +_wrap_g_mount_unmount(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 = pygio_notify_new(); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOO:gio.Mount.unmount", + kwlist, + ¬ify->callback, + &py_flags, + &py_cancellable, + ¬ify->data)) + goto error; + + if (!pygio_notify_callback_is_valid(notify)) + goto error; + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, + py_flags, (gpointer)&flags)) + goto error; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + goto error; + + pygio_notify_reference_callback(notify); + + pyg_begin_allow_threads; + + g_mount_unmount(G_MOUNT(self->obj), + flags, + cancellable, + (GAsyncReadyCallback)async_result_callback_marshal, + notify); + + pyg_end_allow_threads; + + Py_INCREF(Py_None); + return Py_None; + + error: + pygio_notify_free(notify); + return NULL; +} +%% +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 = pygio_notify_new(); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|OOO:gio.Mount.eject", + kwlist, + ¬ify->callback, + &py_flags, + &py_cancellable, + ¬ify->data)) + goto error; + + if (!pygio_notify_callback_is_valid(notify)) + goto error; + + if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS, + py_flags, (gpointer) &flags)) + goto error; + + if (!pygio_check_cancellable(py_cancellable, &cancellable)) + goto error; + + pygio_notify_reference_callback(notify); + + pyg_begin_allow_threads; + + g_mount_eject(G_MOUNT(self->obj), + flags, + cancellable, + (GAsyncReadyCallback) async_result_callback_marshal, + notify); + + pyg_end_allow_threads; + + Py_INCREF(Py_None); + return Py_None; + + error: + pygio_notify_free(notify); + return NULL; +} +%% +override-slot GMount.tp_repr +static PyObject * +_wrap_g_mount_tp_repr(PyGObject *self) +{ + char *name = g_mount_get_name(G_MOUNT(self->obj)); + char *uuid = g_mount_get_uuid(G_MOUNT(self->obj)); + gchar *representation; + PyObject *result; + + if (name) { + if (uuid) { + representation = g_strdup_printf("<%s at %p: %s (%s)>", + self->ob_type->tp_name, self, name, uuid); + } + else { + representation = g_strdup_printf("<%s at %p: %s>", + self->ob_type->tp_name, self, name); + } + } + else + representation = g_strdup_printf("<%s at %p: UNKNOWN NAME>", self->ob_type->tp_name, self); + + g_free(name); + g_free(uuid); + + result = PyString_FromString(representation); + g_free(representation); + return result; +} |