[cairo-commit] pycairo/cairo cairomodule.c,1.10,1.11

Steve Chaplin commit at pdx.freedesktop.org
Tue Jan 11 19:45:06 PST 2005


Committed by: stevech1097

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

Modified Files:
	cairomodule.c 
Log Message:
SC 2005/01/12

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cairomodule.c	10 Dec 2004 13:03:35 -0000	1.10
+++ cairomodule.c	12 Jan 2005 03:45:04 -0000	1.11
@@ -156,6 +156,41 @@
 }
 #endif /* CAIRO_HAS_PS_SURFACE */
 
+#ifdef CAIRO_HAS_PDF_SURFACE
+static PyObject *
+pycairo_pdf_surface_create(PyObject *self, PyObject *args)
+{
+    PyObject *file_object;
+    int width_inches, height_inches, x_pixels_per_inch, y_pixels_per_inch;
+    cairo_surface_t *surface;
+
+    if (!PyArg_ParseTuple(args, "O!iiii:pdf_surface_create",
+			  &PyFile_Type, &file_object, &width_inches, &height_inches, &x_pixels_per_inch, &y_pixels_per_inch))
+	return NULL;
+    if (width_inches <= 0) {
+	PyErr_SetString(PyExc_ValueError, "width_inches must be positive");
+	return NULL;
+    }
+    if (height_inches <= 0) {
+	PyErr_SetString(PyExc_ValueError, "height_inches must be positive");
+	return NULL;
+    }
+    if (x_pixels_per_inch <= 0) {
+	PyErr_SetString(PyExc_ValueError, "x_pixels_per_inch must be positive");
+	return NULL;
+    }
+    if (y_pixels_per_inch <= 0) {
+	PyErr_SetString(PyExc_ValueError, "y_pixels_per_inch must be positive");
+	return NULL;
+    }
+    surface = cairo_pdf_surface_create(PyFile_AsFile(file_object), width_inches, height_inches, x_pixels_per_inch, y_pixels_per_inch);
+    if (!surface)
+	return PyErr_NoMemory();
+
+    return pycairo_surface_wrap(surface);
+}
+#endif /* CAIRO_HAS_PDF_SURFACE */
+
 #ifdef CAIRO_HAS_PNG_SURFACE
 static PyObject *
 pycairo_png_surface_create(PyObject *self, PyObject *args)
@@ -188,18 +223,18 @@
 
 
 static PyMethodDef cairo_functions[] = {
-    /* this is the old function name, should use image_surface_create_for_data */
-    { "surface_create_for_image", (PyCFunction)pycairo_image_surface_create_for_data, METH_VARARGS, "this is the old function name, should use image_surface_create_for_data" },
     { "image_surface_create_for_data", (PyCFunction)pycairo_image_surface_create_for_data, METH_VARARGS, "" },
-
-#ifdef CAIRO_HAS_PS_SURFACE
-    { "ps_surface_create", (PyCFunction)pycairo_ps_surface_create, METH_VARARGS, "" },
+#ifdef CAIRO_HAS_PDF_SURFACE
+    { "pdf_surface_create", (PyCFunction)pycairo_pdf_surface_create, METH_VARARGS, "" },
 #endif
-
 #ifdef CAIRO_HAS_PNG_SURFACE
     { "png_surface_create", (PyCFunction)pycairo_png_surface_create, METH_VARARGS, "" },
 #endif
-
+#ifdef CAIRO_HAS_PS_SURFACE
+    { "ps_surface_create", (PyCFunction)pycairo_ps_surface_create, METH_VARARGS, "" },
+#endif
+    /* this is the old function name, should use image_surface_create_for_data */
+    { "surface_create_for_image", (PyCFunction)pycairo_image_surface_create_for_data, METH_VARARGS, "this is the old function name, should use image_surface_create_for_data" },
     { NULL, NULL, 0 }
 };
 




More information about the cairo-commit mailing list