File: vfs.override

package info (click to toggle)
libdesktop-agnostic 0.3.90-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,004 kB
  • ctags: 4,635
  • sloc: ansic: 30,148; python: 1,069; makefile: 24; xml: 12
file content (227 lines) | stat: -rw-r--r-- 6,506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
%%
headers
/*
 * Copyright (c) 2009 Mark Lee <libdesktop-agnostic@lazymalevolence.com>
 *
 * 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 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.
*/

#ifdef HAVE_BUILD_CONFIG_H
#include "build-config.h"
#endif
#include <pygobject.h>
#include <libdesktop-agnostic/vfs.h>

/* Taken from PyGObject 2.19.0 <gobject/pygobject.h> (LGPL 2.1+). */
#ifndef PYLIST_FROMGLIBLIST
/**
 * PYLIST_FROMGLIBLIST:
 * @type: the type of the GLib list e.g. #GList or #GSList
 * @prefix: the prefix of functions that manipulate a list of the type
 * given by type.
 *
 * A macro that creates a type specific code block which converts a GLib
 * list (#GSList or #GList) to a Python list. The first two args of the macro
 * are used to specify the type and list function prefix so that the type
 * specific macros can be generated.
 *
 * The rest of the args are for the standard args for the type specific
 * macro(s) created from this macro.
 */
 #define PYLIST_FROMGLIBLIST(type,prefix,py_list,list,item_convert_func,\
                            list_free,list_item_free)  \
G_STMT_START \
{ \
    gint i, len; \
    PyObject *item; \
    void (*glib_list_free)(type*) = list_free; \
    GFunc glib_list_item_free = (GFunc)list_item_free;  \
 \
    len = prefix##_length(list); \
    py_list = PyList_New(len); \
    for (i = 0; i < len; i++) { \
        gpointer list_item = prefix##_nth_data(list, i); \
 \
        item = item_convert_func; \
        PyList_SetItem(py_list, i, item); \
    } \
    if (glib_list_item_free != NULL) \
        prefix##_foreach(list, glib_list_item_free, NULL); \
    if (glib_list_free != NULL) \
        glib_list_free(list); \
} G_STMT_END
/**
 * PYLIST_FROMGSLIST:
 * @py_list: the name of the Python list
 *
 * @list: the #GSList to be converted to a Python list
 *
 * @item_convert_func: the function that converts a list item to a Python
 * object. The function must refer to the list item using "@list_item" and
 * must return a #PyObject* object. An example conversion function is:
 * [[
 * PyString_FromString(list_item)
 * ]]
 * A more elaborate function is:
 * [[
 * pyg_boxed_new(GTK_TYPE_RECENT_INFO, list_item, TRUE, TRUE)
 * ]]
 * @list_free: the name of a function that takes a single arg (the list) and
 * frees its memory. Can be %NULL if the list should not be freed. An example
 * is:
 * [[
 * g_list_free
 * ]]
 * @list_item_free: the name of a #GFunc function that frees the memory used
 * by the items in the list or %NULL if the list items do not have to be
 * freed. A simple example is:
 * [[
 * g_free
 * ]]
 *
 * A macro that adds code that converts a #GSList to a Python list.
 *
 */
#define PYLIST_FROMGSLIST(py_list,list,item_convert_func,list_free,\
                          list_item_free) \
        PYLIST_FROMGLIBLIST(GSList,g_slist,py_list,list,item_convert_func,\
                            list_free,list_item_free)
#endif
%%
modulename desktopagnostic.vfs
%%
import gobject.GObject as PyGObject_Type
%%
ignore-glob
  *_get_type
  *_error_quark
  desktop_agnostic_vfs_file_new_*
  desktop_agnostic_vfs_trash_get_default
%%
define DesktopAgnosticVFSFile.for_path onearg staticmethod
static PyObject *
_wrap_desktop_agnostic_v_f_s_file_for_path (PyObject *self, PyObject *arg)
{
  char *path;
  DesktopAgnosticVFSFile *ret;
  GError *error = NULL;

  if (!PyString_Check (arg))
  {
    PyErr_SetString (PyExc_TypeError,
                     "The parameter must be a string.");
    return NULL;
  }

  path = PyString_AsString (arg);

  ret = desktop_agnostic_vfs_file_new_for_path (path, &error);

  if (pyg_error_check (&error))
  {
    return NULL;
  }

  /* pygobject_new handles NULL checking */
  return pygobject_new ((GObject *)ret);
}
%%
define DesktopAgnosticVFSFile.for_uri onearg staticmethod
static PyObject *
_wrap_desktop_agnostic_v_f_s_file_for_uri (PyObject *self, PyObject *arg)
{
    char *uri;
    DesktopAgnosticVFSFile *ret;
    GError *error = NULL;

  if (!PyString_Check (arg))
  {
    PyErr_SetString (PyExc_TypeError,
                     "The parameter must be a string.");
    return NULL;
  }

  uri = PyString_AsString (arg);

  ret = desktop_agnostic_vfs_file_new_for_uri (uri, &error);

  if (pyg_error_check (&error))
  {
    return NULL;
  }

  /* pygobject_new handles NULL checking */
  return pygobject_new ((GObject *)ret);
}
%%
override desktop_agnostic_vfs_file_enumerate_children noargs
static PyObject *
_wrap_desktop_agnostic_vfs_file_enumerate_children (PyGObject *self)
{
  GSList *children = NULL;
  GError *error = NULL;
  PyObject *py_children;

  children = desktop_agnostic_vfs_file_enumerate_children (DESKTOP_AGNOSTIC_VFS_FILE (self->obj),
                                                           &error);

  if (pyg_error_check (&error))
  {
    return NULL;
  }

  PYLIST_FROMGSLIST (py_children, children,
                     pygobject_new ((GObject *)list_item), g_slist_free,
                     g_object_unref);

  return py_children;
}
%%
override desktop_agnostic_vfs_file_load_contents noargs
static PyObject *
_wrap_desktop_agnostic_vfs_file_load_contents (PyGObject *self)
{
  gchar *data;
  size_t length;
  GError *error = NULL;

  desktop_agnostic_vfs_file_load_contents (DESKTOP_AGNOSTIC_VFS_FILE (self->obj),
                                           &data, &length, &error);

  if (pyg_error_check (&error))
  {
    return NULL;
  }

  return PyString_FromStringAndSize (data, length);
}
%%
define DesktopAgnosticVFSTrash.get_default noargs staticmethod
static PyObject *
_wrap_desktop_agnostic_v_f_s_trash_get_default (PyObject *self)
{
  DesktopAgnosticVFSTrash *ret;
  GError *error = NULL;

  ret = desktop_agnostic_vfs_trash_get_default (&error);

  if (pyg_error_check (&error))
  {
    return NULL;
  }
  /* pygobject_new handles NULL checking */
  return pygobject_new ((GObject *)ret);
}