plug-ins/pygimp/gimpcolormodule.c plug-ins/pygimp/gimpenumsmodule.c

2007-05-28  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/gimpcolormodule.c
        * plug-ins/pygimp/gimpenumsmodule.c
        * plug-ins/pygimp/gimpmodule.c
        * plug-ins/pygimp/gimpthumbmodule.c
        * plug-ins/pygimp/gimpuimodule.c
        * plug-ins/pygimp/pygimp-drawable.c
        * plug-ins/pygimp/pygimp-image.c
        * plug-ins/pygimp/pygimp-pdb.c
        * plug-ins/pygimp/pygimp-tile.c: cleanups.

svn path=/trunk/; revision=22644
This commit is contained in:
Manish Singh 2007-05-28 22:26:22 +00:00 committed by Manish Singh
parent 91ca374788
commit 6f26979be4
10 changed files with 107 additions and 68 deletions

View File

@ -1,3 +1,15 @@
2007-05-28 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/gimpcolormodule.c
* plug-ins/pygimp/gimpenumsmodule.c
* plug-ins/pygimp/gimpmodule.c
* plug-ins/pygimp/gimpthumbmodule.c
* plug-ins/pygimp/gimpuimodule.c
* plug-ins/pygimp/pygimp-drawable.c
* plug-ins/pygimp/pygimp-image.c
* plug-ins/pygimp/pygimp-pdb.c
* plug-ins/pygimp/pygimp-tile.c: cleanups.
2007-05-28 Michael Natterer <mitch@gimp.org>
* app/base/tile-manager.c (tile_manager_get): allocate

View File

@ -129,11 +129,10 @@ pygimp_rgb_list_names(PyObject *self)
if (!color)
goto bail;
if (PyDict_SetItemString(dict, names[i], color) < 0)
{
Py_DECREF(color);
goto bail;
}
if (PyDict_SetItemString(dict, names[i], color) < 0) {
Py_DECREF(color);
goto bail;
}
Py_DECREF(color);
}
@ -366,11 +365,12 @@ static char gimpcolor_doc[] =
"This module provides interfaces to allow you to write gimp plugins"
;
void initgimpcolor(void);
PyMODINIT_FUNC
initgimpcolor(void)
{
PyObject *m, *d;
PyObject *i;
pygimp_init_pygobject();
@ -399,9 +399,9 @@ initgimpcolor(void)
PyFloat_FromDouble(GIMP_RGB_LUMINANCE_BLUE));
/* for other modules */
PyDict_SetItemString(d, "_PyGimpColor_API",
i=PyCObject_FromVoidPtr(&pygimpcolor_api_functions, NULL));
Py_DECREF(i);
PyModule_AddObject(m, "_PyGimpColor_API",
PyCObject_FromVoidPtr(&pygimpcolor_api_functions, NULL));
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module gimpcolor");

View File

