[cairo-commit] pycairo/cairo cairogtkmodule.c, 1.24, 1.25 pycairo-private.h, 1.25, 1.26 cairomodule.c, 1.34, 1.35 pycairo-surface.c, 1.41, 1.42 pycairo-context.c, 1.54, 1.55 pycairo-pattern.c, 1.22, 1.23 pycairo-matrix.c, 1.19, 1.20 pycairo.h, 1.32, 1.33 pycairo-font.c, 1.20, 1.21

Steve Chaplin commit at pdx.freedesktop.org
Wed May 18 21:47:58 PDT 2005


Committed by: stevech1097

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

Modified Files:
	cairogtkmodule.c pycairo-private.h cairomodule.c 
	pycairo-surface.c pycairo-context.c pycairo-pattern.c 
	pycairo-matrix.c pycairo.h pycairo-font.c 
Log Message:
SC

Index: cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cairogtkmodule.c	17 May 2005 02:44:20 -0000	1.24
+++ cairogtkmodule.c	19 May 2005 04:47:56 -0000	1.25
@@ -94,19 +94,22 @@
 static cairo_t *
 _gdk_cairo_create (GdkDrawable *drawable)
 {
+    int width, height;
     cairo_t *cr = NULL;
     cairo_surface_t *surface = NULL;
     GdkVisual *visual = gdk_drawable_get_visual (drawable);
 
+    gdk_drawable_get_size (drawable, &width, &height);
     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 (GDK_DRAWABLE_XDISPLAY (drawable),
+					     GDK_DRAWABLE_XID (drawable),
+					     GDK_VISUAL_XVISUAL (visual),
+					     width, height);
     else if (gdk_drawable_get_depth (drawable) == 1)
-	surface = cairo_xlib_surface_create (GDK_PIXMAP_XDISPLAY (drawable),
-					     GDK_PIXMAP_XID (drawable),
-					     CAIRO_FORMAT_A1);
+	surface = cairo_xlib_surface_create_for_bitmap 
+	    (GDK_PIXMAP_XDISPLAY (drawable),
+	     GDK_PIXMAP_XID (drawable),
+	     width, height);
     else {
 	g_warning ("Using Cairo rendering requires the drawable argument to\n"
 		   "have a specified colormap. All windows have a colormap,\n"
@@ -117,11 +120,6 @@
 	return NULL;
     }
     if (surface) {
-	if (GDK_IS_PIXMAP (drawable)) {
-	    gint width, height;
-	    gdk_drawable_get_size (drawable, &width, &height);
-	    cairo_xlib_surface_set_size (surface, width, height);
-	}
 	cr = cairo_create (surface);
 	cairo_surface_destroy (surface);
     }

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- pycairo-private.h	17 May 2005 02:44:20 -0000	1.25
+++ pycairo-private.h	19 May 2005 04:47:56 -0000	1.26
@@ -41,6 +41,8 @@
 #include "pycairo.h"
 
 
+extern PyObject *CairoError;
+
 extern PyTypeObject PycairoContext_Type;
 extern PyTypeObject PycairoFontFace_Type;
 extern PyTypeObject PycairoMatrix_Type;
@@ -66,7 +68,7 @@
 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

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cairomodule.c	14 May 2005 01:26:31 -0000	1.34
+++ cairomodule.c	19 May 2005 04:47:56 -0000	1.35
@@ -35,8 +35,12 @@
 #endif
 #include "pycairo-private.h"
 
+
+/* A module specific exception */
+static PyObject *CairoError = NULL;
+
 int
-Pycairo_check_status(cairo_status_t status)
+Pycairo_Check_Status (cairo_status_t status)
 {
     /* copy strings from cairo.c cairo_status_string() */
     switch (status) {
@@ -46,53 +50,50 @@
 	PyErr_NoMemory();
 	return 1;
     case CAIRO_STATUS_INVALID_RESTORE:
-	PyErr_SetString(PyExc_RuntimeError, "Context.restore without "
-			"matching Context.save");
+	PyErr_SetString(CairoError, "Context.restore without matching "
+			"Context.save");
 	return 1;
     case CAIRO_STATUS_INVALID_POP_GROUP:
-	PyErr_SetString(PyExc_RuntimeError, "Context.pop_group without "
-			"matching Context.push_group");
+	PyErr_SetString(CairoError, "Context.pop_group without matching "
+			"Context.push_group");
 	return 1;
     case CAIRO_STATUS_NO_CURRENT_POINT:
-	PyErr_SetString(PyExc_ValueError, "no current point defined");
+	PyErr_SetString(CairoError, "no current point defined");
 	return 1;
     case CAIRO_STATUS_INVALID_MATRIX:
-	PyErr_SetString(PyExc_ValueError, "invalid matrix (not invertible)");
+	PyErr_SetString(CairoError, "invalid matrix (not invertible)");
 	return 1;
     case CAIRO_STATUS_NO_TARGET_SURFACE:
-	PyErr_SetString(PyExc_RuntimeError, "no target surface has been set");
+	PyErr_SetString(CairoError, "no target surface has been set");
 	return 1;
     case CAIRO_STATUS_NULL_POINTER:
-	PyErr_SetString(PyExc_RuntimeError, "NULL pointer");
+	PyErr_SetString(CairoError, "NULL pointer");
 	return 1;
     case CAIRO_STATUS_INVALID_STRING:
-	PyErr_SetString(PyExc_RuntimeError, "input string not valid UTF-8");
+	PyErr_SetString(CairoError, "input string not valid UTF-8");
 	return 1;
     case CAIRO_STATUS_INVALID_PATH_DATA:
-	PyErr_SetString(PyExc_RuntimeError, "invalid path data not valid");
+	PyErr_SetString(CairoError, "invalid path data not valid");
 	return 1;
     case CAIRO_STATUS_READ_ERROR:
-	PyErr_SetString(PyExc_RuntimeError, "error while reading from input "
-			"stream");
+	PyErr_SetString(CairoError, "error while reading from input stream");
 	return 1;
     case CAIRO_STATUS_WRITE_ERROR:
-	PyErr_SetString(PyExc_RuntimeError, "error while writing to output "
-			"stream");
+	PyErr_SetString(CairoError, "error while writing to output stream");
 	return 1;
     case CAIRO_STATUS_SURFACE_FINISHED:
-	PyErr_SetString(PyExc_RuntimeError, "the target surface has been "
-			"finished");
+	PyErr_SetString(CairoError, "the target surface has been finished");
 	return 1;
     case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
-	PyErr_SetString(PyExc_RuntimeError, "the surface type is not "
-			"appropriate for the operation");
+	PyErr_SetString(CairoError, "the surface type is not appropriate for "
+			"the operation");
 	return 1;
     case CAIRO_STATUS_BAD_NESTING:
-	PyErr_SetString(PyExc_RuntimeError, "drawing operations interleaved "
-			"for two contexts for the same surface");
+	PyErr_SetString(CairoError, "drawing operations interleaved for two "
+			"contexts for the same surface");
 	return 1;
     default:
-	PyErr_SetString(PyExc_RuntimeError, "<unknown error status>");
+	PyErr_SetString(CairoError, "<unknown error status>");
 	return 1;
     }
 }
@@ -123,7 +124,7 @@
     PycairoImageSurface_FromImageSurface,
     PycairoPDFSurface_FromPDFSurface,
 
-    Pycairo_check_status,
+    Pycairo_Check_Status,
 };
 
 DL_EXPORT(void)
@@ -178,6 +179,15 @@
 
     PyModule_AddObject(m, "pycairo_CAPI", PyCObject_FromVoidPtr(&CAPI, NULL));
 
+    /* Add 'cairo.Error' to the module */
+    if (CairoError == NULL) {
+	CairoError = PyErr_NewException("cairo.Error", NULL, NULL);
+	if (CairoError == NULL)
+	    return;
+    }
+    Py_INCREF(CairoError);
+    if (PyModule_AddObject(m, "Error", CairoError) < 0)
+	return;
 
     /* constants */
 #define CONSTANT(x) PyModule_AddIntConstant(m, #x, CAIRO_##x)

Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- pycairo-surface.c	17 May 2005 02:44:20 -0000	1.41
+++ pycairo-surface.c	19 May 2005 04:47:56 -0000	1.42
@@ -140,7 +140,7 @@
     cairo_status_t status = cairo_surface_finish(s->surface);
     Py_CLEAR(s->base);
 
-    if (Pycairo_check_status(status))
+    if (Pycairo_Check_Status(status))
 	return NULL;
     Py_RETURN_NONE;
 }
