[cairo-commit] pycairo/cairo Makefile.am, 1.14, 1.15 pycairo-misc.h, 1.3, NONE pycairo-private.h, 1.24, 1.25 pycairosvg-private.h, 1.4, 1.5 pycairo-surface.c, 1.40, 1.41 pycairo.h, 1.31, 1.32 pycairo-font.c, 1.18, 1.19 pycairo-context.c, 1.53, 1.54 cairosvgmodule.c, 1.6, 1.7 cairogtkmodule.c, 1.23, 1.24

Steve Chaplin commit at pdx.freedesktop.org
Mon May 16 19:44:22 PDT 2005


Committed by: stevech1097

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

Modified Files:
	Makefile.am pycairo-private.h pycairosvg-private.h 
	pycairo-surface.c pycairo.h pycairo-font.c pycairo-context.c 
	cairosvgmodule.c cairogtkmodule.c 
Removed Files:
	pycairo-misc.h 
Log Message:
SC

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/Makefile.am,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Makefile.am	16 May 2005 01:04:34 -0000	1.14
+++ Makefile.am	17 May 2005 02:44:20 -0000	1.15
@@ -15,15 +15,13 @@
 _cairo_la_LIBADD = $(CAIRO_LIBS)
 _cairo_la_SOURCES = \
   pycairo.h \
+  pycairo-private.h \
   pycairo-context.c \
   pycairo-font.c \
   pycairo-matrix.c \
-  pycairo-misc.h \
   pycairo-path.c \
   pycairo-pattern.c \
-  pycairo-private.h \
   pycairo-surface.c \
-  pycairosvg-private.h \
   cairomodule.c
 
 if WITH_PYGTK

--- pycairo-misc.h DELETED ---

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- pycairo-private.h	14 May 2005 01:15:06 -0000	1.24
+++ pycairo-private.h	17 May 2005 02:44:20 -0000	1.25
@@ -39,7 +39,6 @@
 #include <Python.h>
 
 #include "pycairo.h"
-#include "pycairo-misc.h"
 
 
 extern PyTypeObject PycairoContext_Type;
@@ -53,17 +52,35 @@
 extern PyTypeObject PycairoImageSurface_Type;
 extern PyTypeObject PycairoPDFSurface_Type;
 
-PyObject *PycairoContext_FromContext(cairo_t *ctx, PyObject *base);
-PyObject *PycairoFontFace_FromFontFace(cairo_font_face_t *font_face);
-PyObject *PycairoMatrix_FromMatrix(const cairo_matrix_t *matrix);
-PyObject *PycairoPath_FromPath(cairo_path_t *path);
-PyObject *PycairoPattern_FromPattern(cairo_pattern_t *pattern);
-PyObject *PycairoScaledFont_FromScaledFont(cairo_scaled_font_t *scaled_font);
+PyObject *PycairoContext_FromContext (cairo_t *ctx, PyObject *base);
+PyObject *PycairoFontFace_FromFontFace (cairo_font_face_t *font_face);
+PyObject *PycairoMatrix_FromMatrix (const cairo_matrix_t *matrix);
+PyObject *PycairoPath_FromPath (cairo_path_t *path);
+PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern);
+PyObject *PycairoScaledFont_FromScaledFont (cairo_scaled_font_t *scaled_font);
 
-PyObject *PycairoSurface_FromSurface(cairo_surface_t *surface, PyObject *base);
-PyObject *PycairoImageSurface_FromImageSurface(cairo_surface_t *surface, PyObject *base);
-PyObject *PycairoPDFSurface_FromPDFSurface(cairo_surface_t *surface, PyObject *base);
+PyObject *PycairoSurface_FromSurface (cairo_surface_t *surface, 
+				      PyObject *base);
+PyObject *PycairoImageSurface_FromImageSurface (cairo_surface_t *surface, 
+						PyObject *base);
+PyObject *PycairoPDFSurface_FromPDFSurface (cairo_surface_t *surface, 
+					    PyObject *base);
 
-int       Pycairo_check_status(cairo_status_t status);
+int Pycairo_check_status (cairo_status_t status);
+
+/* useful macros from Python 2.4 */
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 4
+#  define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#  define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
+#  define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
+#  define Py_CLEAR(op)				\
+        do {                            	\
+                if (op) {			\
+                        PyObject *tmp = (PyObject *)(op);	\
+                        (op) = NULL;		\
+                        Py_DECREF(tmp);		\
+                }				\
+        } while (0)
+#endif /* PY_MAJOR_VERSION */
 
 #endif /* _PYCAIRO_PRIVATE_H_ */

Index: pycairosvg-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairosvg-private.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pycairosvg-private.h	14 May 2005 01:15:06 -0000	1.4
+++ pycairosvg-private.h	17 May 2005 02:44:20 -0000	1.5
@@ -39,8 +39,23 @@
 #include <Python.h> 
 
 #include "pycairosvg.h"
-#include "pycairo-misc.h"
+
 
 extern PyTypeObject PycairoSVGContext_Type;
 
+/* useful macros from Python 2.4 */
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 4
+#  define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#  define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
+#  define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
+#  define Py_CLEAR(op)				\
+        do {                            	\
+                if (op) {			\
+                        PyObject *tmp = (PyObject *)(op);	\
+                        (op) = NULL;		\
+                        Py_DECREF(tmp);		\
+                }				\
+        } while (0)
+#endif /* PY_MAJOR_VERSION */
+
 #endif  /* _PYCAIROSVG_PRIVATE_H_ */

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- pycairo-surface.c	17 May 2005 01:36:57 -0000	1.40
+++ pycairo-surface.c	17 May 2005 02:44:20 -0000	1.41
@@ -51,7 +51,7 @@
    static int load_numpy(void);
 #endif
 
-/* Class Surface ----------------------------------------------------------- */
+/* Class cairo.Surface ---------------------------------------------------- */
 
 /* PycairoSurface_FromSurface
  * Create a new PycairoSurface from a cairo_surface_t
@@ -241,7 +241,7 @@
 };
 
 
-/* Class ImageSurface ------------------------------------------------------ */
+/* Class cairo.ImageSurface ----------------------------------------------- */
 
 PyObject *
 PycairoImageSurface_FromImageSurface(cairo_surface_t *surface, PyObject *base)
@@ -495,7 +495,7 @@
 };
 
 
-/* Class PDFSurface ------------------------------------------------------ */
+/* Class class.PDFSurface ------------------------------------------------- */
 
 PyObject *
 PycairoPDFSurface_FromPDFSurface(cairo_surface_t *surface, PyObject *base)
@@ -515,12 +515,12 @@
 static int
 pdf_surface_init(PycairoSurface *s, PyObject *args, PyObject *kwds)
 {
-    PyObject *file_object;
+    const char *filename;
     double width, height;
     cairo_surface_t *surface;
 
-    if (!PyArg_ParseTuple(args, "O!dd:pdf_surface_create",
-			  &PyFile_Type, &file_object, &width, &height))
+    if (!PyArg_ParseTuple(args, "sdd:pdf_surface_create",
+			  &filename, &width, &height))
 	return -1;
     if (width <= 0) {
 	PyErr_SetString(PyExc_ValueError, "width must be positive");
@@ -530,18 +530,31 @@
 	PyErr_SetString(PyExc_ValueError, "height must be positive");
 	return -1;
     }
-    s->surface = cairo_pdf_surface_create(PyFile_AsFile(file_object), 
-					  width, height);
+    s->surface = cairo_pdf_surface_create (filename, width, height);
     if (!s->surface) {
 	Py_DECREF(s);
 	PyErr_NoMemory();
 	return -1;
     }
-    Py_INCREF(file_object);
-    s->base = file_object;
     return 0;
 }
 
