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
|
%%
headers
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgimpthumb/gimpthumb.h>
/* TODO: Add a header for these */
void gimpthumb_register_classes(PyObject *d);
void gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix);
%%
modulename gimpthumb
%%
import gobject.GObject as PyGObject_Type
import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
%%
ignore-glob
*_get_type
%%
override gimp_thumb_init kwargs
static PyObject *
_wrap_gimp_thumb_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
char *creator, *thumb_basedir = NULL;
static char *kwlist[] = { "creator", "thumb_basedir", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"s|z:init", kwlist,
&creator, &thumb_basedir))
return NULL;
return PyBool_FromLong(gimp_thumb_init(creator, thumb_basedir));
}
%%
override gimp_thumb_find_thumb kwargs
static PyObject *
_wrap_gimp_thumb_find_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
{
gchar *uri, *ret;
PyObject *py_size, *py_ret;
GimpThumbSize size;
static char *kwlist[] = { "uri", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:find_thumb", kwlist,
&uri, &py_size))
return NULL;
if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gint *)&size))
return NULL;
ret = gimp_thumb_find_thumb(uri, &size);
if (ret == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
py_ret = Py_BuildValue("sN", ret,
pyg_enum_from_gtype(GIMP_TYPE_THUMB_SIZE, size));
g_free(ret);
return py_ret;
}
%%
override gimp_thumb_file_test kwargs
static PyObject *
_wrap_gimp_thumb_file_test(PyGObject *self, PyObject *args, PyObject *kwargs)
{
gchar *filename;
GimpThumbFileType ret;
gint64 mtime, size;
gint err_no;
static char *kwlist[] = { "filename", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:file_test", kwlist,
&filename))
return NULL;
ret = gimp_thumb_file_test(filename, &mtime, &size, &err_no);
if (ret == GIMP_THUMB_FILE_TYPE_NONE) {
PyObject *v = Py_BuildValue("iss",
err_no, g_strerror(err_no), filename);
if (v != NULL) {
PyErr_SetObject(PyExc_IOError, v);
Py_DECREF(v);
}
return NULL;
}
return Py_BuildValue("NNN",
pyg_enum_from_gtype(GIMP_TYPE_THUMB_FILE_TYPE, ret),
PyLong_FromLongLong(mtime),
PyLong_FromLongLong(size));
}
|