@@ -169,7 +169,7 @@
 	return NULL;
 
     status = cairo_surface_write_to_png(s->surface, filename);
-    if (Pycairo_check_status(status))
+    if (Pycairo_Check_Status(status))
 	return NULL;
     Py_RETURN_NONE;
 }
@@ -415,17 +415,18 @@
 #endif /* CAIRO_HAS_PNG_FUNCTIONS */
 
 static PyObject *
-image_surface_get_height(PycairoImageSurface *s)
+image_surface_get_height (PycairoImageSurface *o)
 {
-    return Py_BuildValue("i", cairo_image_surface_get_height(s->surface));
+    return Py_BuildValue("i", cairo_image_surface_get_height (o->surface));
 }
 
 static PyObject *
-image_surface_get_width(PycairoImageSurface *s)
+image_surface_get_width (PycairoImageSurface *o)
 {
-    return Py_BuildValue("i", cairo_image_surface_get_width(s->surface));
+    return Py_BuildValue("i", cairo_image_surface_get_width (o->surface));
 }
 
+
 static PyMethodDef image_surface_methods[] = {
 #ifdef HAVE_NUMPY
     {"create_for_array",(PyCFunction)image_surface_create_for_array, 
@@ -440,14 +441,11 @@
                                                    METH_VARARGS | METH_CLASS },
     /* create_from_png_stream */
 #endif
+    {"get_height",    (PyCFunction)image_surface_get_height,      METH_NOARGS},
+    {"get_width",     (PyCFunction)image_surface_get_width,       METH_NOARGS},
     {NULL, NULL, 0, NULL},
 };
 
