9fb0828c220bb0b962665bd00d8aa41b7bd48264
[platform/upstream/pygobject2.git] / gio / gmount.override
1 /* -*- Mode: C; c-basic-offset: 4 -*-
2  * pygobject - Python bindings for GObject
3  * Copyright (C) 2009  Gian Mario Tagliaretti
4  *
5  *   gmount.override: module overrides for GMount
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22 %%
23 override g_mount_guess_content_type kwargs
24 static PyObject *
25 _wrap_g_mount_guess_content_type(PyGObject *self,
26                                  PyObject *args,
27                                  PyObject *kwargs)
28 {
29     static char *kwlist[] = { "callback", "force_rescan",
30                               "cancellable", "user_data", NULL };
31     PyGIONotify *notify;
32     PyGObject *py_cancellable = NULL;
33     GCancellable *cancellable;
34     gboolean force_rescan;
35
36     notify = pygio_notify_new();
37
38     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
39                                      "Oi|OO:Mount.guess_content_type",
40                                      kwlist,
41                                      &notify->callback,
42                                      &force_rescan,
43                                      &py_cancellable,
44                                      &notify->data))
45         goto error;
46
47     if (!pygio_notify_callback_is_valid(notify))
48         goto error;
49
50     if (!pygio_check_cancellable(py_cancellable, &cancellable))
51         goto error;
52
53     pygio_notify_reference_callback(notify);
54
55     g_mount_guess_content_type(G_MOUNT(self->obj),
56                             force_rescan,
57                             cancellable,
58                             (GAsyncReadyCallback)async_result_callback_marshal,
59                             notify);
60
61     Py_INCREF(Py_None);
62     return Py_None;
63
64     error:
65        pygio_notify_free(notify);
66        return NULL;
67 }
68 %%
69 override g_mount_guess_content_type_finish kwargs
70 static PyObject *
71 _wrap_g_mount_guess_content_type_finish(PyGObject *self,
72                                         PyObject *args,
73                                         PyObject *kwargs)
74 {
75     static char *kwlist[] = { "result", NULL };
76     PyGObject *result;
77     GError *error = NULL;
78     char **ret;
79     PyObject *py_ret;
80
81     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
82                                      "O!:Mount.guess_content_type_finish",
83                                       kwlist,
84                                       &PyGAsyncResult_Type,
85                                       &result))
86         return NULL;
87
88     ret = g_mount_guess_content_type_finish(G_MOUNT(self->obj),
89                                          G_ASYNC_RESULT(result->obj), &error);
90
91     if (pyg_error_check(&error))
92         return NULL;
93
94     if (ret && ret[0] != NULL) {
95         py_ret = strv_to_pylist(ret);
96         g_strfreev (ret);
97     } else {
98         py_ret = Py_None;
99         Py_INCREF(py_ret);
100     }
101     return py_ret;
102 }
103 %%
104 override g_mount_guess_content_type_sync kwargs
105 static PyObject *
106 _wrap_g_mount_guess_content_type_sync(PyGObject *self,
107                                       PyObject *args,
108                                       PyObject *kwargs)
109 {
110     static char *kwlist[] = { "force_rescan", "cancellable", NULL };
111     gboolean force_rescan;
112     PyGObject *py_cancellable = NULL;
113     GCancellable *cancellable;
114     GError *error = NULL;
115     char **ret;
116     PyObject *py_ret;
117
118     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
119                                      "i|O:Mount.guess_content_type_sync",
120                                       kwlist,
121                                       &force_rescan,
122                                       &py_cancellable))
123         return NULL;
124
125     if (!pygio_check_cancellable(py_cancellable, &cancellable))
126         return NULL;
127
128     ret = g_mount_guess_content_type_sync(G_MOUNT(self->obj), force_rescan,
129                                           cancellable, &error);
130
131     if (pyg_error_check(&error))
132         return NULL;
133
134     if (ret && ret[0] != NULL) {
135         py_ret = strv_to_pylist(ret);
136         g_strfreev (ret);
137     } else {
138         py_ret = Py_None;
139         Py_INCREF(py_ret);
140     }
141     return py_ret;
142 }
143 %%
144 override g_mount_remount kwargs
145 static PyObject *
146 _wrap_g_mount_remount(PyGObject *self, PyObject *args, PyObject *kwargs)
147 {
148     static char *kwlist[] = { "callback", "flags", "mount_operation",
149                               "cancellable", "user_data", NULL };
150     PyGIONotify *notify;
151     PyObject *py_flags = NULL;
152     GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
153     PyObject *py_mount_operation = Py_None;
154     GMountOperation *mount_operation = NULL;
155     PyGObject *py_cancellable = NULL;
156     GCancellable *cancellable;
157
158     notify = pygio_notify_new();
159
160     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
161                                      "O|OOOO:gio.Mount.remount",
162                                      kwlist,
163                                      &notify->callback,
164                                      &py_flags,
165                                      &py_mount_operation,
166                                      &py_cancellable,
167                                      &notify->data))
168         goto error;
169
170     if (!pygio_notify_callback_is_valid(notify))
171         goto error;
172
173     if (py_mount_operation != Py_None) {
174         if (!pygobject_check(py_mount_operation, &PyGMountOperation_Type)) {
175             PyErr_SetString(PyExc_TypeError,
176                             "mount_operation must be a gio.MountOperation or None");
177             goto error;
178         }
179
180         mount_operation = G_MOUNT_OPERATION(pygobject_get(py_mount_operation));
181     }
182
183     if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
184                                         py_flags, (gpointer) &flags))
185         goto error;
186
187     if (!pygio_check_cancellable(py_cancellable, &cancellable))
188         goto error;
189
190     pygio_notify_reference_callback(notify);
191
192     pyg_begin_allow_threads;
193
194     g_mount_remount(G_MOUNT(self->obj),
195                     flags,
196                     mount_operation,
197                     cancellable,
198                     (GAsyncReadyCallback) async_result_callback_marshal,
199                     notify);
200
201     pyg_end_allow_threads;
202
203     Py_INCREF(Py_None);
204     return Py_None;
205
206  error:
207     pygio_notify_free(notify);
208     return NULL;
209 }
210 %%
211 override g_mount_unmount kwargs
212 static PyObject *
213 _wrap_g_mount_unmount(PyGObject *self,
214                       PyObject *args,
215                       PyObject *kwargs)
216 {
217     static char *kwlist[] = { "callback", "flags",
218                               "cancellable", "user_data", NULL };
219     PyGIONotify *notify;
220     PyObject *py_flags = NULL;
221     PyGObject *py_cancellable = NULL;
222     GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
223     GCancellable *cancellable;
224
225     notify = pygio_notify_new();
226
227     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
228                                      "O|OOO:gio.Mount.unmount",
229                                      kwlist,
230                                      &notify->callback,
231                                      &py_flags,
232                                      &py_cancellable,
233                                      &notify->data))
234         goto error;
235
236     if (!pygio_notify_callback_is_valid(notify))
237         goto error;
238
239     if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
240                                         py_flags, (gpointer)&flags))
241         goto error;
242
243     if (!pygio_check_cancellable(py_cancellable, &cancellable))
244         goto error;
245
246     pygio_notify_reference_callback(notify);
247
248     pyg_begin_allow_threads;
249
250     g_mount_unmount(G_MOUNT(self->obj),
251                     flags,
252                     cancellable,
253                     (GAsyncReadyCallback)async_result_callback_marshal,
254                     notify);
255
256     pyg_end_allow_threads;
257
258     Py_INCREF(Py_None);
259     return Py_None;
260
261  error:
262     pygio_notify_free(notify);
263     return NULL;
264 }
265 %%
266 override g_mount_eject kwargs
267 static PyObject *
268 _wrap_g_mount_eject(PyGObject *self, PyObject *args, PyObject *kwargs)
269 {
270     static char *kwlist[] = { "callback", "flags", "cancellable", "user_data", NULL };
271     PyGIONotify *notify;
272     PyObject *py_flags = NULL;
273     GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
274     PyGObject *py_cancellable = NULL;
275     GCancellable *cancellable;
276
277     notify = pygio_notify_new();
278
279     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
280                                      "O|OOO:gio.Mount.eject",
281                                      kwlist,
282                                      &notify->callback,
283                                      &py_flags,
284                                      &py_cancellable,
285                                      &notify->data))
286         goto error;
287
288     if (!pygio_notify_callback_is_valid(notify))
289         goto error;
290
291     if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
292                                         py_flags, (gpointer) &flags))
293         goto error;
294
295     if (!pygio_check_cancellable(py_cancellable, &cancellable))
296         goto error;
297
298     pygio_notify_reference_callback(notify);
299
300     pyg_begin_allow_threads;
301
302     g_mount_eject(G_MOUNT(self->obj),
303                   flags,
304                   cancellable,
305                   (GAsyncReadyCallback) async_result_callback_marshal,
306                   notify);
307
308     pyg_end_allow_threads;
309
310     Py_INCREF(Py_None);
311     return Py_None;
312
313  error:
314     pygio_notify_free(notify);
315     return NULL;
316 }
317 %%
318 override-slot GMount.tp_repr
319 static PyObject *
320 _wrap_g_mount_tp_repr(PyGObject *self)
321 {
322     char *name = g_mount_get_name(G_MOUNT(self->obj));
323     char *uuid = g_mount_get_uuid(G_MOUNT(self->obj));
324     gchar *representation;
325     PyObject *result;
326
327     if (name) {
328         if (uuid) {
329             representation = g_strdup_printf("<%s at %p: %s (%s)>",
330                                              self->ob_type->tp_name, self, name, uuid);
331         }
332         else {
333             representation = g_strdup_printf("<%s at %p: %s>",
334                                              self->ob_type->tp_name, self, name);
335         }
336     }
337     else
338         representation = g_strdup_printf("<%s at %p: UNKNOWN NAME>", self->ob_type->tp_name, self);
339
340     g_free(name);
341     g_free(uuid);
342
343     result = PyString_FromString(representation);
344     g_free(representation);
345     return result;
346 }
347 %%
348 override g_mount_unmount_with_operation kwargs
349 static PyObject *
350 _wrap_g_mount_unmount_with_operation(PyGObject *self,
351                                      PyObject *args,
352                                      PyObject *kwargs)
353 {
354     static char *kwlist[] = { "callback", "flags", "mount_operation",
355                               "cancellable", "user_data", NULL };
356     PyGIONotify *notify;
357     PyObject *py_flags = NULL;
358     PyGObject *mount_operation;
359     PyGObject *py_cancellable = NULL;
360     GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
361     GCancellable *cancellable;
362
363     notify = pygio_notify_new();
364
365     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
366                                 "O|OOOO:gio.Mount.unmount_with_operation",
367                                 kwlist,
368                                 &notify->callback,
369                                 &py_flags,
370                                 &mount_operation,
371                                 &py_cancellable,
372                                 &notify->data))
373         goto error;
374
375     if (!pygio_notify_callback_is_valid(notify))
376         goto error;
377
378     if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
379                                         py_flags, (gpointer)&flags))
380         goto error;
381
382     if (!pygio_check_cancellable(py_cancellable, &cancellable))
383         goto error;
384
385     pygio_notify_reference_callback(notify);
386
387     g_mount_unmount_with_operation(G_MOUNT(self->obj),
388                              flags,
389                              G_MOUNT_OPERATION(mount_operation->obj),
390                              cancellable,
391                              (GAsyncReadyCallback)async_result_callback_marshal,
392                              notify);
393
394     Py_INCREF(Py_None);
395     return Py_None;
396
397  error:
398     pygio_notify_free(notify);
399     return NULL;
400 }
401 %%
402 override g_mount_eject_with_operation kwargs
403 static PyObject *
404 _wrap_g_mount_eject_with_operation(PyGObject *self,
405                                      PyObject *args,
406                                      PyObject *kwargs)
407 {
408     static char *kwlist[] = { "callback", "flags", "mount_operation",
409                               "cancellable", "user_data", NULL };
410     PyGIONotify *notify;
411     PyObject *py_flags = NULL;
412     PyGObject *mount_operation;
413     PyGObject *py_cancellable = NULL;
414     GMountUnmountFlags flags = G_MOUNT_UNMOUNT_NONE;
415     GCancellable *cancellable;
416
417     notify = pygio_notify_new();
418
419     if (!PyArg_ParseTupleAndKeywords(args, kwargs,
420                                 "O|OOOO:gio.Mount.eject_with_operation",
421                                 kwlist,
422                                 &notify->callback,
423                                 &py_flags,
424                                 &mount_operation,
425                                 &py_cancellable,
426                                 &notify->data))
427         goto error;
428
429     if (!pygio_notify_callback_is_valid(notify))
430         goto error;
431
432     if (py_flags && pyg_flags_get_value(G_TYPE_MOUNT_UNMOUNT_FLAGS,
433                                         py_flags, (gpointer)&flags))
434         goto error;
435
436     if (!pygio_check_cancellable(py_cancellable, &cancellable))
437         goto error;
438
439     pygio_notify_reference_callback(notify);
440
441     g_mount_eject_with_operation(G_MOUNT(self->obj),
442                             flags,
443                             G_MOUNT_OPERATION(mount_operation->obj),
444                             cancellable,
445                             (GAsyncReadyCallback)async_result_callback_marshal,
446                             notify);
447
448     Py_INCREF(Py_None);
449     return Py_None;
450
451  error:
452     pygio_notify_free(notify);
453     return NULL;
454 }