Commit 378a465c authored by Sven Neumann's avatar Sven Neumann

python: add Image.insert_layer() and Image.insert_channel()

parent 48f62195
......@@ -44,6 +44,34 @@ img_add_channel(PyGimpImage *self, PyObject *args)
return Py_None;
}
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)
{
......@@ -65,6 +93,34 @@ img_add_layer(PyGimpImage *self, PyObject *args)
return Py_None;
}
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)
{
......@@ -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},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment