[cairo-commit]
pycairo/cairo pycairo-private.h, 1.19, 1.20 pycairo.h,
1.26, 1.27 cairomodule.c, 1.29, 1.30 cairogtkmodule.c, 1.17,
1.18 pycairo-pattern.c, 1.16, 1.17 pycairo-matrix.c, 1.13,
1.14 pycairo-context.c, 1.45, 1.46 pycairo-surface.c, 1.33,
1.34 pycairo-font.c, 1.12, 1.13
Steve Chaplin
commit at pdx.freedesktop.org
Sun May 8 17:52:49 PDT 2005
- Previous message: [cairo-commit]
pycairo/examples/cairo_snippets snippets_png.py, 1.6,
1.7 snippets_pdf.py, 1.2, 1.3 snippets_gtk.py, 1.5, 1.6
- Next message: [cairo-commit] pycairo/examples/gtk cairo-demo.py, 1.3,
1.4 cairo-knockout.py, 1.4, 1.5 hangman.py, 1.4,
1.5 lsystem.py, 1.3, 1.4 png_view.py, 1.5, 1.6 text.py, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv27558/cairo
Modified Files:
pycairo-private.h pycairo.h cairomodule.c cairogtkmodule.c
pycairo-pattern.c pycairo-matrix.c pycairo-context.c
pycairo-surface.c pycairo-font.c
Log Message:
SC
Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- pycairo-private.h 6 May 2005 13:46:13 -0000 1.19
+++ pycairo-private.h 9 May 2005 00:52:46 -0000 1.20
@@ -55,7 +55,7 @@
int pycairo_check_status(cairo_status_t status);
/* takes ownership of reference */
-PyObject *PyCairoContext_FromContext(cairo_t *ctx);
+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 *PyCairoPattern_FromPattern(cairo_pattern_t *pattern);
Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- pycairo.h 6 May 2005 13:46:13 -0000 1.26
+++ pycairo.h 9 May 2005 00:52:46 -0000 1.27
@@ -50,6 +50,7 @@
typedef struct {
PyObject_HEAD
cairo_t *ctx;
+ PyObject *base; /* base object used to create context, or NULL */
} PyCairoContext;
typedef struct {
@@ -86,7 +87,7 @@
PyTypeObject *Surface_Type;
/* constructors */
- PyObject *(*Context_FromContext)(cairo_t *ctx);
+ PyObject *(*Context_FromContext)(cairo_t *ctx, PyObject *base);
PyObject *(*FontFace_FromFontFace)(cairo_font_face_t *font_face);
PyObject *(*Matrix_FromMatrix)(const cairo_matrix_t *matrix);
PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern);
Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- cairomodule.c 7 May 2005 04:28:06 -0000 1.29
+++ cairomodule.c 9 May 2005 00:52:46 -0000 1.30
@@ -99,10 +99,6 @@
}
-static PyMethodDef cairo_functions[] = {
- { NULL, NULL, 0 }
-};
-
/* C API. Clients get at this via PyCairo_IMPORT, defined in pycairo.h.
*/
static PyCairo_CAPI_t CAPI = {
@@ -142,7 +138,7 @@
if (PyType_Ready(&PyCairoPDFSurface_Type) < 0)
return;
- m = Py_InitModule("cairo._cairo", cairo_functions);
+ m = Py_InitModule("cairo._cairo", NULL);
Py_INCREF(&PyCairoContext_Type);
PyModule_AddObject(m, "Context", (PyObject *)&PyCairoContext_Type);
@@ -156,7 +152,8 @@
Py_INCREF(&PyCairoSurface_Type);
PyModule_AddObject(m, "Surface", (PyObject *)&PyCairoSurface_Type);
Py_INCREF(&PyCairoImageSurface_Type);
- PyModule_AddObject(m, "ImageSurface", (PyObject *)&PyCairoImageSurface_Type);
+ PyModule_AddObject(m, "ImageSurface",
+ (PyObject *)&PyCairoImageSurface_Type);
Py_INCREF(&PyCairoPDFSurface_Type);
PyModule_AddObject(m, "PDFSurface", (PyObject *)&PyCairoPDFSurface_Type);
@@ -216,5 +213,10 @@
CONSTANT(EXTEND_NONE);
CONSTANT(EXTEND_REPEAT);
CONSTANT(EXTEND_REFLECT);
+
+ CONSTANT(PATH_MOVE_TO);
+ CONSTANT(PATH_LINE_TO);
+ CONSTANT(PATH_CURVE_TO);
+ CONSTANT(PATH_CLOSE_PATH);
#undef CONSTANT
}
Index: cairogtkmodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cairogtkmodule.c 7 May 2005 04:28:06 -0000 1.17
+++ cairogtkmodule.c 9 May 2005 00:52:46 -0000 1.18
@@ -44,57 +44,6 @@
#define PyGdkDrawable_Type (*_PyGdkDrawable_Type)
static PyTypeObject *_PyGdkPixbuf_Type;
#define PyGdkPixbuf_Type (*_PyGdkPixbuf_Type)
-static PyTypeObject *_PyGdkPixmap_Type;
-#define PyGdkPixmap_Type (*_PyGdkPixmap_Type)
-static PyTypeObject *_PyGdkVisual_Type;
-#define PyGdkVisual_Type (*_PyGdkVisual_Type)
-static PyTypeObject *_PyGdkWindow_Type;
-#define PyGdkWindow_Type (*_PyGdkWindow_Type)
-
-static cairo_format_t
-_DEPTH_TO_CAIRO_FORMAT (gint depth)
-{
- switch (depth) {
- case 1:
- return CAIRO_FORMAT_A1;
- case 8:
- return CAIRO_FORMAT_A8;
- case 24:
- return CAIRO_FORMAT_RGB24;
- case 32:
- default:
- return CAIRO_FORMAT_ARGB32;
- }
-}
-
-static PyObject *
-surface_create_for_drawable(PyObject *self, PyObject *args)
-{
- PyObject *py_surface;
- PyGObject *py_drawable;
- GdkDrawable *gdk_drawable;
- cairo_format_t format = CAIRO_FORMAT_ARGB32;
- cairo_surface_t *surface;
-
- if (!PyArg_ParseTuple(args, "O!|i:surface_create_for_drawable",
- &PyGdkDrawable_Type, &py_drawable, &format))
- return NULL;
-
- gdk_drawable = GDK_DRAWABLE(py_drawable->obj);
- surface = cairo_xlib_surface_create /* deprecated */
- (GDK_DRAWABLE_XDISPLAY(gdk_drawable),
- GDK_DRAWABLE_XID(gdk_drawable),
- GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(gdk_drawable)),
- format,
- GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdk_drawable)));
- if (!surface)
- return PyErr_NoMemory();
-
- py_surface = PyCairoSurface_FromSurface(surface, (PyObject *)py_drawable);
- if (!py_surface)
- cairo_surface_destroy(surface);
- return py_surface;
-}
static PyObject *
surface_create_for_pixbuf(PyObject *self, PyObject *args)
@@ -136,136 +85,95 @@
return py_surface;
}
-static PyObject *
-surface_create_for_pixmap(PyObject *self, PyObject *args)
+/* copied from gtk+/gdk/gdkdraw.c and gdkdrawable-x11.c
+ * gdk_drawable_create_cairo_context() should be available in gtk 2.10
+ */
+static cairo_t *
+_gdk_drawable_create_cairo_context (GdkDrawable *drawable)
{
- PyObject *py_surface;
- PyGObject *py_pixmap;
- GdkDrawable *gdk_pixmap;
+ cairo_t *cr = NULL;
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);
- /* 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),
- _DEPTH_TO_CAIRO_FORMAT(gdk_drawable_get_depth(gdk_pixmap)));
- if (!surface)
- return PyErr_NoMemory();
-
- gdk_drawable_get_size (gdk_pixmap, &width, &height);
- cairo_xlib_surface_set_size (surface, width, height);
+ GdkVisual *visual;
+
+ visual = gdk_drawable_get_visual (drawable);
- py_surface = PyCairoSurface_FromSurface(surface, (PyObject *)py_pixmap);
- if (!py_surface)
+ if (GDK_IS_WINDOW (drawable))
+ surface = cairo_xlib_surface_create_for_window_with_visual (GDK_WINDOW_XDISPLAY (drawable),
+ GDK_WINDOW_XID (drawable),
+ GDK_VISUAL_XVISUAL (visual));
+ else if (visual)
+ surface = cairo_xlib_surface_create_for_pixmap_with_visual (GDK_PIXMAP_XDISPLAY (drawable),
+ GDK_PIXMAP_XID (drawable),
+ GDK_VISUAL_XVISUAL (visual));
+ else if (gdk_drawable_get_depth (drawable) == 1)
+ surface = cairo_xlib_surface_create_for_pixmap (GDK_PIXMAP_XDISPLAY (drawable),
+ GDK_PIXMAP_XID (drawable),
+ CAIRO_FORMAT_A1);
+ else
+ {
+ g_warning ("Using Cairo rendering requires the drawable argument to\n"
+ "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");
+ return NULL;
+ }
+ if (surface) {
+ cr = cairo_create (surface);
cairo_surface_destroy(surface);
- return py_surface;
+ }
+ return cr;
}
+/* gdk.Drawable.create_cairo_context() should be available in pygtk 2.10 */
static PyObject *
-surface_create_for_pixmap_with_visual(PyObject *self, PyObject *args)
+create_cairo_context(PyObject *self, PyObject *args)
{
- PyObject *py_surface;
- PyGObject *py_pixmap, *py_visual;
- GdkDrawable *gdk_pixmap;
- GdkVisual *gdk_visual;
- cairo_surface_t *surface;
- int width, height;
+ cairo_t *cr;
+ PyObject *c;
+ PyGObject *py_drawable;
- if (!PyArg_ParseTuple(args, "O!O!:surface_create_for_pixmap_with_visual",
- &PyGdkPixmap_Type, &py_pixmap,
- &PyGdkVisual_Type, &py_visual))
+ if (!PyArg_ParseTuple(args, "O!:create_cairo_context",
+ &PyGdkDrawable_Type, &py_drawable))
return NULL;
- gdk_pixmap = GDK_PIXMAP(py_pixmap->obj);
- gdk_visual = GDK_VISUAL(py_visual->obj);
-
- surface = cairo_xlib_surface_create_for_pixmap_with_visual
- (GDK_PIXMAP_XDISPLAY(gdk_pixmap),
- GDK_PIXMAP_XID(gdk_pixmap),
- GDK_VISUAL_XVISUAL(gdk_visual));
- if (!surface)
- return PyErr_NoMemory();
-
- gdk_drawable_get_size (gdk_pixmap, &width, &height);
- cairo_xlib_surface_set_size (surface, width, height);
-
- py_surface = PyCairoSurface_FromSurface(surface, (PyObject *)py_pixmap);
- if (!py_surface)
- cairo_surface_destroy(surface);
- return py_surface;
-}
-
-static PyObject *
-surface_create_for_window_with_visual(PyObject *self, PyObject *args)
-{
- PyObject *py_surface;
- PyGObject *py_window, *py_visual;
- 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,
- &PyGdkVisual_Type, &py_visual))
+ cr = _gdk_drawable_create_cairo_context (GDK_DRAWABLE(py_drawable->obj));
+ if (!cr) {
+ PyErr_SetString(PyExc_RuntimeError, "could not create context");
return NULL;
+ }
- gdk_window = GDK_WINDOW(py_window->obj);
- gdk_visual = GDK_VISUAL(py_visual->obj);
-
- surface = cairo_xlib_surface_create_for_window_with_visual
- (GDK_WINDOW_XDISPLAY(gdk_window),
- GDK_WINDOW_XID(gdk_window),
- GDK_VISUAL_XVISUAL(gdk_visual));
- if (!surface)
- return PyErr_NoMemory();
-
- gdk_drawable_get_size (gdk_window, &width, &height);
- cairo_xlib_surface_set_size (surface, width, height);
-
- py_surface = PyCairoSurface_FromSurface(surface, (PyObject *)py_window);
- if (!py_surface)
- cairo_surface_destroy(surface);
- return (PyObject *)py_surface;
+ c = PyCairoContext_FromContext(cr, (PyObject *)py_drawable);
+ if (!c)
+ cairo_destroy(cr);
+ return c;
}
+
static PyMethodDef cairogtk_functions[] = {
- { "surface_create_for_drawable", /* deprecated */
- (PyCFunction)surface_create_for_drawable, METH_VARARGS },
+ { "create_cairo_context", (PyCFunction)create_cairo_context,
+ METH_VARARGS },
{ "surface_create_for_pixbuf",
(PyCFunction)surface_create_for_pixbuf, METH_VARARGS },
- { "surface_create_for_pixmap",
- (PyCFunction)surface_create_for_pixmap, METH_VARARGS },
- { "surface_create_for_pixmap_with_visual",
- (PyCFunction)surface_create_for_pixmap_with_visual, METH_VARARGS },
- { "surface_create_for_window_with_visual",
- (PyCFunction)surface_create_for_window_with_visual, METH_VARARGS },
{ NULL, NULL, 0 }
};
DL_EXPORT(void)
initgtk(void)
{
- PyObject *mod;
-
- mod = Py_InitModule("cairo.gtk", cairogtk_functions);
+ PyObject *mod = Py_InitModule("cairo.gtk", cairogtk_functions);
+ if (!mod)
+ return;
PyCairo_IMPORT;
- init_pygtk();
+ /* strange way to access the pygtk C API, why not PyGTK_IMPORT ? */
+ init_pygtk();
mod = PyImport_ImportModule("gtk.gdk");
- _PyGdkDrawable_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "Drawable");
- _PyGdkPixbuf_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "Pixbuf");
- _PyGdkPixmap_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "Pixmap");
- _PyGdkVisual_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "Visual");
- _PyGdkWindow_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "Window");
+ if (!mod)
+ return;
+ _PyGdkDrawable_Type = (PyTypeObject *)PyObject_GetAttrString(mod,
+ "Drawable");
+ _PyGdkPixbuf_Type = (PyTypeObject *)PyObject_GetAttrString(mod,
+ "Pixbuf");
}
Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- pycairo-pattern.c 6 May 2005 13:46:13 -0000 1.16
+++ pycairo-pattern.c 9 May 2005 00:52:46 -0000 1.17
@@ -246,9 +246,11 @@
METH_VARARGS | METH_CLASS },
{ "create_radial", (PyCFunction)pattern_create_radial,
METH_VARARGS | METH_CLASS },
+ /* cairo_pattern_destroy() - never exposed in a language binding */
{ "set_extend", (PyCFunction)pattern_set_extend, METH_VARARGS },
{ "set_filter", (PyCFunction)pattern_set_filter, METH_VARARGS },
{ "set_matrix", (PyCFunction)pattern_set_matrix, METH_VARARGS },
+ /* cairo_pattern_reference() - never exposed in a language binding */
{ NULL, NULL, 0 }
};
@@ -280,7 +282,7 @@
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
"Pattern objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Index: pycairo-matrix.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-matrix.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pycairo-matrix.c 6 May 2005 13:46:13 -0000 1.13
+++ pycairo-matrix.c 9 May 2005 00:52:46 -0000 1.14
@@ -311,7 +311,7 @@
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
NULL, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- pycairo-context.c 7 May 2005 04:28:06 -0000 1.45
+++ pycairo-context.c 9 May 2005 00:52:46 -0000 1.46
@@ -40,15 +40,21 @@
/* PyCairoContext_FromContext
* Create a new PyCairoContext from a cairo_t
* Return value: New reference (NULL on failure)
+ *
+ * base - the base object used to create the context, or NULL.
+ * it is referenced to keep it alive while the context
+ * is being used
*/
PyObject *
-PyCairoContext_FromContext(cairo_t *ctx)
+PyCairoContext_FromContext(cairo_t *ctx, PyObject *base)
{
PyCairoContext *c = (PyCairoContext *)PyCairoContext_Type.tp_new
(&PyCairoContext_Type, NULL, NULL);
- if (c)
+ if (c) {
c->ctx = ctx;
-
+ Py_XINCREF(base);
+ c->base = base;
+ }
return (PyObject *) c;
}
@@ -62,6 +68,8 @@
cairo_destroy(c->ctx);
c->ctx = NULL;
}
+ Py_CLEAR(c->base);
+
c->ob_type->tp_free((PyObject *)c);
#ifdef DEBUG
printf("context_dealloc end\n");
@@ -145,6 +153,39 @@
}
static PyObject *
+pycairo_close_path(PyCairoContext *c)
+{
+ cairo_close_path(c->ctx);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_copy_page(PyCairoContext *c)
+{
+ cairo_copy_page(c->ctx);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_curve_to(PyCairoContext *c, PyObject *args)
+{
+ double x1, y1, x2, y2, x3, y3;
+
+ if (!PyArg_ParseTuple(args, "dddddd:Context.curve_to",
+ &x1, &y1, &x2, &y2, &x3, &y3))
+ return NULL;
+
+ cairo_curve_to(c->ctx, x1, y1, x2, y2, x3, y3);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
pycairo_device_to_user(PyCairoContext *c, PyObject *args)
{
double x, y;
@@ -293,15 +334,6 @@
}
static PyObject *
-pycairo_get_rgb_color(PyCairoContext *c)
-{
- double red, green, blue;
-
- cairo_get_rgb_color(c->ctx, &red, &green, &blue);
- return Py_BuildValue("(ddd)", red, green, blue);
-}
-
-static PyObject *
pycairo_get_source(PyCairoContext *c)
{
PyObject *p;
@@ -318,6 +350,22 @@
}
static PyObject *
+pycairo_get_target(PyCairoContext *c)
+{
+ PyObject *s;
+ cairo_surface_t *surface = cairo_get_target(c->ctx);
+ if (!surface) {
+ pycairo_check_status(cairo_status(c->ctx));
+ return NULL;
+ }
+
+ s = PyCairoSurface_FromSurface(surface, NULL);
+ if (s)
+ cairo_surface_reference(surface);
+ return s;
+}
+
+static PyObject *
pycairo_get_tolerance(PyCairoContext *c)
{
return PyFloat_FromDouble(cairo_get_tolerance(c->ctx));
@@ -365,6 +413,20 @@
}
static PyObject *
+pycairo_line_to(PyCairoContext *c, PyObject *args)
+{
+ double x, y;
+
+ if (!PyArg_ParseTuple(args, "dd:Context.line_to", &x, &y))
+ return NULL;
+
+ cairo_line_to(c->ctx, x, y);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
pycairo_mask(PyCairoContext *c, PyObject *args)
{
PyCairoPattern *p;
@@ -441,6 +503,64 @@
}
static PyObject *
+pycairo_rectangle(PyCairoContext *c, PyObject *args)
+{
+ double x, y, width, height;
+
+ if (!PyArg_ParseTuple(args, "dddd:Context.rectangle",
+ &x, &y, &width, &height))
+ return NULL;
+
+ cairo_rectangle(c->ctx, x, y, width, height);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_rel_curve_to(PyCairoContext *c, PyObject *args)
+{
+ double dx1, dy1, dx2, dy2, dx3, dy3;
+
+ if (!PyArg_ParseTuple(args, "dddddd:Context.rel_curve_to",
+ &dx1, &dy1, &dx2, &dy2, &dx3, &dy3))
+ return NULL;
+
+ cairo_rel_curve_to(c->ctx, dx1, dy1, dx2, dy2, dx3, dy3);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_rel_line_to(PyCairoContext *c, PyObject *args)
+{
+ double dx, dy;
+
+ if (!PyArg_ParseTuple(args, "dd:Context.rel_line_to", &dx, &dy))
+ return NULL;
+
+ cairo_rel_line_to(c->ctx, dx, dy);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_rel_move_to(PyCairoContext *c, PyObject *args)
+{
+ double dx, dy;
+
+ if (!PyArg_ParseTuple(args, "dd:Context.rel_move_to", &dx, &dy))
+ return NULL;
+
+ cairo_rel_move_to(c->ctx, dx, dy);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
pycairo_reset_clip(PyCairoContext *c)
{
cairo_reset_clip(c->ctx);
@@ -496,6 +616,23 @@
}
static PyObject *
+pycairo_select_font_face(PyCairoContext *c, PyObject *args)
+{
+ const char *family;
+ cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
+ cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
+
+ if (!PyArg_ParseTuple(args, "s|ii:Context.select_font_face",
+ &family, &slant, &weight))
+ return NULL;
+
+ cairo_select_font_face(c->ctx, family, slant, weight);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
pycairo_set_dash(PyCairoContext *c, PyObject *args)
{
double *dashes, offset = 0;
@@ -543,6 +680,51 @@
}
static PyObject *
+pycairo_set_font_matrix(PyCairoContext *c, PyObject *args)
+{
+ PyCairoMatrix *matrix;
+
+ if (!PyArg_ParseTuple(args, "O!:Context.set_font_matrix",
+ &PyCairoMatrix_Type, &matrix))
+ return NULL;
+
+ cairo_set_font_matrix(c->ctx, &matrix->matrix);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_set_font_size(PyCairoContext *c, PyObject *args)
+{
+ double size;
+
+ if (!PyArg_ParseTuple(args, "d:Context.set_font_size", &size))
+ return NULL;
+
+ cairo_set_font_size(c->ctx, size);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_set_font_face(PyCairoContext *c, PyObject *args)
+{
+ PyCairoFontFace *ff;
+ /* TODO: font_face or None (NULL) should be allowed */
+
+ if (!PyArg_ParseTuple(args, "O!:Context.set_font_face",
+ &PyCairoFontFace_Type, &ff))
+ return NULL;
+
+ cairo_set_font_face(c->ctx, ff->font_face);
+ if (pycairo_check_status(cairo_status(c->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
pycairo_set_line_cap(PyCairoContext *c, PyObject *args)
{
cairo_line_cap_t line_cap;
@@ -703,178 +885,23 @@
}
static PyObject *
-pycairo_stroke_extents(PyCairoContext *c)
-{
- double x1, y1, x2, y2;
- cairo_stroke_extents(c->ctx, &x1, &y1, &x2, &y2);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- return Py_BuildValue("(dddd)", x1, y1, x2, y2);
-}
-
-static PyObject *
-pycairo_text_path(PyCairoContext *c, PyObject *args)
-{
- const char *utf8;
-
- if (!PyArg_ParseTuple(args, "s:Context.text_path", &utf8))
- return NULL;
-
- cairo_text_path(c->ctx, utf8);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_translate(PyCairoContext *c, PyObject *args)
-{
- double tx, ty;
-
- if (!PyArg_ParseTuple(args, "dd:Context.translate", &tx, &ty))
- return NULL;
-
- cairo_translate(c->ctx, tx, ty);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_transform(PyCairoContext *c, PyObject *args)
-{
- PyCairoMatrix *matrix;
-
- if (!PyArg_ParseTuple(args, "O!:Context.transform",
- &PyCairoMatrix_Type, &matrix))
- return NULL;
-
- cairo_transform(c->ctx, &matrix->matrix);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_user_to_device_distance(PyCairoContext *c, PyObject *args)
-{
- double dx, dy;
-
- if (!PyArg_ParseTuple(args, "dd:Context.user_to_device_distance",
- &dx, &dy))
- return NULL;
-
- cairo_user_to_device_distance(c->ctx, &dx, &dy);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- return Py_BuildValue("(dd)", dx, dy);
-}
-
-static PyObject *
-pycairo_user_to_device(PyCairoContext *c, PyObject *args)
-{
- double x, y;
-
- if (!PyArg_ParseTuple(args, "dd:Context.user_to_device", &x, &y))
- return NULL;
-
- cairo_user_to_device(c->ctx, &x, &y);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- return Py_BuildValue("(dd)", x, y);
-}
-
-static PyObject *
-pycairo_line_to(PyCairoContext *c, PyObject *args)
-{
- double x, y;
-
- if (!PyArg_ParseTuple(args, "dd:Context.line_to", &x, &y))
- return NULL;
-
- cairo_line_to(c->ctx, x, y);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_curve_to(PyCairoContext *c, PyObject *args)
-{
- double x1, y1, x2, y2, x3, y3;
-
- if (!PyArg_ParseTuple(args, "dddddd:Context.curve_to",
- &x1, &y1, &x2, &y2, &x3, &y3))
- return NULL;
-
- cairo_curve_to(c->ctx, x1, y1, x2, y2, x3, y3);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_rel_move_to(PyCairoContext *c, PyObject *args)
-{
- double dx, dy;
-
- if (!PyArg_ParseTuple(args, "dd:Context.rel_move_to", &dx, &dy))
- return NULL;
-
- cairo_rel_move_to(c->ctx, dx, dy);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_rel_line_to(PyCairoContext *c, PyObject *args)
-{
- double dx, dy;
-
- if (!PyArg_ParseTuple(args, "dd:Context.rel_line_to", &dx, &dy))
- return NULL;
-
- cairo_rel_line_to(c->ctx, dx, dy);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_rel_curve_to(PyCairoContext *c, PyObject *args)
+pycairo_show_page(PyCairoContext *c)
{
- double dx1, dy1, dx2, dy2, dx3, dy3;
-
- if (!PyArg_ParseTuple(args, "dddddd:Context.rel_curve_to",
- &dx1, &dy1, &dx2, &dy2, &dx3, &dy3))
- return NULL;
-
- cairo_rel_curve_to(c->ctx, dx1, dy1, dx2, dy2, dx3, dy3);
+ cairo_show_page(c->ctx);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
Py_RETURN_NONE;
}
static PyObject *
-pycairo_rectangle(PyCairoContext *c, PyObject *args)
+pycairo_show_text(PyCairoContext *c, PyObject *args)
{
- double x, y, width, height;
-
- if (!PyArg_ParseTuple(args, "dddd:Context.rectangle",
- &x, &y, &width, &height))
- return NULL;
+ const char *utf8;
- cairo_rectangle(c->ctx, x, y, width, height);
- if (pycairo_check_status(cairo_status(c->ctx)))
+ if (!PyArg_ParseTuple(args, "s:Context.show_text", &utf8))
return NULL;
- Py_RETURN_NONE;
-}
-static PyObject *
-pycairo_close_path(PyCairoContext *c)
-{
- cairo_close_path(c->ctx);
+ cairo_show_text(c->ctx, utf8);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
Py_RETURN_NONE;
@@ -890,136 +917,125 @@
}
static PyObject *
-pycairo_stroke_preserve(PyCairoContext *c)
-{
- cairo_stroke_preserve(c->ctx);
- if (pycairo_check_status(cairo_status(c->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_copy_page(PyCairoContext *c)
+pycairo_stroke_extents(PyCairoContext *c)
{
- cairo_copy_page(c->ctx);
+ double x1, y1, x2, y2;
+ cairo_stroke_extents(c->ctx, &x1, &y1, &x2, &y2);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
- Py_RETURN_NONE;
+ return Py_BuildValue("(dddd)", x1, y1, x2, y2);
}
static PyObject *
-pycairo_show_page(PyCairoContext *c)
+pycairo_stroke_preserve(PyCairoContext *c)
{
- cairo_show_page(c->ctx);
+ cairo_stroke_preserve(c->ctx);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
Py_RETURN_NONE;
}
static PyObject *
-pycairo_select_font_face(PyCairoContext *c, PyObject *args)
+pycairo_text_extents(PyCairoContext *c, PyObject *args)
{
- const char *family;
- cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
- cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
+ const char *utf8;
+ cairo_text_extents_t extents;
- if (!PyArg_ParseTuple(args, "s|ii:Context.select_font_face",
- &family, &slant, &weight))
+ if (!PyArg_ParseTuple(args, "s:Context.text_extents", &utf8))
return NULL;
- cairo_select_font_face(c->ctx, family, slant, weight);
+ cairo_text_extents(c->ctx, utf8, &extents);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
- Py_RETURN_NONE;
+ return Py_BuildValue("(dddddd)", extents.x_bearing, extents.y_bearing,
+ extents.width, extents.height, extents.x_advance,
+ extents.y_advance);
}
static PyObject *
-pycairo_set_font_matrix(PyCairoContext *c, PyObject *args)
+pycairo_text_path(PyCairoContext *c, PyObject *args)
{
- PyCairoMatrix *matrix;
+ const char *utf8;
- if (!PyArg_ParseTuple(args, "O!:Context.set_font_matrix",
- &PyCairoMatrix_Type, &matrix))
+ if (!PyArg_ParseTuple(args, "s:Context.text_path", &utf8))
return NULL;
- cairo_set_font_matrix(c->ctx, &matrix->matrix);
+ cairo_text_path(c->ctx, utf8);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
Py_RETURN_NONE;
}
static PyObject *
-pycairo_set_font_size(PyCairoContext *c, PyObject *args)
+pycairo_translate(PyCairoContext *c, PyObject *args)
{
- double size;
+ double tx, ty;
- if (!PyArg_ParseTuple(args, "d:Context.set_font_size", &size))
+ if (!PyArg_ParseTuple(args, "dd:Context.translate", &tx, &ty))
return NULL;
- cairo_set_font_size(c->ctx, size);
+ cairo_translate(c->ctx, tx, ty);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
Py_RETURN_NONE;
}
static PyObject *
-pycairo_set_font_face(PyCairoContext *c, PyObject *args)
+pycairo_transform(PyCairoContext *c, PyObject *args)
{
- PyCairoFontFace *ff;
- /* TODO: font_face or None (NULL) should be allowed */
+ PyCairoMatrix *matrix;
- if (!PyArg_ParseTuple(args, "O!:Context.set_font_face",
- &PyCairoFontFace_Type, &ff))
+ if (!PyArg_ParseTuple(args, "O!:Context.transform",
+ &PyCairoMatrix_Type, &matrix))
return NULL;
- cairo_set_font_face(c->ctx, ff->font_face);
+ cairo_transform(c->ctx, &matrix->matrix);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
Py_RETURN_NONE;
}
static PyObject *
-pycairo_show_text(PyCairoContext *c, PyObject *args)
+pycairo_user_to_device(PyCairoContext *c, PyObject *args)
{
- const char *utf8;
+ double x, y;
- if (!PyArg_ParseTuple(args, "s:Context.show_text", &utf8))
+ if (!PyArg_ParseTuple(args, "dd:Context.user_to_device", &x, &y))
return NULL;
- cairo_show_text(c->ctx, utf8);
+ cairo_user_to_device(c->ctx, &x, &y);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
- Py_RETURN_NONE;
+ return Py_BuildValue("(dd)", x, y);
}
static PyObject *
-pycairo_text_extents(PyCairoContext *c, PyObject *args)
+pycairo_user_to_device_distance(PyCairoContext *c, PyObject *args)
{
- const char *utf8;
- cairo_text_extents_t extents;
+ double dx, dy;
- if (!PyArg_ParseTuple(args, "s:Context.text_extents", &utf8))
+ if (!PyArg_ParseTuple(args, "dd:Context.user_to_device_distance",
+ &dx, &dy))
return NULL;
- cairo_text_extents(c->ctx, utf8, &extents);
+ cairo_user_to_device_distance(c->ctx, &dx, &dy);
if (pycairo_check_status(cairo_status(c->ctx)))
return NULL;
- return Py_BuildValue("(dddddd)", extents.x_bearing, extents.y_bearing,
- extents.width, extents.height, extents.x_advance,
- extents.y_advance);
+ return Py_BuildValue("(dd)", dx, dy);
}
static PyMethodDef pycairo_methods[] = {
- /* append_path_data */
+ /* methods never exposed in a language binding:
+ * cairo_destroy()
+ * cairo_reference()
+ */
{ "arc", (PyCFunction)pycairo_arc, METH_VARARGS },
{ "arc_negative", (PyCFunction)pycairo_arc_negative, METH_VARARGS },
{ "clip", (PyCFunction)pycairo_clip, METH_NOARGS },
{ "clip_preserve", (PyCFunction)pycairo_clip_preserve, METH_NOARGS },
{ "close_path", (PyCFunction)pycairo_close_path, METH_NOARGS },
{ "copy_page", (PyCFunction)pycairo_copy_page, METH_NOARGS },
- /* copy_path_data */
- /* copy_path_data_flat */
{ "curve_to", (PyCFunction)pycairo_curve_to, METH_VARARGS },
{ "device_to_user",(PyCFunction)pycairo_device_to_user,METH_VARARGS },
{ "device_to_user_distance",
@@ -1065,7 +1081,6 @@
{ "set_source_rgba",(PyCFunction)pycairo_set_source_rgba,METH_VARARGS },
{ "set_source_surface",(PyCFunction)pycairo_set_source_surface,
METH_VARARGS },
- /* "set_target_image" */
{ "set_tolerance", (PyCFunction)pycairo_set_tolerance, METH_VARARGS },
/* show_glyphs */
{ "show_page", (PyCFunction)pycairo_show_page, METH_NOARGS },
@@ -1095,9 +1110,9 @@
{ "miter_limit", (getter)pycairo_get_miter_limit, (setter)0 },
{ "operator", (getter)pycairo_get_operator, (setter)0 },
{ "point", (getter)pycairo_get_current_point,(setter)0 },
- { "rgb_color", (getter)pycairo_get_rgb_color, (setter)0 },
{ "source", (getter)pycairo_get_source, (setter)0 },
{ "stroke_extents", (getter)pycairo_stroke_extents, (setter)0 },
+ { "target", (getter)pycairo_get_target, (setter)0 },
{ "tolerance", (getter)pycairo_get_tolerance, (setter)0 },
{ NULL, (getter)0, (setter)0 }
};
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- pycairo-surface.c 7 May 2005 04:28:06 -0000 1.33
+++ pycairo-surface.c 9 May 2005 00:52:46 -0000 1.34
@@ -59,8 +59,8 @@
(&PyCairoSurface_Type, NULL, NULL);
if (s) {
s->surface = surface;
- s->base = base;
Py_XINCREF(base);
+ s->base = base;
}
return (PyObject *) s;
}
@@ -166,6 +166,12 @@
static PyMethodDef surface_methods[] = {
+ /* methods never exposed in a language binding:
+ * cairo_surface_destroy()
+ * cairo_surface_reference()
+ * cairo_surface_get_user_data()
+ * cairo_surface_set_user_data()
+ */
{ "create_similar", (PyCFunction)surface_create_similar, METH_VARARGS },
{ "finish", (PyCFunction)surface_finish, METH_NOARGS },
{ "set_device_offset",(PyCFunction)surface_set_device_offset,
@@ -236,8 +242,8 @@
(&PyCairoImageSurface_Type, NULL, NULL);
if (s) {
s->surface = surface;
- s->base = base;
Py_XINCREF(base);
+ s->base = base;
}
return (PyObject *) s;
}
@@ -499,8 +505,8 @@
(&PyCairoPDFSurface_Type, NULL, NULL);
if (s) {
s->surface = surface;
- s->base = base;
Py_XINCREF(base);
+ s->base = base;
}
return (PyObject *) s;
}
@@ -540,8 +546,8 @@
PyErr_NoMemory();
return -1;
}
- s->base = file_object;
Py_INCREF(file_object);
+ s->base = file_object;
return 0;
}
Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pycairo-font.c 6 May 2005 13:46:13 -0000 1.12
+++ pycairo-font.c 9 May 2005 00:52:46 -0000 1.13
@@ -75,6 +75,12 @@
}
static PyMethodDef font_face_methods[] = {
+ /* methods never exposed in a language binding:
+ * cairo_font_face_destroy()
+ * cairo_font_face_reference()
+ * cairo_font_face_get_user_data()
+ * cairo_font_face_set_user_data(),
+ */
{ NULL, NULL, 0 }
};
- Previous message: [cairo-commit]
pycairo/examples/cairo_snippets snippets_png.py, 1.6,
1.7 snippets_pdf.py, 1.2, 1.3 snippets_gtk.py, 1.5, 1.6
- Next message: [cairo-commit] pycairo/examples/gtk cairo-demo.py, 1.3,
1.4 cairo-knockout.py, 1.4, 1.5 hangman.py, 1.4,
1.5 lsystem.py, 1.3, 1.4 png_view.py, 1.5, 1.6 text.py, 1.4, 1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list