-static PyGetSetDef image_surface_getsets[] = {
-    {"height", (getter)image_surface_get_height},
-    {"width",  (getter)image_surface_get_width},
-    {NULL, (getter)0, (setter)0, NULL, NULL},
-};
 
 PyTypeObject PycairoImageSurface_Type = {
     PyObject_HEAD_INIT(&PyType_Type)
@@ -480,7 +478,7 @@
     0,                                  /* tp_iternext */
     image_surface_methods,              /* tp_methods */
     0,                                  /* tp_members */
-    image_surface_getsets,              /* tp_getset */
+    0,                                  /* tp_getset */
     &PycairoSurface_Type,               /* tp_base */
     0,                                  /* tp_dict */
     0,                                  /* tp_descr_get */

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- pycairo-context.c	17 May 2005 02:44:20 -0000	1.54
+++ pycairo-context.c	19 May 2005 04:47:56 -0000	1.55
@@ -46,68 +46,67 @@
 PyObject *
 PycairoContext_FromContext(cairo_t *ctx, PyObject *base)
 {
-    PyObject *c;
+    PyObject *o;
 
     assert (ctx != NULL);
-    c = PycairoContext_Type.tp_alloc (&PycairoContext_Type, 0);
-    if (c) {
-	((PycairoContext *)c)->ctx = ctx;
+    o = PycairoContext_Type.tp_alloc (&PycairoContext_Type, 0);
[...1368 lines suppressed...]
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,/* tp_flags */
     0,                                  /* tp_doc */
     0,                                  /* tp_traverse */
     0,                                  /* tp_clear */
@@ -1181,13 +1177,13 @@
     0,                                  /* tp_iternext */
     pycairo_methods,                    /* tp_methods */
     0,                                  /* tp_members */
-    pycairo_getsets,                    /* tp_getset */
+    0,                                  /* tp_getset */
     &PyBaseObject_Type,                 /* tp_base */
     0,                                  /* tp_dict */
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)pycairo_init,             /* tp_init */
+    0,                                  /* tp_init */
     0,                                  /* tp_alloc */
     (newfunc)pycairo_new,               /* tp_new */
     0,                                  /* tp_free */

Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- pycairo-pattern.c	17 May 2005 01:36:57 -0000	1.22
+++ pycairo-pattern.c	19 May 2005 04:47:56 -0000	1.23
@@ -144,7 +144,7 @@
 
     status = cairo_pattern_add_color_stop_rgb (p->pattern, offset, red, green, 
 					       blue);
-    if (Pycairo_check_status(status))
+    if (Pycairo_Check_Status(status))
 	return NULL;
     Py_RETURN_NONE;
 }
@@ -161,7 +161,7 @@
 
     status = cairo_pattern_add_color_stop_rgba (p->pattern, offset, red, 
 						green, blue, alpha);
-    if (Pycairo_check_status(status))
+    if (Pycairo_Check_Status(status))
 	return NULL;
     Py_RETURN_NONE;
 }

Index: pycairo-matrix.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-matrix.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- pycairo-matrix.c	17 May 2005 01:36:57 -0000	1.19
+++ pycairo-matrix.c	19 May 2005 04:47:56 -0000	1.20
@@ -145,7 +145,7 @@
 static PyObject *
 matrix_invert(PycairoMatrix *m)
 {
-    if (Pycairo_check_status(cairo_matrix_invert(&m->matrix)))
+    if (Pycairo_Check_Status(cairo_matrix_invert(&m->matrix)))
 	return NULL;
     Py_RETURN_NONE;
 }

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- pycairo.h	17 May 2005 02:44:20 -0000	1.32
+++ pycairo.h	19 May 2005 04:47:56 -0000	1.33
@@ -135,7 +135,7 @@
 #define PycairoPDFSurface_FromPDFSurface \
         (Pycairo_CAPI->PDFSurface_FromPDFSurface)
 
-#define Pycairo_check_status         (Pycairo_CAPI->check_status)
+#define Pycairo_Check_Status         (Pycairo_CAPI->Pycheck_Check_Status)
 
 
 /* To access the Pycairo C API, edit the client module file to:

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- pycairo-font.c	18 May 2005 04:42:42 -0000	1.20
+++ pycairo-font.c	19 May 2005 04:47:56 -0000	1.21
@@ -216,7 +216,7 @@
 {
     cairo_font_extents_t e;
     cairo_status_t status = cairo_scaled_font_extents (o->scaled_font, &e);
-    if (Pycairo_check_status (status))
+    if (Pycairo_Check_Status (status))
 	return NULL;
     return Py_BuildValue ("(ddddd)", e.ascent, e.descent, e.height, 
 			  e.max_x_advance, e.max_y_advance);




More information about the cairo-commit mailing list