[cairo-commit] pycairo/cairo Makefile.am, 1.3, 1.4 pycairo-context.c, 1.5, 1.6

Carl Worth commit at pdx.freedesktop.org
Tue Nov 2 17:24:08 PST 2004


Committed by: cworth

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

Modified Files:
	Makefile.am pycairo-context.c 
Log Message:

        * examples/spiral.py:
        * examples/hering.py: New examples from Steve Chaplin to
        demonstrate PNG and PS output.

        * cairo/pycairo-context.c (pycairo_set_target_ps)
        (pycairo_set_target_png): Fixes from Steve Chaplin.
        (pycairo_set_pattern): Disable set_pattern as this wrapper is
        currently broken.
        (pycairo_methods): Fix binding of copy_page.

        * cairo/Makefile.am (gtk_la_LIBADD): Add CAIRO_LIBS which was
        mistakenly dropped in a recent change.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.am	1 Nov 2004 16:29:45 -0000	1.3
+++ Makefile.am	3 Nov 2004 01:24:05 -0000	1.4
@@ -23,7 +23,7 @@
 pycairoexec_LTLIBRARIES += gtk.la
 endif
 gtk_la_LDFLAGS = -module -avoid-version -export-symbols-regex initgtk
-gtk_la_LIBADD = $(CAIRO_GTK_LIBS)
+gtk_la_LIBADD = $(CAIRO_LIBS) $(CAIRO_GTK_LIBS)
 gtk_la_SOURCES = \
   cairogtkmodule.c
 

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pycairo-context.c	1 Nov 2004 16:46:52 -0000	1.5
+++ pycairo-context.c	3 Nov 2004 01:24:05 -0000	1.6
@@ -114,22 +114,18 @@
 static PyObject *
 pycairo_set_target_ps(PyCairoContext *self, PyObject *args)
 {
-    FILE *file;
-    char *filename;
+    PyObject *file_object;
     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, 
+    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_ps",
+			  &PyFile_Type, &file_object,
+			  &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, 
+    cairo_set_target_ps(self->ctx, PyFile_AsFile(file_object),
+			width_inches, height_inches, 
 			x_pixels_per_inch, y_pixels_per_inch);
     if (pycairo_check_status(cairo_status(self->ctx)))
 	return NULL;
@@ -141,21 +137,17 @@
 static PyObject *
 pycairo_set_target_png(PyCairoContext *self, PyObject *args)
 {
-    FILE *file;
-    char *filename;
+    PyObject *file_object;
     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");
+    if (!PyArg_ParseTuple(args, "O!iii:Context.set_target_png", 
+			  &PyFile_Type, &file_object, &format, &width, 
+			  &height))
 	return NULL;
-	}
 
-    cairo_set_target_png(self->ctx, file, format, width, height);
+    cairo_set_target_png(self->ctx, PyFile_AsFile(file_object), format, 
+			 width, height);
     if (pycairo_check_status(cairo_status(self->ctx)))
 	return NULL;
 
@@ -209,12 +201,19 @@
     return Py_None;
 }
 
+/* XXX: Looks like this function has not been ported from the old
+ * cairo_surface_t* version of cairo_set_pattern to the new
+ * cairo_pattern_t* version. I don't know enough about python bindings
+ * to fix it, but I do know the current version won't work, so out it
+ * goes.
+ */
+#if 0
 static PyObject *
 pycairo_set_pattern(PyCairoContext *self, PyObject *args)
 {
     PyCairoSurface *surface;
 
-    if (!PyArg_ParseTuple(args, "O!:Context.set_patter",
+    if (!PyArg_ParseTuple(args, "O!:Context.set_pattern",
 			  &PyCairoSurface_Type, &surface))
 	return NULL;
 
@@ -224,6 +223,7 @@
     Py_INCREF(Py_None);
     return Py_None;
 }
+#endif
 
 static PyObject *
 pycairo_set_tolerance(PyCairoContext *self, PyObject *args)
@@ -844,7 +844,10 @@
     { "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 },
+/* XXX: set_pattern is currently broken. See above. */
+#if 0
     { "set_pattern", (PyCFunction)pycairo_set_pattern, METH_VARARGS },
+#endif
     { "set_tolerance", (PyCFunction)pycairo_set_tolerance, METH_VARARGS },
     { "set_fill_rule", (PyCFunction)pycairo_set_fill_rule, METH_VARARGS },
     { "set_line_width", (PyCFunction)pycairo_set_line_width, METH_VARARGS },
@@ -879,7 +882,7 @@
     { "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 },
+    { "copy_page", (PyCFunction)pycairo_copy_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 },




More information about the cairo-commit mailing list