@ -99,7 +99,9 @@ static char gimpenums_doc[] =
"This module provides interfaces to allow you to write gimp plugins"
;
DL_EXPORT(void)
void init_gimpenums(void);
PyMODINIT_FUNC
init_gimpenums(void)
{
PyObject *m;

View File

@ -799,6 +799,7 @@ static PyObject *
pygimp_context_push(PyObject *self)
{
gimp_context_push();
Py_INCREF(Py_None);
return Py_None;
}
@ -806,6 +807,7 @@ static PyObject *
pygimp_context_pop(PyObject *self)
{
gimp_context_pop();
Py_INCREF(Py_None);
return Py_None;
}
@ -1407,7 +1409,7 @@ pygimp_user_directory(PyObject *self, PyObject *args, PyObject *kwargs)
&py_type))
return NULL;
if (pyg_enum_get_value(GIMP_TYPE_USER_DIRECTORY, py_type, &type))
if (pyg_enum_get_value(GIMP_TYPE_USER_DIRECTORY, py_type, (gpointer)&type))
return NULL;
user_dir = gimp_user_directory(type);
@ -1791,11 +1793,12 @@ static char gimp_module_documentation[] =
"This module provides interfaces to allow you to write gimp plugins"
;
DL_EXPORT(void)
void initgimp(void);
PyMODINIT_FUNC
initgimp(void)
{
PyObject *m, *d;
PyObject *i;
PyObject *m;
PyGimpPDB_Type.ob_type = &PyType_Type;
PyGimpPDB_Type.tp_alloc = PyType_GenericAlloc;
@ -1888,48 +1891,65 @@ initgimp(void)
NULL, PYTHON_API_VERSION);
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
pygimp_error = PyErr_NewException("gimp.error", PyExc_RuntimeError, NULL);
PyDict_SetItemString(d, "error", pygimp_error);
PyModule_AddObject(m, "error", pygimp_error);
PyDict_SetItemString(d, "pdb", pygimp_pdb_new());
PyModule_AddObject(m, "pdb", pygimp_pdb_new());
/* export the types used in gimpmodule */
PyDict_SetItemString(d, "Image", (PyObject *)&PyGimpImage_Type);
PyDict_SetItemString(d, "Drawable", (PyObject *)&PyGimpDrawable_Type);
PyDict_SetItemString(d, "Layer", (PyObject *)&PyGimpLayer_Type);
PyDict_SetItemString(d, "Channel", (PyObject *)&PyGimpChannel_Type);
PyDict_SetItemString(d, "Display", (PyObject *)&PyGimpDisplay_Type);
PyDict_SetItemString(d, "Tile", (PyObject *)&PyGimpTile_Type);
PyDict_SetItemString(d, "PixelRgn", (PyObject *)&PyGimpPixelRgn_Type);
PyDict_SetItemString(d, "Parasite", (PyObject *)&PyGimpParasite_Type);
PyDict_SetItemString(d, "VectorsBezierStroke", (PyObject *)&PyGimpVectorsBezierStroke_Type);
PyDict_SetItemString(d, "Vectors", (PyObject *)&PyGimpVectors_Type);
Py_INCREF(&PyGimpImage_Type);
PyModule_AddObject(m, "Image", (PyObject *)&PyGimpImage_Type);
Py_INCREF(&PyGimpDrawable_Type);
PyModule_AddObject(m, "Drawable", (PyObject *)&PyGimpDrawable_Type);
Py_INCREF(&PyGimpLayer_Type);
PyModule_AddObject(m, "Layer", (PyObject *)&PyGimpLayer_Type);
Py_INCREF(&PyGimpChannel_Type);
PyModule_AddObject(m, "Channel", (PyObject *)&PyGimpChannel_Type);
Py_INCREF(&PyGimpDisplay_Type);
PyModule_AddObject(m, "Display", (PyObject *)&PyGimpDisplay_Type);
Py_INCREF(&PyGimpTile_Type);
PyModule_AddObject(m, "Tile", (PyObject *)&PyGimpTile_Type);
Py_INCREF(&PyGimpPixelRgn_Type);
PyModule_AddObject(m, "PixelRgn", (PyObject *)&PyGimpPixelRgn_Type);
Py_INCREF(&PyGimpParasite_Type);
PyModule_AddObject(m, "Parasite", (PyObject *)&PyGimpParasite_Type);
Py_INCREF(&PyGimpVectorsBezierStroke_Type);
PyModule_AddObject(m, "VectorsBezierStroke", (PyObject *)&PyGimpVectorsBezierStroke_Type);
Py_INCREF(&PyGimpVectors_Type);
PyModule_AddObject(m, "Vectors", (PyObject *)&PyGimpVectors_Type);
/* for other modules */
pygimp_api_functions.pygimp_error = pygimp_error;
PyDict_SetItemString(d, "_PyGimp_API",
i=PyCObject_FromVoidPtr(&pygimp_api_functions, NULL));
Py_DECREF(i);
PyDict_SetItemString(d, "version",
i=Py_BuildValue("(iii)",
gimp_major_version,
gimp_minor_version,
gimp_micro_version));
Py_DECREF(i);
PyModule_AddObject(m, "_PyGimp_API",
PyCObject_FromVoidPtr(&pygimp_api_functions, NULL));
PyModule_AddObject(m, "version",
Py_BuildValue("(iii)",
gimp_major_version,
gimp_minor_version,
gimp_micro_version));
/* Some environment constants */
PyDict_SetItemString(d, "directory",
PyString_FromString(gimp_directory()));
PyDict_SetItemString(d, "data_directory",
PyString_FromString(gimp_data_directory()));
PyDict_SetItemString(d, "locale_directory",
PyString_FromString(gimp_locale_directory()));
PyDict_SetItemString(d, "sysconf_directory",
PyString_FromString(gimp_sysconf_directory()));
PyDict_SetItemString(d, "plug_in_directory",
PyString_FromString(gimp_plug_in_directory()));
PyModule_AddObject(m, "directory",
PyString_FromString(gimp_directory()));
PyModule_AddObject(m, "data_directory",
PyString_FromString(gimp_data_directory()));
PyModule_AddObject(m, "locale_directory",
PyString_FromString(gimp_locale_directory()));
PyModule_AddObject(m, "sysconf_directory",
PyString_FromString(gimp_sysconf_directory()));
PyModule_AddObject(m, "plug_in_directory",
PyString_FromString(gimp_plug_in_directory()));
/* Check for errors */
if (PyErr_Occurred())