+static PyObject *
+pdf_surface_set_dpi (PycairoPDFSurface *s, PyObject *args)
+{
+    double x_dpi, y_dpi;
+
+    if (!PyArg_ParseTuple(args, "dd:PDFSurface.set_dpi", &x_dpi, &y_dpi))
+	return NULL;
+    cairo_pdf_surface_set_dpi (s->surface, x_dpi, y_dpi);
+    Py_RETURN_NONE;
+}
+
+static PyMethodDef pdfsurface_methods[] = {
+    {"set_dpi", (PyCFunction)pdf_surface_set_dpi,    METH_VARARGS },
+    {NULL, NULL, 0, NULL},
+};
+
 PyTypeObject PycairoPDFSurface_Type = {
     PyObject_HEAD_INIT(&PyType_Type)
     0,                                  /* ob_size */
@@ -571,7 +584,7 @@
     0,                                  /* tp_weaklistoffset */
     0,                                  /* tp_iter */
     0,                                  /* tp_iternext */
-    0,                                  /* tp_methods */
+    pdfsurface_methods,                 /* tp_methods */
     0,                                  /* tp_members */
     0,                                  /* tp_getset */
     &PycairoSurface_Type,               /* tp_base */
@@ -588,7 +601,7 @@
 };
 
 
-/* Numeric routines -------------------------------------------------------- */
+/* Numeric routines ------------------------------------------------------- */
 
 #ifdef HAVE_NUMPY
 /* load the Numeric Python module

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- pycairo.h	14 May 2005 01:15:06 -0000	1.31
+++ pycairo.h	17 May 2005 02:44:20 -0000	1.32
@@ -99,8 +99,10 @@
     PyObject *(*ScaledFont_FromScaledFont)(cairo_scaled_font_t *scaled_font);
 
     PyObject *(*Surface_FromSurface)(cairo_surface_t *surface, PyObject *base);
-    PyObject *(*ImageSurface_FromImageSurface)(cairo_surface_t *surface, PyObject *base);
-    PyObject *(*PDFSurface_FromPDFSurface)(cairo_surface_t *surface, PyObject *base);
+    PyObject *(*ImageSurface_FromImageSurface)(cairo_surface_t *surface, 
+					       PyObject *base);
+    PyObject *(*PDFSurface_FromPDFSurface)(cairo_surface_t *surface, 
+					   PyObject *base);
 
     /* misc functions */
     int (* check_status)(cairo_status_t status);
@@ -124,19 +126,22 @@
 #define PycairoFontFace_FromFontFace (Pycairo_CAPI->Fontface_FromFontFace)
 #define PycairoMatrix_FromMatrix     (Pycairo_CAPI->Matrix_FromMatrix)
 #define PycairoPattern_FromPattern   (Pycairo_CAPI->Pattern_FromPattern)
-#define PycairoScaledFont_FromScaledFont (Pycairo_CAPI->ScaledFont_FromScaledFont)
+#define PycairoScaledFont_FromScaledFont \
+        (Pycairo_CAPI->ScaledFont_FromScaledFont)
 
 #define PycairoSurface_FromSurface   (Pycairo_CAPI->Surface_FromSurface)
-#define PycairoImageSurface_FromImageSurface (Pycairo_CAPI->ImageSurface_FromImageSurface)
-#define PycairoPDFSurface_FromPDFSurface     (Pycairo_CAPI->PDFSurface_FromPDFSurface)
+#define PycairoImageSurface_FromImageSurface \
+        (Pycairo_CAPI->ImageSurface_FromImageSurface)
+#define PycairoPDFSurface_FromPDFSurface \
+        (Pycairo_CAPI->PDFSurface_FromPDFSurface)
 
 #define Pycairo_check_status         (Pycairo_CAPI->check_status)
 
 
