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
|
/* -*- Mode: C; c-basic-offset: 4 -*-
* pygobject - Python bindings for GObject
* Copyright (C) 2008 Johan Dahlin
*
* giomodule.c: module wrapping the GIO library
*
* 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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Python.h>
#include <pyglib.h>
#include <pygobject.h>
#include <pyglib-python-compat.h>
#include <gio/gio.h>
#define PYGIO_MAJOR_VERSION PYGOBJECT_MAJOR_VERSION
#define PYGIO_MINOR_VERSION PYGOBJECT_MINOR_VERSION
#define PYGIO_MICRO_VERSION PYGOBJECT_MICRO_VERSION
/* include any extra headers needed here */
void pygio_register_classes(PyObject *d);
void pygio_add_constants(PyObject *module, const gchar *strip_prefix);
extern PyMethodDef pygio_functions[];
PYGLIB_INIT_FUNCTION(_gio, "gio._gio", pygio_functions)
{
PyObject *d;
PyObject *tuple;
PyObject *e;
/* perform any initialisation required by the library here */
d = PyModule_GetDict(module);
g_type_init();
pyglib_init();
if (pygobject_init(2, 15, 2) == NULL)
return -1;
pygio_register_classes(d);
pygio_add_constants(module, "G_IO_");
PyModule_AddStringConstant(module, "ERROR", g_quark_to_string(G_IO_ERROR));
e = pyglib_register_exception_for_domain("gio.Error", G_IO_ERROR);
PyDict_SetItemString(d, "Error", e);
Py_DECREF(e);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_TYPE",
G_FILE_ATTRIBUTE_STANDARD_TYPE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_HIDDEN",
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_BACKUP",
G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_SYMLINK",
G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL",
G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_NAME",
G_FILE_ATTRIBUTE_STANDARD_NAME);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME",
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_EDIT_NAME",
G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_COPY_NAME",
G_FILE_ATTRIBUTE_STANDARD_COPY_NAME);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_DESCRIPTION",
G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_ICON",
G_FILE_ATTRIBUTE_STANDARD_ICON);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE",
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE",
G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_SIZE",
G_FILE_ATTRIBUTE_STANDARD_SIZE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET",
G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_TARGET_URI",
G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_SORT_ORDER",
G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ETAG_VALUE",
G_FILE_ATTRIBUTE_ETAG_VALUE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ID_FILE",
G_FILE_ATTRIBUTE_ID_FILE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ID_FILESYSTEM",
G_FILE_ATTRIBUTE_ID_FILESYSTEM);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_READ",
G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_WRITE",
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE",
G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_DELETE",
G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_TRASH",
G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_RENAME",
G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT",
G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT",
G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT",
G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE",
G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI",
G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_MODIFIED",
G_FILE_ATTRIBUTE_TIME_MODIFIED);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_MODIFIED_USEC",
G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_ACCESS",
G_FILE_ATTRIBUTE_TIME_ACCESS);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_ACCESS_USEC",
G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CHANGED",
G_FILE_ATTRIBUTE_TIME_CHANGED);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CHANGED_USEC",
G_FILE_ATTRIBUTE_TIME_CHANGED_USEC);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CREATED",
G_FILE_ATTRIBUTE_TIME_CREATED);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CREATED_USEC",
G_FILE_ATTRIBUTE_TIME_CREATED_USEC);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_DEVICE",
G_FILE_ATTRIBUTE_UNIX_DEVICE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_INODE",
G_FILE_ATTRIBUTE_UNIX_INODE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_MODE",
G_FILE_ATTRIBUTE_UNIX_MODE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_NLINK",
G_FILE_ATTRIBUTE_UNIX_NLINK);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_UID",
G_FILE_ATTRIBUTE_UNIX_UID);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_GID",
G_FILE_ATTRIBUTE_UNIX_GID);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_RDEV",
G_FILE_ATTRIBUTE_UNIX_RDEV);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_BLOCK_SIZE",
G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_BLOCKS",
G_FILE_ATTRIBUTE_UNIX_BLOCKS);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT",
G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_DOS_IS_ARCHIVE",
G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_DOS_IS_SYSTEM",
G_FILE_ATTRIBUTE_DOS_IS_SYSTEM);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_OWNER_USER",
G_FILE_ATTRIBUTE_OWNER_USER);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_OWNER_USER_REAL",
G_FILE_ATTRIBUTE_OWNER_USER_REAL);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_OWNER_GROUP",
G_FILE_ATTRIBUTE_OWNER_GROUP);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_THUMBNAIL_PATH",
G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_THUMBNAILING_FAILED",
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_SIZE",
G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_FREE",
G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_TYPE",
G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_READONLY",
G_FILE_ATTRIBUTE_FILESYSTEM_READONLY);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW",
G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_GVFS_BACKEND",
G_FILE_ATTRIBUTE_GVFS_BACKEND);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_SELINUX_CONTEXT",
G_FILE_ATTRIBUTE_SELINUX_CONTEXT);
PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TRASH_ITEM_COUNT",
G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT);
PyModule_AddStringConstant(module, "ERROR", g_quark_to_string(G_IO_ERROR));
/* pygio version */
tuple = Py_BuildValue ("(iii)",
PYGIO_MAJOR_VERSION,
PYGIO_MINOR_VERSION,
PYGIO_MICRO_VERSION);
PyDict_SetItemString(d, "pygio_version", tuple);
Py_DECREF(tuple);
return 0;
}
|