[gimp] python: add Image.insert_layer() and Image.insert_channel()
- From: Sven Neumann <neo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] python: add Image.insert_layer() and Image.insert_channel()
- Date: Mon, 6 Sep 2010 21:59:37 +0000 (UTC)
commit 378a465caaa1a206ab22955f38f8961803409585
Author: Sven Neumann <sven gimp org>
Date: Mon Sep 6 23:43:22 2010 +0200
python: add Image.insert_layer() and Image.insert_channel()
plug-ins/pygimp/pygimp-image.c | 58 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/pygimp/pygimp-image.c b/plug-ins/pygimp/pygimp-image.c
index 200e0e3..9b3f340 100644
--- a/plug-ins/pygimp/pygimp-image.c
+++ b/plug-ins/pygimp/pygimp-image.c
@@ -45,6 +45,34 @@ img_add_channel(PyGimpImage *self, PyObject *args)
}
static PyObject *
+img_insert_channel(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpChannel *chn;
+ PyGimpChannel *parent = NULL;
+ int pos = -1;
+
+ static char *kwlist[] = { "channel", "parent", "position", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|O!i:insert_channel", kwlist,
+ &PyGimpChannel_Type, &chn,
+ &PyGimpChannel_Type, &parent,
+ &pos))
+ return NULL;
+
+ if (!gimp_image_insert_channel(self->ID,
+ chn->ID, parent ? parent->ID : -1, pos)) {
+ PyErr_Format(pygimp_error,
+ "could not insert channel (ID %d) to image (ID %d)",
+ chn->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
img_add_layer(PyGimpImage *self, PyObject *args)
{
PyGimpLayer *lay;
@@ -66,6 +94,34 @@ img_add_layer(PyGimpImage *self, PyObject *args)
}
static PyObject *
+img_insert_layer(PyGimpImage *self, PyObject *args, PyObject *kwargs)
+{
+ PyGimpLayer *lay;
+ PyGimpLayer *parent = NULL;
+ int pos = -1;
+
+ static char *kwlist[] = { "layer", "parent", "position", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "O!|O!i:insert_layer", kwlist,
+ &PyGimpLayer_Type, &lay,
+ &PyGimpLayer_Type, &parent,
+ &pos))
+ return NULL;
+
+ if (!gimp_image_insert_layer(self->ID,
+ lay->ID, parent ? parent->ID : -1, pos)) {
+ PyErr_Format(pygimp_error,
+ "could not insert layer (ID %d) to image (ID %d)",
+ lay->ID, self->ID);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
img_new_layer(PyGimpImage *self, PyObject *args, PyObject *kwargs)
{
char *layer_name;
@@ -837,7 +893,9 @@ img_undo_group_end(PyGimpImage *self)
static PyMethodDef img_methods[] = {
{"add_channel", (PyCFunction)img_add_channel, METH_VARARGS},
+ {"insert_channel", (PyCFunction)img_insert_channel, METH_VARARGS | METH_KEYWORDS},
{"add_layer", (PyCFunction)img_add_layer, METH_VARARGS},
+ {"insert_layer", (PyCFunction)img_insert_layer, METH_VARARGS | METH_KEYWORDS},
{"new_layer", (PyCFunction)img_new_layer, METH_VARARGS | METH_KEYWORDS},
{"clean_all", (PyCFunction)img_clean_all, METH_NOARGS},
{"disable_undo", (PyCFunction)img_disable_undo, METH_NOARGS},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]