[cairo-commit] pycairo/cairo cairomodule.c, 1.49, 1.50 pycairo.h, 1.42, 1.43 pycairo-private.h, 1.33, 1.34 pycairo-surface.c, 1.60, 1.61

Steve Chaplin commit at pdx.freedesktop.org
Tue Dec 13 20:47:04 PST 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv11259/cairo

Modified Files:
	cairomodule.c pycairo.h pycairo-private.h pycairo-surface.c 
Log Message:
'SC'

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- cairomodule.c	29 Aug 2005 14:52:30 -0000	1.49
+++ cairomodule.c	14 Dec 2005 04:47:02 -0000	1.50
@@ -101,6 +101,11 @@
 #else
     0,
 #endif
+#ifdef CAIRO_HAS_SVG_SURFACE
+    &PycairoSVGSurface_Type,
+#else
+    0,
+#endif
 #ifdef CAIRO_HAS_WIN32_SURFACE
     &PycairoWin32Surface_Type,
 #else
@@ -191,6 +196,11 @@
     if (PyType_Ready(&PycairoPSSurface_Type) < 0)
         return;
 #endif
+#ifdef CAIRO_HAS_SVG_SURFACE
+    PycairoSVGSurface_Type.tp_base = &PycairoSurface_Type;
+    if (PyType_Ready(&PycairoSVGSurface_Type) < 0)
+        return;
+#endif
 #ifdef CAIRO_HAS_WIN32_SURFACE
     PycairoWin32Surface_Type.tp_base = &PycairoSurface_Type;
     if (PyType_Ready(&PycairoWin32Surface_Type) < 0)
@@ -247,6 +257,11 @@
     PyModule_AddObject(m, "PSSurface", (PyObject *)&PycairoPSSurface_Type);
 #endif
 
+#ifdef CAIRO_HAS_SVG_SURFACE
+    Py_INCREF(&PycairoSVGSurface_Type);
+    PyModule_AddObject(m, "SVGSurface", (PyObject *)&PycairoSVGSurface_Type);
+#endif
+
 #ifdef CAIRO_HAS_WIN32_SURFACE
     Py_INCREF(&PycairoWin32Surface_Type);
     PyModule_AddObject(m, "Win32Surface",
@@ -286,15 +301,20 @@
 #else
     PyModule_AddIntConstant(m, "HAS_PDF_SURFACE", 0);
 #endif
+#if CAIRO_HAS_PNG_FUNCTIONS
+    PyModule_AddIntConstant(m, "HAS_PNG_FUNCTIONS", 1);
+#else
+    PyModule_AddIntConstant(m, "HAS_PNG_FUNCTIONS", 0);
+#endif
 #if CAIRO_HAS_PS_SURFACE
     PyModule_AddIntConstant(m, "HAS_PS_SURFACE", 1);
 #else
     PyModule_AddIntConstant(m, "HAS_PS_SURFACE", 0);
 #endif
-#if CAIRO_HAS_PNG_FUNCTIONS
-    PyModule_AddIntConstant(m, "HAS_PNG_FUNCTIONS", 1);
+#if CAIRO_HAS_SVG_SURFACE
+    PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 1);
 #else
-    PyModule_AddIntConstant(m, "HAS_PNG_FUNCTIONS", 0);
+    PyModule_AddIntConstant(m, "HAS_SVG_SURFACE", 0);
 #endif
 #if CAIRO_HAS_QUARTZ_SURFACE
     PyModule_AddIntConstant(m, "HAS_QUARTZ_SURFACE", 1);

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- pycairo.h	29 Aug 2005 14:52:30 -0000	1.42
+++ pycairo.h	14 Dec 2005 04:47:02 -0000	1.43
@@ -87,6 +87,7 @@
 #define PycairoImageSurface PycairoSurface
 #define PycairoPDFSurface   PycairoSurface
 #define PycairoPSSurface    PycairoSurface
