[cairo-commit] pycairo/cairo pycairo-context.c,1.4,1.5

Carl Worth commit at pdx.freedesktop.org
Mon Nov 1 08:46:54 PST 2004


Committed by: cworth

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

Modified Files:
	pycairo-context.c 
Log Message:

        * cairo/pycairo-context.c (pycairo_set_target_ps)
        (pycairo_set_target_png, pycairo_copy_page, pycairo_show_page):
        Add missing functions. Thanks to Steve Chaplin
        <stevech1097 at yahoo.com.au>.


Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pycairo-context.c	29 Apr 2004 13:50:10 -0000	1.4
+++ pycairo-context.c	1 Nov 2004 16:46:52 -0000	1.5
@@ -112,6 +112,58 @@
 #endif
 
 static PyObject *
+pycairo_set_target_ps(PyCairoContext *self, PyObject *args)
+{
+    FILE *file;
+    char *filename;
+    double width_inches, height_inches;
+    double x_pixels_per_inch, y_pixels_per_inch;
+
+    if (!PyArg_ParseTuple(args, "sdddd:Context.set_target_ps",
+			  &filename, &width_inches, &height_inches, 
+			  &x_pixels_per_inch, &y_pixels_per_inch))
+	return NULL;
+
+    if ((file = fopen (filename, "w")) == NULL) {
+        PyErr_SetString(PyExc_IOError, "file open failed");
+	return NULL;
+	}
+
+    cairo_set_target_ps(self->ctx, file, width_inches, height_inches, 
+			x_pixels_per_inch, y_pixels_per_inch);
+    if (pycairo_check_status(cairo_status(self->ctx)))
+	return NULL;
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
+pycairo_set_target_png(PyCairoContext *self, PyObject *args)
+{
+    FILE *file;
+    char *filename;
+    cairo_format_t format;
+    int width, height;
+
+    if (!PyArg_ParseTuple(args, "siii:Context.set_target_png", 
+			  &filename, &format, &width, &height))
+	return NULL;
+
+    if ((file = fopen (filename, "w")) == NULL) {
+        PyErr_SetString(PyExc_IOError, "file open failed");
+	return NULL;
+	}
+
+    cairo_set_target_png(self->ctx, file, format, width, height);
+    if (pycairo_check_status(cairo_status(self->ctx)))
+	return NULL;
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
 pycairo_set_operator(PyCairoContext *self, PyObject *args)
 {
     cairo_operator_t op;
@@ -633,6 +685,26 @@
 }
 
 static PyObject *
+pycairo_copy_page(PyCairoContext *self)
+{
+    cairo_copy_page(self->ctx);
+    if (pycairo_check_status(cairo_status(self->ctx)))
+	return NULL;
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
+pycairo_show_page(PyCairoContext *self)
+{
+    cairo_show_page(self->ctx);
+    if (pycairo_check_status(cairo_status(self->ctx)))
+	return NULL;
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
 pycairo_clip(PyCairoContext *self)
 {
     cairo_clip(self->ctx);
@@ -765,6 +837,10 @@
     { "restore", (PyCFunction)pycairo_restore, METH_NOARGS },
     { "set_target_surface", (PyCFunction)pycairo_set_target_surface,
       METH_VARARGS },
+    { "set_target_ps", (PyCFunction)pycairo_set_target_ps,
+      METH_VARARGS},
+    { "set_target_png", (PyCFunction)pycairo_set_target_png,
+      METH_VARARGS },
     { "set_operator", (PyCFunction)pycairo_set_operator, METH_VARARGS },
     { "set_rgb_color", (PyCFunction)pycairo_set_rgb_color, METH_VARARGS },
     { "set_alpha", (PyCFunction)pycairo_set_alpha, METH_VARARGS },
@@ -803,6 +879,8 @@
     { "close_path", (PyCFunction)pycairo_close_path, METH_NOARGS },
     { "stroke", (PyCFunction)pycairo_stroke, METH_NOARGS },
     { "fill", (PyCFunction)pycairo_fill, METH_NOARGS },
+    { "copy_page", (PyCFunction)pycairo_show_page, METH_NOARGS },
+    { "show_page", (PyCFunction)pycairo_show_page, METH_NOARGS },
     { "clip", (PyCFunction)pycairo_clip, METH_NOARGS },
     { "select_font", (PyCFunction)pycairo_select_font, METH_VARARGS },
     { "scale_font", (PyCFunction)pycairo_scale_font, METH_VARARGS },




More information about the cairo-commit mailing list