1
/* -*- mode: C; c-basic-offset: 4 -*- */
3
#include "pygnomevfs-private.h"
4
#define NO_IMPORT_PYGOBJECT
9
pygvdrive_get_id(PyGObject *self)
11
return PyLong_FromUnsignedLong(gnome_vfs_drive_get_id(GNOME_VFS_DRIVE(self->obj)));
15
pygvdrive_get_device_type(PyGObject *self)
17
return PyInt_FromLong(gnome_vfs_drive_get_device_type(GNOME_VFS_DRIVE(self->obj)));
21
pygvdrive_get_mounted_volumes(PyGObject *self)
24
PyObject *pyvolumes = PyList_New(0);
26
for (volumes = l = gnome_vfs_drive_get_mounted_volumes(GNOME_VFS_DRIVE(self->obj));
29
GnomeVFSVolume *volume = GNOME_VFS_VOLUME(l->data);
30
PyObject *pyvol = pygobject_new((GObject *)volume);
31
PyList_Append(pyvolumes, pyvol);
34
gnome_vfs_drive_volume_list_free(volumes);
39
pygvdrive_get_device_path(PyGObject *self)
43
retval = gnome_vfs_drive_get_device_path(GNOME_VFS_DRIVE(self->obj));
45
return PyString_FromString(retval);
53
pygvdrive_get_activation_uri(PyGObject *self)
57
retval = gnome_vfs_drive_get_activation_uri(GNOME_VFS_DRIVE(self->obj));
59
return PyString_FromString(retval);
68
pygvdrive_get_display_name(PyGObject *self)
72
retval = gnome_vfs_drive_get_display_name(GNOME_VFS_DRIVE(self->obj));
74
return PyString_FromString(retval);
82
pygvdrive_get_icon(PyGObject *self)
86
retval = gnome_vfs_drive_get_icon(GNOME_VFS_DRIVE(self->obj));
88
return PyString_FromString(retval);
96
pygvdrive_get_hal_udi(PyGObject *self)
100
retval = gnome_vfs_drive_get_hal_udi(GNOME_VFS_DRIVE(self->obj));
102
return PyString_FromString(retval);
110
pygvdrive_is_user_visible(PyGObject *self)
114
retval = gnome_vfs_drive_is_user_visible(GNOME_VFS_DRIVE(self->obj));
125
pygvdrive_is_connected(PyGObject *self)
129
retval = gnome_vfs_drive_is_connected(GNOME_VFS_DRIVE(self->obj));
140
pygvdrive_is_mounted(PyGObject *self)
144
retval = gnome_vfs_drive_is_mounted(GNOME_VFS_DRIVE(self->obj));
155
wrap_gnomevfs_volume_op_callback(gboolean succeeded,
157
char *detailed_error,
160
PyGnomeVFSVolumeOpCallback *context;
162
PyGILState_STATE gil;
164
context = (PyGnomeVFSVolumeOpCallback *) data;
165
gil = pyg_gil_state_ensure();
167
if (context->user_data)
168
retval = PyEval_CallFunction(context->callback, "(OssO)",
169
error, detailed_error,
172
retval = PyEval_CallFunction(context->callback, "(Oss)",
173
error, detailed_error);
180
Py_DECREF(context->callback);
181
Py_XDECREF(context->user_data);
184
pyg_gil_state_release(gil);
189
pygvdrive_mount(PyGObject *self, PyObject *args, PyObject *kwargs)
191
static char *kwlist[] = { "callback", "user_data", NULL };
192
PyObject *py_callback, *py_user_data = NULL;
193
PyGnomeVFSVolumeOpCallback *callback_context;
195
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
196
"O|O:gnomevfs.Drive.mount",
197
kwlist, &py_callback, py_user_data))
200
if (!PyCallable_Check(py_callback)) {
201
PyErr_SetString(PyExc_TypeError, "first argument must be callable");
205
callback_context = g_new(PyGnomeVFSVolumeOpCallback, 1);
206
callback_context->callback = py_callback;
207
Py_INCREF(py_callback);
208
callback_context->user_data = py_user_data;
209
Py_XINCREF(py_user_data);
211
gnome_vfs_drive_mount(GNOME_VFS_DRIVE(self->obj),
212
wrap_gnomevfs_volume_op_callback,
220
pygvdrive_unmount(PyGObject *self, PyObject *args, PyObject *kwargs)
222
static char *kwlist[] = { "callback", "user_data", NULL };
223
PyObject *py_callback, *py_user_data = NULL;
224
PyGnomeVFSVolumeOpCallback *callback_context;
226
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
227
"O|O:gnomevfs.Drive.unmount",
228
kwlist, &py_callback, py_user_data))
231
if (!PyCallable_Check(py_callback)) {
232
PyErr_SetString(PyExc_TypeError, "first argument must be callable");
236
callback_context = g_new(PyGnomeVFSVolumeOpCallback, 1);
237
callback_context->callback = py_callback;
238
Py_INCREF(py_callback);
239
callback_context->user_data = py_user_data;
240
Py_XINCREF(py_user_data);
242
gnome_vfs_drive_unmount(GNOME_VFS_DRIVE(self->obj),
243
wrap_gnomevfs_volume_op_callback,
251
pygvdrive_eject(PyGObject *self, PyObject *args, PyObject *kwargs)
253
static char *kwlist[] = { "callback", "user_data", NULL };
254
PyObject *py_callback, *py_user_data = NULL;
255
PyGnomeVFSVolumeOpCallback *callback_context;
257
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
258
"O|O:gnomevfs.Drive.eject",
259
kwlist, &py_callback, py_user_data))
262
if (!PyCallable_Check(py_callback)) {
263
PyErr_SetString(PyExc_TypeError, "first argument must be callable");
267
callback_context = g_new(PyGnomeVFSVolumeOpCallback, 1);
268
callback_context->callback = py_callback;
269
Py_INCREF(py_callback);
270
callback_context->user_data = py_user_data;
271
Py_XINCREF(py_user_data);
273
gnome_vfs_drive_eject(GNOME_VFS_DRIVE(self->obj),
274
wrap_gnomevfs_volume_op_callback,
281
static PyMethodDef pygvdrive_methods[] = {
282
{ "get_id", (PyCFunction)pygvdrive_get_id, METH_NOARGS },
283
{ "get_device_type", (PyCFunction)pygvdrive_get_device_type, METH_NOARGS },
284
{ "get_mounted_volumes", (PyCFunction)pygvdrive_get_mounted_volumes, METH_NOARGS },
285
{ "get_device_path", (PyCFunction)pygvdrive_get_device_path, METH_NOARGS },
286
{ "get_activation_uri", (PyCFunction)pygvdrive_get_activation_uri, METH_NOARGS },
287
{ "get_display_name", (PyCFunction)pygvdrive_get_display_name, METH_NOARGS },
288
{ "get_icon", (PyCFunction)pygvdrive_get_icon, METH_NOARGS },
289
{ "get_hal_udi", (PyCFunction)pygvdrive_get_hal_udi, METH_NOARGS },
290
{ "is_user_visible", (PyCFunction)pygvdrive_is_user_visible, METH_NOARGS },
291
{ "is_connected", (PyCFunction)pygvdrive_is_connected, METH_NOARGS },
292
{ "is_mounted", (PyCFunction)pygvdrive_is_mounted, METH_NOARGS },
293
{ "mount", (PyCFunction)pygvdrive_mount, METH_VARARGS|METH_KEYWORDS },
294
{ "unmount", (PyCFunction)pygvdrive_unmount, METH_VARARGS|METH_KEYWORDS },
295
{ "eject", (PyCFunction)pygvdrive_eject, METH_VARARGS|METH_KEYWORDS },
301
pygvdrive_compare(PyGObject *self, PyGObject *other)
303
return gnome_vfs_drive_compare(GNOME_VFS_DRIVE(self->obj),
304
GNOME_VFS_DRIVE(other->obj));
308
PyTypeObject PyGnomeVFSDrive_Type = {
309
PyObject_HEAD_INIT(NULL)
311
"gnomevfs.Drive", /* tp_name */
312
sizeof(PyGObject), /* tp_basicsize */
315
(destructor)0, /* tp_dealloc */
316
(printfunc)0, /* tp_print */
317
(getattrfunc)0, /* tp_getattr */
318
(setattrfunc)0, /* tp_setattr */
319
(cmpfunc)pygvdrive_compare, /* tp_compare */
320
(reprfunc)0, /* tp_repr */
321
0, /* tp_as_number */
322
0, /* tp_as_sequence */
323
0, /* tp_as_mapping */
324
(hashfunc)0, /* tp_hash */
325
(ternaryfunc)0, /* tp_call */
326
(reprfunc)0, /* tp_str */
327
(getattrofunc)0, /* tp_getattro */
328
(setattrofunc)0, /* tp_setattro */
329
0, /* tp_as_buffer */
330
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
331
NULL, /* Documentation string */
332
(traverseproc)0, /* tp_traverse */
333
(inquiry)0, /* tp_clear */
334
(richcmpfunc)0, /* tp_richcompare */
335
0, /* tp_weaklistoffset */
336
(getiterfunc)0, /* tp_iter */
337
(iternextfunc)0, /* tp_iternext */
338
pygvdrive_methods, /* tp_methods */
341
(PyTypeObject *)0, /* tp_base */
342
(PyObject *)0, /* tp_dict */
343
0, /* tp_descr_get */
344
0, /* tp_descr_set */
345
0, /* tp_dictoffset */
346
(initproc)0, /* tp_init */
347
PyType_GenericAlloc, /* tp_alloc */
348
PyType_GenericNew, /* tp_new */
350
(inquiry)0, /* tp_is_gc */
351
(PyObject *)0, /* tp_bases */