+#define PycairoSVGSurface   PycairoSurface
 #define PycairoWin32Surface PycairoSurface
 
 /* get C object out of the Python wrapper */
@@ -171,6 +172,10 @@
 #define PycairoPSSurface_Type       *(Pycairo_CAPI->PSSurface_Type)
 #endif
 
+#if CAIRO_HAS_SVG_SURFACE
+#define PycairoSVGSurface_Type      *(Pycairo_CAPI->SVGSurface_Type)
+#endif
+
 #if CAIRO_HAS_WIN32_SURFACE
 #define PycairoWin32Surface_Type    *(Pycairo_CAPI->Win32Surface_Type)
 #endif

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- pycairo-private.h	29 Aug 2005 14:52:30 -0000	1.33
+++ pycairo-private.h	14 Dec 2005 04:47:02 -0000	1.34
@@ -81,6 +81,10 @@
 extern PyTypeObject PycairoPSSurface_Type;
 #endif
 
+#if CAIRO_HAS_SVG_SURFACE
+extern PyTypeObject PycairoSVGSurface_Type;
+#endif
+
 #if CAIRO_HAS_WIN32_SURFACE
 extern PyTypeObject PycairoWin32Surface_Type;
 #endif

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- pycairo-surface.c	17 Oct 2005 02:31:31 -0000	1.60
+++ pycairo-surface.c	14 Dec 2005 04:47:02 -0000	1.61
@@ -694,7 +694,7 @@
     Py_RETURN_NONE;
 }
 
-static PyMethodDef pdfsurface_methods[] = {
+static PyMethodDef pdf_surface_methods[] = {
     {"set_dpi", (PyCFunction)pdf_surface_set_dpi,    METH_VARARGS },
     {NULL, NULL, 0, NULL},
 };
@@ -728,7 +728,7 @@
     0,                                  /* tp_weaklistoffset */
     0,                                  /* tp_iter */
     0,                                  /* tp_iternext */
-    pdfsurface_methods,                 /* tp_methods */
+    pdf_surface_methods,                /* tp_methods */
     0,                                  /* tp_members */
     0,                                  /* tp_getset */
     0, /* &PycairoSurface_Type, */      /* tp_base */
@@ -787,7 +787,7 @@
     Py_RETURN_NONE;
 }
 
