summaryrefslogtreecommitdiffstats
path: root/plug-ins/pygimp/gimpthumb.override
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:30:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:30:19 +0000
commit5c1676dfe6d2f3c837a5e074117b45613fd29a72 (patch)
treecbffb45144febf451e54061db2b21395faf94bfe /plug-ins/pygimp/gimpthumb.override
parentInitial commit. (diff)
downloadgimp-5c1676dfe6d2f3c837a5e074117b45613fd29a72.tar.xz
gimp-5c1676dfe6d2f3c837a5e074117b45613fd29a72.zip
Adding upstream version 2.10.34.upstream/2.10.34upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plug-ins/pygimp/gimpthumb.override')
-rw-r--r--plug-ins/pygimp/gimpthumb.override102
1 files changed, 102 insertions, 0 deletions
diff --git a/plug-ins/pygimp/gimpthumb.override b/plug-ins/pygimp/gimpthumb.override
new file mode 100644
index 0000000..c43e539
--- /dev/null
+++ b/plug-ins/pygimp/gimpthumb.override
@@ -0,0 +1,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));
+}