View File

@ -42,7 +42,9 @@ static char gimpthumb_doc[] =
"This module provides interfaces to allow you to write gimp plugins"
;
DL_EXPORT(void)
void initgimpthumb(void);
PyMODINIT_FUNC
initgimpthumb(void)
{
PyObject *m, *d;

View File

@ -44,7 +44,9 @@ static char gimpui_doc[] =
"This module provides interfaces to allow you to write gimp plugins"
;
DL_EXPORT(void)
void init_gimpui(void);
PyMODINIT_FUNC
init_gimpui(void)
{
PyObject *m, *d;

View File

@ -382,7 +382,7 @@ drw_set_pixel(PyGimpDrawable *self, PyObject *args)
is_string = TRUE;
num_channels = PyString_Size(seq);
pixel = PyString_AsString(seq);
pixel = (guint8 *)PyString_AsString(seq);
}
error = !gimp_drawable_set_pixel(self->ID, x, y, num_channels, pixel);

View File

@ -926,7 +926,7 @@ img_get_colormap(PyGimpImage *self, void *closure)
return NULL;
}
ret = PyString_FromStringAndSize(cmap, n_colours * 3);
ret = PyString_FromStringAndSize((char *)cmap, n_colours * 3);
g_free(cmap);
return ret;
@ -945,7 +945,7 @@ img_set_colormap(PyGimpImage *self, PyObject *value, void *closure)
return -1;
}
if (!gimp_image_set_colormap(self->ID, PyString_AsString(value),
if (!gimp_image_set_colormap(self->ID, (guchar *)PyString_AsString(value),
PyString_Size(value) / 3)) {
PyErr_Format(pygimp_error, "could not set colormap on image (ID %d)",
self->ID);

View File

@ -806,7 +806,7 @@ pf_call(PyGimpPDBFunction *self, PyObject *args, PyObject *kwargs)
return NULL;
}
if (pyg_enum_get_value(GIMP_TYPE_RUN_MODE, val, &run_mode))
if (pyg_enum_get_value(GIMP_TYPE_RUN_MODE, val, (gpointer)&run_mode))
return NULL;
} else if (len != 0) {
PyErr_SetString(PyExc_TypeError,

View File

@ -163,7 +163,8 @@ tile_subscript(PyGimpTile *self, PyObject *sub)
return NULL;
}
return PyString_FromStringAndSize(tile->data + bpp * x, bpp);
return PyString_FromStringAndSize
((char *)tile->data + bpp * x, bpp);
}
if (PyTuple_Check(sub)) {
@ -175,8 +176,8 @@ tile_subscript(PyGimpTile *self, PyObject *sub)
return NULL;
}
return PyString_FromStringAndSize(tile->data + bpp * (x +
y * tile->ewidth), bpp);
return PyString_FromStringAndSize
((char *)tile->data + bpp * (x + y * tile->ewidth), bpp);
}
PyErr_SetString(PyExc_TypeError, "tile subscript not int or 2-tuple");
@ -189,7 +190,7 @@ tile_ass_sub(PyGimpTile *self, PyObject *v, PyObject *w)
GimpTile *tile = self->tile;
int bpp = tile->bpp, i;
long x, y;
char *pix, *data;
guchar *pix, *data;
if (w == NULL) {
PyErr_SetString(PyExc_TypeError,
@ -202,7 +203,7 @@ tile_ass_sub(PyGimpTile *self, PyObject *v, PyObject *w)
return -1;
}
pix = PyString_AsString(w);
pix = (guchar *)PyString_AsString(w);
if (PyInt_Check(v)) {
x = PyInt_AsLong(v);
@ -385,7 +386,7 @@ pr_subscript(PyGimpPixelRgn *self, PyObject *key)
}
if (PyInt_Check(y)) {
char buf[MAX_BPP];
guchar buf[MAX_BPP];
y1 = PyInt_AsLong(y);
@ -396,7 +397,7 @@ pr_subscript(PyGimpPixelRgn *self, PyObject *key)
gimp_pixel_rgn_get_pixel(pr, buf, x1, y1);
return PyString_FromStringAndSize(buf, bpp);
return PyString_FromStringAndSize((char *)buf, bpp);
} else if (PySlice_Check(y))
if (PySlice_GetIndices((PySliceObject *)y,
pr->y + pr->h, &y1, &y2, &ys) ||
@ -405,12 +406,12 @@ pr_subscript(PyGimpPixelRgn *self, PyObject *key)
PyErr_SetString(PyExc_IndexError, "invalid y slice");
return NULL;
} else {
gchar *buf = g_new(gchar, bpp * (y2 - y1));
guchar *buf = g_new(guchar, bpp * (y2 - y1));
PyObject *ret;
if (y1 == 0) y1 = pr->y;
gimp_pixel_rgn_get_col(pr, buf, x1, y1, y2-y1);
ret = PyString_FromStringAndSize(buf, bpp * (y2 - y1));
ret = PyString_FromStringAndSize((char *)buf, bpp * (y2 - y1));
g_free(buf);
return ret;
}
@ -427,7 +428,7 @@ pr_subscript(PyGimpPixelRgn *self, PyObject *key)
}
if (x1 == 0) x1 = pr->x;
if (PyInt_Check(y)) {
char *buf;
guchar *buf;
PyObject *ret;
y1 = PyInt_AsLong(y);
@ -435,9 +436,9 @@ pr_subscript(PyGimpPixelRgn *self, PyObject *key)
PyErr_SetString(PyExc_IndexError, "y subscript out of range");
return NULL;
}
buf = g_new(gchar, bpp * (x2 - x1));
buf = g_new(guchar, bpp * (x2 - x1));
gimp_pixel_rgn_get_row(pr, buf, x1, y1, x2 - x1);
ret = PyString_FromStringAndSize(buf, bpp * (x2-x1));
ret = PyString_FromStringAndSize((char *)buf, bpp * (x2-x1));
g_free(buf);
return ret;
} else if (PySlice_Check(y))
@ -448,13 +449,13 @@ pr_subscript(PyGimpPixelRgn *self, PyObject *key)
PyErr_SetString(PyExc_IndexError, "invalid y slice");
return NULL;
} else {
gchar *buf = g_new(gchar, bpp * (x2 - x1) * (y2 - y1));
guchar *buf = g_new(guchar, bpp * (x2 - x1) * (y2 - y1));
PyObject *ret;
if (y1 == 0) y1 = pr->y;
gimp_pixel_rgn_get_rect(pr, buf, x1, y1,
x2 - x1, y2 - y1);
ret = PyString_FromStringAndSize(buf, bpp * (x2-x1) * (y2-y1));
ret = PyString_FromStringAndSize((char *)buf, bpp * (x2-x1) * (y2-y1));
g_free(buf);
return ret;
}
@ -474,7 +475,7 @@ pr_ass_sub(PyGimpPixelRgn *self, PyObject *v, PyObject *w)
GimpPixelRgn *pr = &(self->pr);
int bpp = pr->bpp;
PyObject *x, *y;
char *buf;
guchar *buf;
int len, x1, x2, xs, y1, y2, ys;
if (w == NULL) {
@ -495,7 +496,7 @@ pr_ass_sub(PyGimpPixelRgn *self, PyObject *v, PyObject *w)
if (!PyArg_ParseTuple(v, "OO", &x, &y))
return -1;
buf = PyString_AsString(w);
buf = (guchar *)PyString_AsString(w);
len = PyString_Size(w);
if (PyInt_Check(x)) {