diff options
author | Steve Chaplin <> | 2012-08-16 20:56:02 +0800 |
---|---|---|
committer | Steve Chaplin <> | 2012-08-16 20:56:02 +0800 |
commit | cd463341de185094455cf5869a442aa02b8b812e (patch) | |
tree | 2ec8356934959b99b7f9e2d6437742bcc019489c /src/surface.c | |
parent | cdec5e4c0a9ef4ad7b0413e4dc1e21f81841b064 (diff) | |
download | pycairo-cd463341de185094455cf5869a442aa02b8b812e.tar.gz |
Add new constants:
cairo.SVG_VERSION_1_1
cairo.SVG_VERSION_1_2
Add new functions:
cairo_svg_surface_restrict_to_version ()
cairo_svg_version_to_string ()
Diffstat (limited to 'src/surface.c')
-rw-r--r-- | src/surface.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/surface.c b/src/surface.c index 1589a70..204af68 100644 --- a/src/surface.c +++ b/src/surface.c @@ -799,7 +799,7 @@ static PyMethodDef pdf_surface_methods[] = { {"restrict_to_version", (PyCFunction)pdf_surface_restrict_to_version, METH_VARARGS }, {"set_size", (PyCFunction)pdf_surface_set_size, METH_VARARGS }, - /* pdf_get_levels - not implemented yet */ + /* pdf_get_versions - not implemented yet */ {"pdf_version_to_string", (PyCFunction)pdf_surface_pdf_version_to_string, METH_VARARGS | METH_STATIC}, {NULL, NULL, 0, NULL}, @@ -1199,13 +1199,39 @@ svg_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds) { return PycairoSurface_FromSurface (sfc, obj); } +static PyObject * +svg_surface_restrict_to_version (PycairoSVGSurface *o, PyObject *args) { + int version; + + if (!PyArg_ParseTuple(args, "i:SVGSurface.restrict_to_version", &version)) + return NULL; + cairo_svg_surface_restrict_to_version (o->surface, version); + RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface); + Py_RETURN_NONE; +} + +/* METH_STATIC */ +static PyObject * +svg_surface_svg_version_to_string (PyObject *self, PyObject *args) { + int version; + if (!PyArg_ParseTuple(args, "i:svg_version_to_string", &version)) + return NULL; + const char *s = cairo_svg_version_to_string (version); + if (s == NULL){ + PyErr_SetString(CairoError, "svg_version_to_string: " + "invalid level argument"); + return NULL; + } + return PyUnicode_DecodeASCII(s, strlen(s), NULL); +} + static PyMethodDef svg_surface_methods[] = { - /* TODO - * cairo_svg_surface_restrict_to_version - * cairo_svg_get_versions - * cairo_svg_version_to_string - */ - {NULL, NULL, 0, NULL}, + {"restrict_to_version", (PyCFunction)svg_surface_restrict_to_version, + METH_VARARGS }, + /* svg_get_versions - not implemented yet */ + {"svg_version_to_string", (PyCFunction)svg_surface_svg_version_to_string, + METH_VARARGS | METH_STATIC}, + {NULL, NULL, 0, NULL}, }; PyTypeObject PycairoSVGSurface_Type = { |