115
127
gimp_procedural_db_proc_info(name, &b, &h, &a, &c, &d, &t, &np, &nrv,
117
129
g_free(b); g_free(h); g_free(a); g_free(c); g_free(d); g_free(pd);
120
fprintf(stderr, "Params for %s:", name);
132
g_printerr("Params for %s:", name);
121
133
print_GParam(nparams, params);
123
136
args = pygimp_param_to_tuple(nparams, params);
124
138
if (args == NULL) {
127
*return_vals = g_new(GimpParam, 1);
128
(*return_vals)[0].type = GIMP_PDB_STATUS;
129
(*return_vals)[0].data.d_status = GIMP_PDB_CALLING_ERROR;
142
*return_vals = g_new(GimpParam, 1);
143
(*return_vals)[0].type = GIMP_PDB_STATUS;
144
(*return_vals)[0].data.d_status = GIMP_PDB_CALLING_ERROR;
132
149
ret = PyObject_CallFunction(callbacks[3], "(sO)", name, args);
134
152
if (ret == NULL) {
138
*return_vals = g_new(GimpParam, 1);
139
(*return_vals)[0].type = GIMP_PDB_STATUS;
140
(*return_vals)[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
157
*return_vals = g_new(GimpParam, 1);
158
(*return_vals)[0].type = GIMP_PDB_STATUS;
159
(*return_vals)[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
143
164
*return_vals = pygimp_param_from_tuple(ret, rv, nrv);
145
167
if (*return_vals == NULL) {
148
*return_vals = g_new(GimpParam, 1);
149
(*return_vals)[0].type = GIMP_PDB_STATUS;
150
(*return_vals)[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
171
*return_vals = g_new(GimpParam, 1);
172
(*return_vals)[0].type = GIMP_PDB_STATUS;
173
(*return_vals)[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
154
180
*nreturn_vals = nrv + 1;
155
181
(*return_vals)[0].type = GIMP_PDB_STATUS;
156
182
(*return_vals)[0].data.d_status = GIMP_PDB_SUCCESS;
499
555
pygimp_install_procedure(PyObject *self, PyObject *args)
501
557
char *name, *blurb, *help, *author, *copyright, *date, *menu_path,
502
*image_types, *n, *d;
558
*image_types, *n, *d;
503
559
GimpParamDef *params, *return_vals;
504
560
int type, nparams, nreturn_vals, i;
505
561
PyObject *pars, *rets;
507
563
if (!PyArg_ParseTuple(args, "sssssszziOO:install_procedure",
508
&name, &blurb, &help,
509
&author, ©right, &date, &menu_path, &image_types,
510
&type, &pars, &rets))
564
&name, &blurb, &help,
565
&author, ©right, &date, &menu_path, &image_types,
566
&type, &pars, &rets))
512
569
if (!PySequence_Check(pars) || !PySequence_Check(rets)) {
513
PyErr_SetString(PyExc_TypeError,
514
"last two args must be sequences");
570
PyErr_SetString(PyExc_TypeError, "last two args must be sequences");
517
574
nparams = PySequence_Length(pars);
518
575
nreturn_vals = PySequence_Length(rets);
519
576
params = g_new(GimpParamDef, nparams);
520
578
for (i = 0; i < nparams; i++) {
521
if (!PyArg_ParseTuple(PySequence_GetItem(pars, i), "iss",
522
&(params[i].type), &n, &d)) {
526
params[i].name = g_strdup(n);
527
params[i].description = g_strdup(d);
579
if (!PyArg_ParseTuple(PySequence_GetItem(pars, i), "iss",
580
&(params[i].type), &n, &d)) {
585
params[i].name = g_strdup(n);
586
params[i].description = g_strdup(d);
529
589
return_vals = g_new(GimpParamDef, nreturn_vals);
530
591
for (i = 0; i < nreturn_vals; i++) {
531
if (!PyArg_ParseTuple(PySequence_GetItem(rets, i), "iss",
532
&(return_vals[i].type), &n, &d)) {
533
g_free(params); g_free(return_vals);
536
return_vals[i].name = g_strdup(n);
537
return_vals[i].description = g_strdup(d);
592
if (!PyArg_ParseTuple(PySequence_GetItem(rets, i), "iss",
593
&(return_vals[i].type), &n, &d)) {
594
g_free(params); g_free(return_vals);
598
return_vals[i].name = g_strdup(n);
599
return_vals[i].description = g_strdup(d);
539
602
gimp_install_procedure(name, blurb, help, author, copyright, date,
540
menu_path, image_types, type, nparams, nreturn_vals,
541
params, return_vals);
603
menu_path, image_types, type, nparams, nreturn_vals,
604
params, return_vals);
542
606
Py_INCREF(Py_None);
547
611
pygimp_install_temp_proc(PyObject *self, PyObject *args)
549
613
char *name, *blurb, *help, *author, *copyright, *date, *menu_path,
550
*image_types, *n, *d;
614
*image_types, *n, *d;
551
615
GimpParamDef *params, *return_vals;
552
616
int type, nparams, nreturn_vals, i;
553
617
PyObject *pars, *rets;
555
619
if (!PyArg_ParseTuple(args, "sssssszziOO:install_temp_proc",
556
&name, &blurb, &help,
557
&author, ©right, &date, &menu_path, &image_types,
558
&type, &pars, &rets))
620
&name, &blurb, &help,
621
&author, ©right, &date, &menu_path, &image_types,
622
&type, &pars, &rets))
560
625
if (!PySequence_Check(pars) || !PySequence_Check(rets)) {
561
PyErr_SetString(PyExc_TypeError,
562
"last two args must be sequences");
626
PyErr_SetString(PyExc_TypeError, "last two args must be sequences");
565
630
nparams = PySequence_Length(pars);
566
631
nreturn_vals = PySequence_Length(rets);
567
632
params = g_new(GimpParamDef, nparams);
568
634
for (i = 0; i < nparams; i++) {
569
if (!PyArg_ParseTuple(PySequence_GetItem(pars, i), "iss",
570
&(params[i].type), &n, &d)) {
574
params[i].name = g_strdup(n);
575
params[i].description = g_strdup(d);
635
if (!PyArg_ParseTuple(PySequence_GetItem(pars, i), "iss",
636
&(params[i].type), &n, &d)) {
641
params[i].name = g_strdup(n);
642
params[i].description = g_strdup(d);
577
645
return_vals = g_new(GimpParamDef, nreturn_vals);
578
647
for (i = 0; i < nreturn_vals; i++) {
579
if (!PyArg_ParseTuple(PySequence_GetItem(rets, i), "iss",
580
&(return_vals[i].type), &n, &d)) {
581
g_free(params); g_free(return_vals);
584
return_vals[i].name = g_strdup(n);
585
return_vals[i].description = g_strdup(d);
648
if (!PyArg_ParseTuple(PySequence_GetItem(rets, i), "iss",
649
&(return_vals[i].type), &n, &d)) {
650
g_free(params); g_free(return_vals);
654
return_vals[i].name = g_strdup(n);
655
return_vals[i].description = g_strdup(d);
587
658
gimp_install_temp_proc(name, blurb, help, author, copyright, date,
588
menu_path, image_types, type, nparams, nreturn_vals, params,
589
return_vals, pygimp_run_proc);
659
menu_path, image_types, type,
660
nparams, nreturn_vals, params, return_vals,
590
663
Py_INCREF(Py_None);
660
778
static PyObject *
779
pygimp_personal_rc_file(PyObject *self, PyObject *args, PyObject *kwargs)
781
char *basename, *filename;
784
static char *kwlist[] = { "basename", NULL };
786
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
787
"s:personal_rc_file", kwlist,
791
filename = gimp_personal_rc_file(basename);
792
ret = PyString_FromString(filename);
799
pygimp_context_push(PyObject *self)
806
pygimp_context_pop(PyObject *self)
661
813
pygimp_get_background(PyObject *self)
666
gimp_context_get_background(&colour);
667
gimp_rgb_get_uchar(&colour, &r, &g, &b);
668
return Py_BuildValue("(iii)", (int)r, (int)g, (int)b);
817
gimp_context_get_background(&rgb);
818
return pygimp_rgb_new(&rgb);
671
821
static PyObject *
672
822
pygimp_get_foreground(PyObject *self)
677
gimp_context_get_foreground(&colour);
678
gimp_rgb_get_uchar(&colour, &r, &g, &b);
679
return Py_BuildValue("(iii)", (int)r, (int)g, (int)b);
826
gimp_context_get_foreground(&rgb);
827
return pygimp_rgb_new(&rgb);
682
830
static PyObject *
683
831
pygimp_set_background(PyObject *self, PyObject *args)
834
GimpRGB tmprgb, *rgb;
687
if (!PyArg_ParseTuple(args, "(iii):set_background", &r, &g, &b)) {
689
if (!PyArg_ParseTuple(args, "iii:set_background", &r, &g, &b))
692
r = CLAMP(r, 0, 255);
693
g = CLAMP(g, 0, 255);
694
b = CLAMP(b, 0, 255);
695
gimp_rgb_set_uchar(&colour, r, g, b);
696
gimp_context_set_background(&colour);
836
gboolean compat = FALSE;
838
if (!PyArg_ParseTuple(args, "O!:set_background",
839
PyGimpRGB_Type, &color)) {
842
if (!PyArg_ParseTuple(args, "(iii):set_background", &r, &g, &b)) {
844
if (!PyArg_ParseTuple(args, "iii:set_background", &r, &g, &b)) {
846
PyArg_ParseTuple(args, "O!:set_background",
847
PyGimpRGB_Type, &color);
854
r = CLAMP(r, 0, 255);
855
g = CLAMP(g, 0, 255);
856
b = CLAMP(b, 0, 255);
858
gimp_rgb_set_uchar(&tmprgb, r, g, b);
861
rgb = pyg_boxed_get(color, GimpRGB);
864
gimp_context_set_background(rgb);
697
866
Py_INCREF(Py_None);
701
870
static PyObject *
702
871
pygimp_set_foreground(PyObject *self, PyObject *args)
874
GimpRGB tmprgb, *rgb;
706
if (!PyArg_ParseTuple(args, "(iii):set_foreground", &r, &g, &b)) {
708
if (!PyArg_ParseTuple(args, "iii:set_foreground", &r, &g, &b))
711
r = CLAMP(r, 0, 255);
712
g = CLAMP(g, 0, 255);
713
b = CLAMP(b, 0, 255);
714
gimp_rgb_set_uchar(&colour, r, g, b);
715
gimp_context_set_foreground(&colour);
876
gboolean compat = FALSE;
878
if (!PyArg_ParseTuple(args, "O!:set_foreground",
879
PyGimpRGB_Type, &color)) {
882
if (!PyArg_ParseTuple(args, "(iii):set_foreground", &r, &g, &b)) {
884
if (!PyArg_ParseTuple(args, "iii:set_foreground", &r, &g, &b)) {
886
PyArg_ParseTuple(args, "O!:set_foreground",
887
PyGimpRGB_Type, &color);
894
r = CLAMP(r, 0, 255);
895
g = CLAMP(g, 0, 255);
896
b = CLAMP(b, 0, 255);
898
gimp_rgb_set_uchar(&tmprgb, r, g, b);
901
rgb = pyg_boxed_get(color, GimpRGB);
904
gimp_context_set_foreground(rgb);
716
906
Py_INCREF(Py_None);
720
910
static PyObject *
721
pygimp_gradients_get_list(PyObject *self)
911
pygimp_gradients_get_list(PyObject *self, PyObject *args, PyObject *kwargs)
913
char **list, *filter = NULL;
727
list = gimp_gradients_get_list(NULL, &num);
917
static char *kwlist[] = { "filter", NULL };
919
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
920
"|s:gradients_get_list", kwlist,
924
list = gimp_gradients_get_list(filter, &num);
728
926
ret = PyList_New(num);
729
for (i = 0; i < num; i++)
730
PyList_SetItem(ret, i, PyString_FromString(list[i]));
928
for (i = 0; i < num; i++) {
929
PyList_SetItem(ret, i, PyString_FromString(list[i]));
816
1020
PyObject *ret, *item;
817
1021
gboolean success;
819
if (!PyArg_ParseTuple(args, "sO|i:gradient_get_uniform_samples", &name, &ret, &reverse))
1023
if (!PyArg_ParseTuple(args, "sO|i:gradient_get_custom_samples",
1024
&name, &ret, &reverse))
822
1027
if (!PySequence_Check(ret)) {
823
PyErr_SetString(PyExc_TypeError,
824
"second arg must be a sequence");
1028
PyErr_SetString(PyExc_TypeError,
1029
"second arg must be a sequence");
828
1033
num = PySequence_Length(ret);
829
1034
pos = g_new(gdouble, num);
831
1036
for (i = 0; i < num; i++) {
832
item = PySequence_GetItem(ret, i);
834
if (!PyFloat_Check(item)) {
835
PyErr_SetString(PyExc_TypeError,
836
"second arg must be a sequence of floats");
841
pos[i] = PyFloat_AsDouble(item);
1037
item = PySequence_GetItem(ret, i);
1039
if (!PyFloat_Check(item)) {
1040
PyErr_SetString(PyExc_TypeError,
1041
"second arg must be a sequence of floats");
1046
pos[i] = PyFloat_AsDouble(item);
844
1049
success = gimp_gradient_get_custom_samples(name, num, pos, reverse,
849
PyErr_SetString(pygimp_error, "gradient_get_custom_samples failed");
1054
PyErr_SetString(pygimp_error, "gradient_get_custom_samples failed");
853
1058
ret = PyList_New(num);
854
1059
for (i = 0, j = 0; i < num; i++, j += 4)
855
PyList_SetItem(ret, i, Py_BuildValue("(dddd)", samp[j],
856
samp[j+1], samp[j+2], samp[j+3]));
1060
PyList_SetItem(ret, i, Py_BuildValue("(dddd)", samp[j],
1061
samp[j+1], samp[j+2], samp[j+3]));
1056
1321
gchar **parasites;
1058
1323
if (gimp_parasite_list(&num_parasites, ¶sites)) {
1062
ret = PyTuple_New(num_parasites);
1063
for (i = 0; i < num_parasites; i++) {
1064
PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
1065
g_free(parasites[i]);
1327
ret = PyTuple_New(num_parasites);
1329
for (i = 0; i < num_parasites; i++) {
1330
PyTuple_SetItem(ret, i, PyString_FromString(parasites[i]));
1331
g_free(parasites[i]);
1070
1338
PyErr_SetString(pygimp_error, "could not list parasites");
1074
1342
static PyObject *
1343
pygimp_show_tool_tips(PyObject *self)
1345
return PyBool_FromLong(gimp_show_tool_tips());
1349
pygimp_show_help_button(PyObject *self)
1351
return PyBool_FromLong(gimp_show_help_button());
1355
pygimp_check_size(PyObject *self)
1357
return PyInt_FromLong(gimp_check_size());
1361
pygimp_check_type(PyObject *self)
1363
return PyInt_FromLong(gimp_check_type());
1075
1367
pygimp_default_display(PyObject *self)
1077
1369
return pygimp_display_new(gimp_default_display());
1080
1372
static PyObject *
1373
pygimp_wm_class(PyObject *self)
1375
return PyString_FromString(gimp_wm_class());
1379
pygimp_display_name(PyObject *self)
1381
return PyString_FromString(gimp_display_name());
1385
pygimp_monitor_number(PyObject *self)
1387
return PyInt_FromLong(gimp_monitor_number());
1391
pygimp_get_progname(PyObject *self)
1393
return PyString_FromString(gimp_get_progname());
1397
pygimp_fonts_refresh(PyObject *self)
1399
if (!gimp_fonts_refresh()) {
1400
PyErr_SetString(pygimp_error, "could not refresh fonts");
1409
pygimp_checks_get_shades(PyObject *self, PyObject *args, PyObject *kwargs)
1413
static char *kwlist[] = { "type", NULL };
1415
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1416
"i:checks_get_shades", kwlist,
1420
if (type < GIMP_CHECK_TYPE_LIGHT_CHECKS ||
1421
type > GIMP_CHECK_TYPE_BLACK_ONLY) {
1422
PyErr_SetString(PyExc_ValueError, "Invalid check type");
1426
gimp_checks_get_shades(type, &light, &dark);
1428
return Py_BuildValue("(ii)", light, dark);
1432
pygimp_fonts_get_list(PyObject *self, PyObject *args, PyObject *kwargs)
1434
char **list, *filter = NULL;
1438
static char *kwlist[] = { "filter", NULL };
1440
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1441
"|s:fonts_get_list", kwlist,
1445
list = gimp_fonts_get_list(filter, &num);
1448
PyErr_SetString(pygimp_error, "could not get font list");
1452
ret = PyList_New(num);
1454
for (i = 0; i < num; i++) {
1455
PyList_SetItem(ret, i, PyString_FromString(list[i]));
1465
vectors_to_objects(int num_vectors, int *vectors)
1470
ret = PyList_New(num_vectors);
1474
for (i = 0; i < num_vectors; i++)
1475
PyList_SetItem(ret, i, pygimp_vectors_new(vectors[i]));
1483
pygimp_vectors_import_from_file(PyObject *self, PyObject *args, PyObject *kwargs)
1487
gboolean merge = FALSE, scale = FALSE;
1488
int *vectors, num_vectors;
1491
static char *kwlist[] = { "image", "svg_file", "merge", "scale", NULL };
1493
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1494
"O!O|ii:vectors_import_from_file", kwlist,
1495
&PyGimpImage_Type, &img, &py_file,
1499
if (PyString_Check(py_file)) {
1500
success = gimp_vectors_import_from_file(img->ID,
1501
PyString_AsString(py_file),
1503
&num_vectors, &vectors);
1505
PyObject *chunk_size, *buffer, *read_method;
1507
chunk_size = PyInt_FromLong(16 * 1024);
1508
if (chunk_size == NULL)
1511
buffer = PyString_FromString("");
1512
if (buffer == NULL) {
1513
Py_DECREF(chunk_size);
1517
read_method = PyString_FromString("read");
1518
if (read_method == NULL || !PyCallable_Check(read_method)) {
1519
Py_XDECREF(read_method);
1520
PyErr_SetString(PyExc_TypeError,
1521
"svg_file must be an object that has a \"read\" "
1522
"method, or a filename (str)");
1528
chunk = PyObject_CallMethodObjArgs(py_file, read_method,
1531
if (!chunk || !PyString_Check(chunk)) {
1533
Py_DECREF(chunk_size);
1535
Py_DECREF(read_method);
1539
if (PyString_GET_SIZE(chunk) != 0) {
1540
PyString_ConcatAndDel(&buffer, chunk);
1541
if (buffer == NULL) {
1542
Py_DECREF(chunk_size);
1543
Py_DECREF(read_method);
1552
success = gimp_vectors_import_from_string(img->ID,
1553
PyString_AsString(buffer),
1554
PyString_Size(buffer),
1556
&num_vectors, &vectors);
1558
Py_DECREF(chunk_size);
1560
Py_DECREF(read_method);
1564
PyErr_SetString(pygimp_error, "Vectors import failed");
1568
return vectors_to_objects(num_vectors, vectors);
1572
pygimp_vectors_import_from_string(PyObject *self, PyObject *args, PyObject *kwargs)
1575
const char *svg_string;
1577
gboolean merge = FALSE, scale = FALSE;
1578
int *vectors, num_vectors;
1581
static char *kwlist[] = { "image", "svg_string", "merge", "scale", NULL };
1583
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1584
"O!s#|ii:vectors_import_from_string", kwlist,
1585
&PyGimpImage_Type, &img,
1586
&svg_string, &length,
1590
success = gimp_vectors_import_from_string(img->ID, svg_string, length,
1592
&num_vectors, &vectors);
1595
PyErr_SetString(pygimp_error, "Vectors import failed");
1599
return vectors_to_objects(num_vectors, vectors);
1081
1603
id2image(PyObject *self, PyObject *args)
1084
1607
if (!PyArg_ParseTuple(args, "i:_id2image", &id))
1087
return pygimp_image_new(id);
1611
return pygimp_image_new(id);
1088
1613
Py_INCREF(Py_None);
1089
1614
return Py_None;
1116
1662
/* List of methods defined in the module */
1118
1664
static struct PyMethodDef gimp_methods[] = {
1119
{"main", (PyCFunction)pygimp_main, METH_VARARGS},
1120
{"quit", (PyCFunction)pygimp_quit, METH_NOARGS},
1121
{"message", (PyCFunction)pygimp_message, METH_VARARGS},
1122
{"set_data", (PyCFunction)pygimp_set_data, METH_VARARGS},
1123
{"get_data", (PyCFunction)pygimp_get_data, METH_VARARGS},
1124
{"progress_init", (PyCFunction)pygimp_progress_init, METH_VARARGS},
1125
{"progress_update", (PyCFunction)pygimp_progress_update, METH_VARARGS},
1126
{"progress_install", (PyCFunction)pygimp_progress_install, METH_VARARGS | METH_KEYWORDS},
1127
{"progress_uninstall", (PyCFunction)pygimp_progress_uninstall, METH_VARARGS},
1128
{"image_list", (PyCFunction)pygimp_image_list, METH_NOARGS},
1129
{"install_procedure", (PyCFunction)pygimp_install_procedure, METH_VARARGS},
1130
{"install_temp_proc", (PyCFunction)pygimp_install_temp_proc, METH_VARARGS},
1131
{"uninstall_temp_proc", (PyCFunction)pygimp_uninstall_temp_proc, METH_VARARGS},
1132
{"register_magic_load_handler", (PyCFunction)pygimp_register_magic_load_handler, METH_VARARGS},
1133
{"register_load_handler", (PyCFunction)pygimp_register_load_handler, METH_VARARGS},
1134
{"register_save_handler", (PyCFunction)pygimp_register_save_handler, METH_VARARGS},
1135
{"gamma", (PyCFunction)pygimp_gamma, METH_NOARGS},
1136
{"install_cmap", (PyCFunction)pygimp_install_cmap, METH_NOARGS},
1137
{"gtkrc", (PyCFunction)pygimp_gtkrc, METH_NOARGS},
1138
{"get_background", (PyCFunction)pygimp_get_background, METH_NOARGS},
1139
{"get_foreground", (PyCFunction)pygimp_get_foreground, METH_NOARGS},
1140
{"set_background", (PyCFunction)pygimp_set_background, METH_VARARGS},
1141
{"set_foreground", (PyCFunction)pygimp_set_foreground, METH_VARARGS},
1142
{"gradients_get_list", (PyCFunction)pygimp_gradients_get_list, METH_NOARGS},
1143
{"context_get_gradient", (PyCFunction)pygimp_context_get_gradient, METH_NOARGS},
1144
{"context_set_gradient", (PyCFunction)pygimp_context_set_gradient, METH_VARARGS},
1145
{"gradients_get_gradient", (PyCFunction)pygimp_gradients_get_gradient, METH_NOARGS},
1146
{"gradients_set_gradient", (PyCFunction)pygimp_gradients_set_gradient, METH_VARARGS},
1147
{"gradient_get_uniform_samples", (PyCFunction)pygimp_gradient_get_uniform_samples, METH_VARARGS},
1148
{"gradient_get_custom_samples", (PyCFunction)pygimp_gradient_get_custom_samples, METH_VARARGS},
1149
{"gradients_sample_uniform", (PyCFunction)pygimp_gradients_sample_uniform, METH_VARARGS},
1150
{"gradients_sample_custom", (PyCFunction)pygimp_gradients_sample_custom, METH_VARARGS},
1665
{"main", (PyCFunction)pygimp_main, METH_VARARGS},
1666
{"quit", (PyCFunction)pygimp_quit, METH_NOARGS},
1667
{"message", (PyCFunction)pygimp_message, METH_VARARGS},
1668
{"set_data", (PyCFunction)pygimp_set_data, METH_VARARGS},
1669
{"get_data", (PyCFunction)pygimp_get_data, METH_VARARGS},
1670
{"progress_init", (PyCFunction)pygimp_progress_init, METH_VARARGS},
1671
{"progress_update", (PyCFunction)pygimp_progress_update, METH_VARARGS},
1672
{"progress_install", (PyCFunction)pygimp_progress_install, METH_VARARGS | METH_KEYWORDS},
1673
{"progress_uninstall", (PyCFunction)pygimp_progress_uninstall, METH_VARARGS},
1674
{"image_list", (PyCFunction)pygimp_image_list, METH_NOARGS},
1675
{"install_procedure", (PyCFunction)pygimp_install_procedure, METH_VARARGS},
1676
{"install_temp_proc", (PyCFunction)pygimp_install_temp_proc, METH_VARARGS},
1677
{"uninstall_temp_proc", (PyCFunction)pygimp_uninstall_temp_proc, METH_VARARGS},
1678
{"register_magic_load_handler", (PyCFunction)pygimp_register_magic_load_handler, METH_VARARGS},
1679
{"register_load_handler", (PyCFunction)pygimp_register_load_handler, METH_VARARGS},
1680
{"register_save_handler", (PyCFunction)pygimp_register_save_handler, METH_VARARGS},
1681
{"domain_register", (PyCFunction)pygimp_domain_register, METH_VARARGS},
1682
{"menu_register", (PyCFunction)pygimp_menu_register, METH_VARARGS},
1683
{"gamma", (PyCFunction)pygimp_gamma, METH_NOARGS},
1684
{"install_cmap", (PyCFunction)pygimp_install_cmap, METH_NOARGS},
1685
{"min_colors", (PyCFunction)pygimp_min_colors, METH_NOARGS},
1686
{"gtkrc", (PyCFunction)pygimp_gtkrc, METH_NOARGS},
1687
{"personal_rc_file", (PyCFunction)pygimp_personal_rc_file, METH_VARARGS | METH_KEYWORDS},
1688
{"context_push", (PyCFunction)pygimp_context_push, METH_NOARGS},
1689
{"context_pop", (PyCFunction)pygimp_context_pop, METH_NOARGS},
1690
{"get_foreground", (PyCFunction)pygimp_get_foreground, METH_NOARGS},
1691
{"get_background", (PyCFunction)pygimp_get_background, METH_NOARGS},
1692
{"get_foreground", (PyCFunction)pygimp_get_foreground, METH_NOARGS},
1693
{"set_background", (PyCFunction)pygimp_set_background, METH_VARARGS},
1694
{"set_foreground", (PyCFunction)pygimp_set_foreground, METH_VARARGS},
1695
{"gradients_get_list", (PyCFunction)pygimp_gradients_get_list, METH_VARARGS | METH_KEYWORDS},
1696
{"context_get_gradient", (PyCFunction)pygimp_context_get_gradient, METH_NOARGS},
1697
{"context_set_gradient", (PyCFunction)pygimp_context_set_gradient, METH_VARARGS},
1698
{"gradients_get_gradient", (PyCFunction)pygimp_gradients_get_gradient, METH_NOARGS},
1699
{"gradients_set_gradient", (PyCFunction)pygimp_gradients_set_gradient, METH_VARARGS},
1700
{"gradient_get_uniform_samples", (PyCFunction)pygimp_gradient_get_uniform_samples, METH_VARARGS},
1701
{"gradient_get_custom_samples", (PyCFunction)pygimp_gradient_get_custom_samples, METH_VARARGS},
1702
{"gradients_sample_uniform", (PyCFunction)pygimp_gradients_sample_uniform, METH_VARARGS},
1703
{"gradients_sample_custom", (PyCFunction)pygimp_gradients_sample_custom, METH_VARARGS},
1151
1704
{"delete", (PyCFunction)pygimp_delete, METH_VARARGS},
1152
1705
{"displays_flush", (PyCFunction)pygimp_displays_flush, METH_NOARGS},
1706
{"displays_reconnect", (PyCFunction)pygimp_displays_reconnect, METH_VARARGS},
1153
1707
{"tile_cache_size", (PyCFunction)pygimp_tile_cache_size, METH_VARARGS},
1154
1708
{"tile_cache_ntiles", (PyCFunction)pygimp_tile_cache_ntiles, METH_VARARGS},
1155
1709
{"tile_width", (PyCFunction)pygimp_tile_width, METH_NOARGS},
1162
1716
{"attach_new_parasite",(PyCFunction)pygimp_attach_new_parasite,METH_VARARGS},
1163
1717
{"parasite_detach", (PyCFunction)pygimp_parasite_detach, METH_VARARGS},
1164
1718
{"parasite_list", (PyCFunction)pygimp_parasite_list, METH_NOARGS},
1719
{"show_tool_tips", (PyCFunction)pygimp_show_tool_tips, METH_NOARGS},
1720
{"show_help_button", (PyCFunction)pygimp_show_help_button, METH_NOARGS},
1721
{"check_size", (PyCFunction)pygimp_check_size, METH_NOARGS},
1722
{"check_type", (PyCFunction)pygimp_check_type, METH_NOARGS},
1165
1723
{"default_display", (PyCFunction)pygimp_default_display, METH_NOARGS},
1724
{"wm_class", (PyCFunction)pygimp_wm_class, METH_NOARGS},
1725
{"display_name", (PyCFunction)pygimp_display_name, METH_NOARGS},
1726
{"monitor_number", (PyCFunction)pygimp_monitor_number, METH_NOARGS},
1727
{"get_progname", (PyCFunction)pygimp_get_progname, METH_NOARGS},
1728
{"fonts_refresh", (PyCFunction)pygimp_fonts_refresh, METH_NOARGS},
1729
{"fonts_get_list", (PyCFunction)pygimp_fonts_get_list, METH_VARARGS | METH_KEYWORDS},
1730
{"checks_get_shades", (PyCFunction)pygimp_checks_get_shades, METH_VARARGS | METH_KEYWORDS},
1731
{"vectors_import_from_file", (PyCFunction)pygimp_vectors_import_from_file, METH_VARARGS | METH_KEYWORDS},
1732
{"vectors_import_from_string", (PyCFunction)pygimp_vectors_import_from_string, METH_VARARGS | METH_KEYWORDS},
1166
1733
{"_id2image", (PyCFunction)id2image, METH_VARARGS},
1167
1734
{"_id2drawable", (PyCFunction)id2drawable, METH_VARARGS},
1168
1735
{"_id2display", (PyCFunction)id2display, METH_VARARGS},
1169
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
1736
{"_id2vectors", (PyCFunction)id2vectors, METH_VARARGS},
1737
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
1741
static struct _PyGimp_Functions pygimp_api_functions = {
1744
&PyGimpDisplay_Type,
1746
&PyGimpDrawable_Type,
1747
pygimp_drawable_new,
1750
&PyGimpChannel_Type,
1752
&PyGimpVectors_Type,
1173
1757
/* Initialization function for the module (*must* be called initgimp) */
1175
static char gimp_module_documentation[] =
1759
static char gimp_module_documentation[] =
1176
1760
"This module provides interfaces to allow you to write gimp plugins"
1182
1766
PyObject *m, *d;
1186
1770
PyGimpPDB_Type.tp_alloc = PyType_GenericAlloc;
1187
1771
PyGimpPDB_Type.tp_new = PyType_GenericNew;
1188
1772
if (PyType_Ready(&PyGimpPDB_Type) < 0)
1191
1775
PyGimpPDBFunction_Type.ob_type = &PyType_Type;
1192
1776
PyGimpPDBFunction_Type.tp_alloc = PyType_GenericAlloc;
1193
1777
PyGimpPDBFunction_Type.tp_new = PyType_GenericNew;
1194
1778
if (PyType_Ready(&PyGimpPDBFunction_Type) < 0)
1197
1781
PyGimpImage_Type.ob_type = &PyType_Type;
1198
1782
PyGimpImage_Type.tp_alloc = PyType_GenericAlloc;
1199
1783
PyGimpImage_Type.tp_new = PyType_GenericNew;
1200
1784
if (PyType_Ready(&PyGimpImage_Type) < 0)
1203
1787
PyGimpDisplay_Type.ob_type = &PyType_Type;
1204
1788
PyGimpDisplay_Type.ob_type = &PyType_Type;
1205
1789
PyGimpDisplay_Type.tp_alloc = PyType_GenericAlloc;
1206
1790
PyGimpDisplay_Type.tp_new = PyType_GenericNew;
1207
1791
if (PyType_Ready(&PyGimpDisplay_Type) < 0)
1210
1794
PyGimpLayer_Type.ob_type = &PyType_Type;
1211
1795
PyGimpLayer_Type.tp_alloc = PyType_GenericAlloc;
1212
1796
PyGimpLayer_Type.tp_new = PyType_GenericNew;
1213
1797
if (PyType_Ready(&PyGimpLayer_Type) < 0)
1216
1800
PyGimpChannel_Type.ob_type = &PyType_Type;
1217
1801
PyGimpChannel_Type.tp_alloc = PyType_GenericAlloc;
1218
1802
PyGimpChannel_Type.tp_new = PyType_GenericNew;
1219
1803
if (PyType_Ready(&PyGimpChannel_Type) < 0)
1222
1806
PyGimpTile_Type.ob_type = &PyType_Type;
1223
1807
PyGimpTile_Type.tp_alloc = PyType_GenericAlloc;
1224
1808
PyGimpTile_Type.tp_new = PyType_GenericNew;
1225
1809
if (PyType_Ready(&PyGimpTile_Type) < 0)
1228
1812
PyGimpPixelRgn_Type.ob_type = &PyType_Type;
1229
1813
PyGimpPixelRgn_Type.tp_alloc = PyType_GenericAlloc;
1230
1814
PyGimpPixelRgn_Type.tp_new = PyType_GenericNew;
1231
1815
if (PyType_Ready(&PyGimpPixelRgn_Type) < 0)
1234
1818
PyGimpParasite_Type.ob_type = &PyType_Type;
1235
1819
PyGimpParasite_Type.tp_alloc = PyType_GenericAlloc;
1236
1820
PyGimpParasite_Type.tp_new = PyType_GenericNew;
1237
1821
if (PyType_Ready(&PyGimpParasite_Type) < 0)
1824
PyGimpVectorsStroke_Type.ob_type = &PyType_Type;
1825
PyGimpVectorsStroke_Type.tp_alloc = PyType_GenericAlloc;
1826
PyGimpVectorsStroke_Type.tp_new = PyType_GenericNew;
1827
if (PyType_Ready(&PyGimpVectorsStroke_Type) < 0)
1830
PyGimpVectorsBezierStroke_Type.ob_type = &PyType_Type;
1831
PyGimpVectorsBezierStroke_Type.tp_alloc = PyType_GenericAlloc;
1832
PyGimpVectorsBezierStroke_Type.tp_new = PyType_GenericNew;
1833
if (PyType_Ready(&PyGimpVectorsBezierStroke_Type) < 0)
1836
PyGimpVectors_Type.ob_type = &PyType_Type;
1837
PyGimpVectors_Type.tp_alloc = PyType_GenericAlloc;
1838
PyGimpVectors_Type.tp_new = PyType_GenericNew;
1839
if (PyType_Ready(&PyGimpVectors_Type) < 0)
1842
pygimp_init_pygobject();
1845
/* initialize i18n support */
1846
bindtextdomain (GETTEXT_PACKAGE "-python", gimp_locale_directory ());
1847
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
1848
bind_textdomain_codeset (GETTEXT_PACKAGE "-python", "UTF-8");
1851
/* set the default python encoding to utf-8 */
1852
PyUnicode_SetDefaultEncoding("utf-8");
1240
1854
/* Create the module and add the functions */
1241
1855
m = Py_InitModule4("gimp", gimp_methods,
1242
gimp_module_documentation,
1243
(PyObject*)NULL,PYTHON_API_VERSION);
1856
gimp_module_documentation,
1857
NULL, PYTHON_API_VERSION);
1245
1859
/* Add some symbolic constants to the module */
1246
1860
d = PyModule_GetDict(m);
1258
1872
PyDict_SetItemString(d, "Tile", (PyObject *)&PyGimpTile_Type);
1259
1873
PyDict_SetItemString(d, "PixelRgn", (PyObject *)&PyGimpPixelRgn_Type);
1260
1874
PyDict_SetItemString(d, "Parasite", (PyObject *)&PyGimpParasite_Type);
1875
PyDict_SetItemString(d, "VectorsBezierStroke", (PyObject *)&PyGimpVectorsBezierStroke_Type);
1876
PyDict_SetItemString(d, "Vectors", (PyObject *)&PyGimpVectors_Type);
1262
/* these are private, for use in gimpprocbrowser */
1263
PyDict_SetItemString(d, "_PDBFunction",
1264
(PyObject *)&PyGimpPDBFunction_Type);
1265
PyDict_SetItemString(d, "_pdb_function_new",
1266
PyCObject_FromVoidPtr(pygimp_pdb_function_new, NULL));
1878
/* for other modules */
1879
pygimp_api_functions.pygimp_error = pygimp_error;
1880
PyDict_SetItemString(d, "_PyGimp_API",
1881
i=PyCObject_FromVoidPtr(&pygimp_api_functions, NULL));
1268
1884
PyDict_SetItemString(d, "version",
1269
i=Py_BuildValue("(iii)",
1272
gimp_micro_version));
1885
i=Py_BuildValue("(iii)",
1888
gimp_micro_version));
1891
/* Some environment constants */
1892
PyDict_SetItemString(d, "directory",
1893
PyString_FromString(gimp_directory()));
1894
PyDict_SetItemString(d, "data_directory",
1895
PyString_FromString(gimp_data_directory()));
1896
PyDict_SetItemString(d, "locale_directory",
1897
PyString_FromString(gimp_locale_directory()));
1898
PyDict_SetItemString(d, "sysconf_directory",
1899
PyString_FromString(gimp_sysconf_directory()));
1900
PyDict_SetItemString(d, "plug_in_directory",
1901
PyString_FromString(gimp_plug_in_directory()));
1275
1903
/* Check for errors */
1276
1904
if (PyErr_Occurred())
1277
Py_FatalError("can't initialize module gimp");
1905
Py_FatalError("can't initialize module gimp");