-static PyMethodDef pssurface_methods[] = {
+static PyMethodDef ps_surface_methods[] = {
     {"set_dpi", (PyCFunction)ps_surface_set_dpi,    METH_VARARGS },
     {NULL, NULL, 0, NULL},
 };
@@ -821,7 +821,7 @@
     0,                                  /* tp_weaklistoffset */
     0,                                  /* tp_iter */
     0,                                  /* tp_iternext */
-    pssurface_methods,                  /* tp_methods */
+    ps_surface_methods,                 /* tp_methods */
     0,                                  /* tp_members */
     0,                                  /* tp_getset */
     0, /* &PycairoSurface_Type, */      /* tp_base */
@@ -839,6 +839,99 @@
 #endif  /* CAIRO_HAS_PS_SURFACE */
 
 
+/* Class SVGSurface(Surface) ----------------------------------------------- */
+#ifdef CAIRO_HAS_SVG_SURFACE
+#include <cairo-svg.h>
+
+static PyObject *
+svg_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    const char *filename;
+    double width_in_points, height_in_points;
+    cairo_surface_t *surface;
+    PyObject *o;
+
+    if (!PyArg_ParseTuple(args, "sdd:SVGSurface.__new__",
+			  &filename, &width_in_points, &height_in_points))
+	return NULL;
+
+    o = type->tp_alloc(type, 0);
+    if (o) {
+	surface = cairo_svg_surface_create (filename, width_in_points,
+					    height_in_points);
+	if (Pycairo_Check_Status (cairo_surface_status (surface))) {
+	    cairo_surface_destroy (surface);
+	    Py_DECREF(o);
+	    return NULL;
+	}
+	((PycairoSVGSurface *)o)->surface = surface;
+    }
+    return o;
+}
+
+static PyObject *
+svg_surface_set_dpi (PycairoSVGSurface *o, PyObject *args)
+{
+    double x_dpi, y_dpi;
+
+    if (!PyArg_ParseTuple(args, "dd:SVGSurface.set_dpi", &x_dpi, &y_dpi))
+	return NULL;
+    cairo_svg_surface_set_dpi (o->surface, x_dpi, y_dpi);
+    Py_RETURN_NONE;
+}
+
+static PyMethodDef svg_surface_methods[] = {
+    {"set_dpi", (PyCFunction)svg_surface_set_dpi,    METH_VARARGS },
+    {NULL, NULL, 0, NULL},
+};
+
+PyTypeObject PycairoSVGSurface_Type = {
+    PyObject_HEAD_INIT(NULL)
+    0,                                  /* ob_size */
+    "cairo.SVGSurface",                  /* tp_name */
+    sizeof(PycairoSVGSurface),           /* tp_basicsize */
+    0,                                  /* tp_itemsize */
+    0,                                  /* tp_dealloc */
+    0,                                  /* tp_print */
+    0,                                  /* tp_getattr */
+    0,                                  /* tp_setattr */
+    0,                                  /* tp_compare */
+    0,                                  /* tp_repr */
+    0,                                  /* tp_as_number */
+    0,                                  /* tp_as_sequence */
+    0,                                  /* tp_as_mapping */
+    0,                                  /* tp_hash */
+    0,                                  /* tp_call */
+    0,                                  /* tp_str */
+    0,                                  /* tp_getattro */
+    0,                                  /* tp_setattro */
+    0,                                  /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
+    0,                                  /* tp_doc */
+    0,                                  /* tp_traverse */
+    0,                                  /* tp_clear */
+    0,                                  /* tp_richcompare */
+    0,                                  /* tp_weaklistoffset */
+    0,                                  /* tp_iter */
+    0,                                  /* tp_iternext */
+    svg_surface_methods,                /* tp_methods */
+    0,                                  /* tp_members */
+    0,                                  /* tp_getset */
+    0, /* &PycairoSurface_Type, */      /* tp_base */
+    0,                                  /* tp_dict */
+    0,                                  /* tp_descr_get */
+    0,                                  /* tp_descr_set */
+    0,                                  /* tp_dictoffset */
+    0,                                  /* tp_init */
+    0,                                  /* tp_alloc */
+    (newfunc)svg_surface_new,           /* tp_new */
+    0,                                  /* tp_free */
+    0,                                  /* tp_is_gc */
+    0,                                  /* tp_bases */
+};
+#endif  /* CAIRO_HAS_SVG_SURFACE */
+
+
 /* Class Win32Surface(Surface) -------------------------------------------- */
 #if CAIRO_HAS_WIN32_SURFACE
 #include <cairo-win32.h>
@@ -861,12 +954,12 @@
 	    Py_DECREF(o);
 	    return NULL;
 	}
-	((PycairoPSSurface *)o)->surface = surface;
+	((PycairoWin32Surface *)o)->surface = surface;
     }
     return o;
 }
 
-static PyMethodDef win32surface_methods[] = {
+static PyMethodDef win32_surface_methods[] = {
     {NULL, NULL, 0, NULL},
 };
 
@@ -899,7 +992,7 @@
     0,                                  /* tp_weaklistoffset */
     0,                                  /* tp_iter */
     0,                                  /* tp_iternext */
-    win32surface_methods,               /* tp_methods */
+    win32_surface_methods,              /* tp_methods */
     0,                                  /* tp_members */
     0,                                  /* tp_getset */
     0, /* &PycairoSurface_Type, */      /* tp_base */



More information about the cairo-commit mailing list