[cairo-commit] pycairo/cairo cairomodule.c, 1.14, 1.15 cairogtkmodule.c, 1.12, 1.13 pycairo-font.c, 1.7, 1.8

Steve Chaplin commit at pdx.freedesktop.org
Fri Mar 18 20:51:41 PST 2005


Committed by: stevech1097

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

Modified Files:
	cairomodule.c cairogtkmodule.c pycairo-font.c 
Log Message:
SC 2005/03/19

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cairomodule.c	18 Mar 2005 12:04:35 -0000	1.14
+++ cairomodule.c	19 Mar 2005 04:51:39 -0000	1.15
@@ -39,6 +39,7 @@
 int
 pycairo_check_status(cairo_status_t status)
 {
+    /* copy strings from cairo.c cairo_status_string() */
     switch (status) {
     case CAIRO_STATUS_SUCCESS:
 	return 0;
@@ -66,10 +67,21 @@
 	PyErr_SetString(PyExc_RuntimeError, "NULL pointer");
 	return 1;
     case CAIRO_STATUS_INVALID_STRING:
-	PyErr_SetString(PyExc_RuntimeError, "invalid string");
+	PyErr_SetString(PyExc_RuntimeError, "input string not valid UTF-8");
+	return 1;
+    case CAIRO_STATUS_INVALID_PATH_DATA:
+	PyErr_SetString(PyExc_RuntimeError, "invalid path data not valid");
+	return 1;
+    case CAIRO_STATUS_WRITE_ERROR:
+	PyErr_SetString(PyExc_RuntimeError, "error while writing to output "
+			"stream");
+	return 1;
+    case CAIRO_STATUS_SURFACE_FINISHED:
+	PyErr_SetString(PyExc_RuntimeError, "the target surface has been "
+			"finished");
 	return 1;
     default:
-	PyErr_SetString(PyExc_RuntimeError, "other cairo error");
+	PyErr_SetString(PyExc_RuntimeError, "<unknown error status>");
 	return 1;
     }
 }

Index: cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairogtkmodule.c	18 Mar 2005 12:04:35 -0000	1.12
+++ cairogtkmodule.c	19 Mar 2005 04:51:39 -0000	1.13
@@ -136,14 +136,17 @@
     PyGObject *py_pixmap;
     GdkDrawable *gdk_pixmap;
     cairo_surface_t *surface;
+    int width, height;
 
     if (!PyArg_ParseTuple(args, "O!:surface_create_for_pixmap",
 			  &PyGdkPixmap_Type, &py_pixmap))
 	return NULL;
 
     gdk_pixmap = GDK_PIXMAP(py_pixmap->obj);
-    /* auto determine format by using gdk_drawable_get_depth() to read
-       Pixmap info from the GTK+ cache */
+    /* GTK+ caches gdk_pixmap info, so read cache for:
+     * depth - to determine cairo_format
+     * width, height - so can call surface_set_size()
+     */
     surface = cairo_xlib_surface_create_for_pixmap
 	(GDK_PIXMAP_XDISPLAY(gdk_pixmap),
 	 GDK_PIXMAP_XID(gdk_pixmap),
@@ -151,6 +154,9 @@
     if (!surface)
 	return PyErr_NoMemory();
 
+    gdk_drawable_get_size (gdk_pixmap, &width, &height);
+    cairo_xlib_surface_set_size (surface, width, height);
+
     return pycairo_surface_wrap(surface);
 }
 
@@ -161,6 +167,7 @@
     GdkDrawable *gdk_pixmap;
     GdkVisual *gdk_visual;
     cairo_surface_t *surface;
+    int width, height;
 
     if (!PyArg_ParseTuple(args, "O!O!:surface_create_for_pixmap_with_visual",
 			  &PyGdkPixmap_Type, &py_pixmap,
@@ -177,6 +184,9 @@
     if (!surface)
 	return PyErr_NoMemory();
 
+    gdk_drawable_get_size (gdk_pixmap, &width, &height);
+    cairo_xlib_surface_set_size (surface, width, height);
+
     return pycairo_surface_wrap(surface);
 }
 
@@ -187,6 +197,7 @@
     GdkVisual *gdk_visual;
     GdkWindow *gdk_window;
     cairo_surface_t *surface;
+    int width, height;
 
     if (!PyArg_ParseTuple(args, "O!O!:surface_create_for_window_with_visual",
 			  &PyGdkWindow_Type, &py_window,
@@ -203,6 +214,9 @@
     if (!surface)
 	return PyErr_NoMemory();
 
+    gdk_drawable_get_size (gdk_window, &width, &height);
+    cairo_xlib_surface_set_size (surface, width, height);
+
     return pycairo_surface_wrap(surface);
 }
 

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pycairo-font.c	10 Mar 2005 08:29:52 -0000	1.7
+++ pycairo-font.c	19 Mar 2005 04:51:39 -0000	1.8
@@ -69,16 +69,19 @@
 static PyObject *
 pycairo_font_extents(PyCairoFont *self, PyObject *args)
 {
-    PyCairoMatrix *matrix;
+    PyCairoMatrix *py_matrix;
     cairo_font_extents_t extents;
 
     if (!PyArg_ParseTuple(args, "O!:Font.extents",
-			  &PyCairoMatrix_Type, &matrix))
+			  &PyCairoMatrix_Type, &py_matrix))
 	return NULL;
 
-    if (pycairo_check_status(cairo_font_extents(self->font, matrix, &extents)))
+    if (pycairo_check_status(cairo_font_extents
+			     (self->font, py_matrix->matrix, &extents)))
 	return NULL;
-    return Py_BuildValue("(ddddd)", extents.ascent, extents.descent, extents.height, extents.max_x_advance, extents.max_y_advance);
+    return Py_BuildValue("(ddddd)", extents.ascent, extents.descent, 
+			 extents.height, extents.max_x_advance, 
+			 extents.max_y_advance);
 }
 
 




More information about the cairo-commit mailing list