Index: ChangeLog =================================================================== RCS file: /cvs/cairo/pycairo/ChangeLog,v retrieving revision 1.128 diff -u -p -d -r1.128 ChangeLog --- ChangeLog 30 May 2005 04:27:01 -0000 1.128 +++ ChangeLog 31 May 2005 21:01:03 -0000 @@ -1,3 +1,12 @@ +2005-05-31 Gustavo J. A. M. Carneiro + + * cairo/cairogtkmodule.c (pygdk_cairo_create): Update to new + PycairoContext_FromContext API. + + * cairo/pycairo-private.h, cairo/pycairo.h, cairo/pycairo-context.c + (PycairoContext_FromContext): Add a third parameter that allows + instantiation of a subclass of cairo.Context. + 2005-05-30 Steve Chaplin * cairo/cairomodule.c : add cairo features cairo.HAS_WIN32_SURFACE, Index: cairo/cairogtkmodule.c =================================================================== RCS file: /cvs/cairo/pycairo/cairo/cairogtkmodule.c,v retrieving revision 1.26 diff -u -p -d -r1.26 cairogtkmodule.c --- cairo/cairogtkmodule.c 27 May 2005 03:02:50 -0000 1.26 +++ cairo/cairogtkmodule.c 31 May 2005 21:01:03 -0000 @@ -144,7 +144,7 @@ pygdk_cairo_create(PyObject *self, PyObj PyErr_SetString(PyExc_RuntimeError, "could not create context"); return NULL; } - return PycairoContext_FromContext (cr, (PyObject *)py_drawable); + return PycairoContext_FromContext (cr, (PyObject *)py_drawable, NULL); } static PyMethodDef cairogtk_functions[] = { Index: cairo/pycairo-context.c =================================================================== RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v retrieving revision 1.56 diff -u -p -d -r1.56 pycairo-context.c --- cairo/pycairo-context.c 25 May 2005 11:07:13 -0000 1.56 +++ cairo/pycairo-context.c 31 May 2005 21:01:03 -0000 @@ -41,15 +41,20 @@ * it is unreferenced if the PycairoContext creation fails * base - the base object used to create the context, or NULL. * it is referenced to keep it alive while the cairo_t is being used + * type - the type of the object to instantiate; it can be NULL, + * meaning a base cairo.Context type, or it can be a subclass of + * cairo.Context. * Return value: New reference or NULL on failure */ PyObject * -PycairoContext_FromContext(cairo_t *ctx, PyObject *base) +PycairoContext_FromContext(cairo_t *ctx, PyObject *base, PyTypeObject *type) { PyObject *o; assert (ctx != NULL); - o = PycairoContext_Type.tp_alloc (&PycairoContext_Type, 0); + if (type == NULL) + type = &PycairoContext_Type; + o = PycairoContext_Type.tp_alloc (type, 0); if (o) { ((PycairoContext *)o)->ctx = ctx; Py_XINCREF(base); Index: cairo/pycairo-private.h =================================================================== RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v retrieving revision 1.29 diff -u -p -d -r1.29 pycairo-private.h --- cairo/pycairo-private.h 30 May 2005 04:27:01 -0000 1.29 +++ cairo/pycairo-private.h 31 May 2005 21:01:04 -0000 @@ -44,7 +44,7 @@ extern PyObject *CairoError; extern PyTypeObject PycairoContext_Type; -PyObject *PycairoContext_FromContext (cairo_t *ctx, PyObject *base); +PyObject *PycairoContext_FromContext (cairo_t *ctx, PyObject *base, PyTypeObject *type); extern PyTypeObject PycairoFontFace_Type; PyObject *PycairoFontFace_FromFontFace (cairo_font_face_t *font_face); Index: cairo/pycairo.h =================================================================== RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v retrieving revision 1.37 diff -u -p -d -r1.37 pycairo.h --- cairo/pycairo.h 30 May 2005 04:27:01 -0000 1.37 +++ cairo/pycairo.h 31 May 2005 21:01:04 -0000 @@ -82,7 +82,7 @@ typedef struct { typedef struct { /* (type object, constructor) pairs */ PyTypeObject *Context_Type; - PyObject *(*Context_FromContext)(cairo_t *ctx, PyObject *base); + PyObject *(*Context_FromContext)(cairo_t *ctx, PyObject *base, PyTypeObject *type); PyTypeObject *FontFace_Type; PyObject *(*FontFace_FromFontFace)(cairo_font_face_t *font_face); PyTypeObject *Matrix_Type;