-/* To import the Pycairo C API, edit the client module file to:
- * 1) add 'Pycairo_IMPORT' to the init<module> function
- * 2) add the line below to define a global variable for the C API
+/* To access the Pycairo C API, edit the client module file to:
+ * 1) Add the following line to define a global variable for the C API
  *    static Pycairo_CAPI_t *Pycairo_CAPI;
+ * 2) Add 'Pycairo_IMPORT;' to the init<module> function
  */
 #define Pycairo_IMPORT \
         Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import("cairo", \

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- pycairo-font.c	17 May 2005 01:36:57 -0000	1.18
+++ pycairo-font.c	17 May 2005 02:44:20 -0000	1.19
@@ -36,7 +36,7 @@
 #include "pycairo-private.h"
 
 
-/* PycairoFontFace -------------------------------------------------------- */
+/* class cairo.FontFace --------------------------------------------------- */
 
 /* PycairoFontFace_FromFontFace
  * Create a new PycairoFontFace from a cairo_font_face_t
@@ -138,7 +138,7 @@
 };
 
 
-/* PycairoScaledFont ------------------------------------------------------ */
+/* class cairo.ScaledFont ------------------------------------------------- */
 
 /* PycairoScaledFont_FromScaledFont
  * Create a new PycairoScaledFont from a cairo_font_face_t

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- pycairo-context.c	17 May 2005 01:36:57 -0000	1.53
+++ pycairo-context.c	17 May 2005 02:44:20 -0000	1.54
@@ -663,7 +663,8 @@
 
     if (!PyArg_ParseTuple(args, "O|d:Context.set_dash", &py_dashes, &offset))
 	return NULL;
-    if (!(py_dashes = PySequence_Fast(py_dashes, "first argument must be a sequence")))
+    if (!(py_dashes = PySequence_Fast(py_dashes, 
+				      "first argument must be a sequence")))
 	return NULL;
 
     ndash = PySequence_Fast_GET_SIZE(py_dashes);

Index: cairosvgmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairosvgmodule.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cairosvgmodule.c	16 May 2005 01:05:28 -0000	1.6
+++ cairosvgmodule.c	17 May 2005 02:44:20 -0000	1.7
@@ -140,8 +140,10 @@
     if (!PyArg_ParseTuple(args, "t#:Context.parse_buffer", &buf, &count))
 	return NULL;
 
-    //svg_cairo_status_t svg_cairo_parse_buffer (svg_cairo_t *svg_cairo, const char *buf, size_t count);
-    if (Pycairosvg_check_status (svg_cairo_parse_buffer (self->ctx, buf, count)))
+    /*svg_cairo_status_t svg_cairo_parse_buffer (svg_cairo_t *svg_cairo, 
+      const char *buf, size_t count);*/
+    if (Pycairosvg_check_status (svg_cairo_parse_buffer (self->ctx, buf, 
+							 count)))
     	return NULL;
     Py_RETURN_NONE;
 }

Index: cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cairogtkmodule.c	17 May 2005 01:36:57 -0000	1.23
+++ cairogtkmodule.c	17 May 2005 02:44:20 -0000	1.24
@@ -99,9 +99,10 @@
     GdkVisual *visual = gdk_drawable_get_visual (drawable);
 
     if (visual) 
-	surface = cairo_xlib_surface_create_with_visual (GDK_DRAWABLE_XDISPLAY (drawable),
-							 GDK_DRAWABLE_XID (drawable),
-							 GDK_VISUAL_XVISUAL (visual));
+	surface = cairo_xlib_surface_create_with_visual 
+	    (GDK_DRAWABLE_XDISPLAY (drawable),
+	     GDK_DRAWABLE_XID (drawable),
+	     GDK_VISUAL_XVISUAL (visual));
     else if (gdk_drawable_get_depth (drawable) == 1)
 	surface = cairo_xlib_surface_create (GDK_PIXMAP_XDISPLAY (drawable),
 					     GDK_PIXMAP_XID (drawable),
@@ -111,7 +112,8 @@
 		   "have a specified colormap. All windows have a colormap,\n"
 		   "however, pixmaps only have colormap by default if they\n"
 		   "were created with a non-NULL window argument. Otherwise\n"
-		   "a colormap must be set on them with gdk_drawable_set_colormap");
+		   "a colormap must be set on them with "
+		   "gdk_drawable_set_colormap");
 	return NULL;
     }
     if (surface) {




More information about the cairo-commit mailing list