[pygtk] Re: Passing cairo_t and cairo_matrix_t as signals/properties

Robert Gibbs gibbsrc at gmail.com
Wed Mar 22 09:46:01 WST 2006


I'll answer my own question:

In the xxxmodule.c init function, the get/set functions need to be
registered as follows

pyg_register_boxed_custom(CR_TYPE_MATRIX,
                              crmatrix_from_value,
                              crmatrix_to_value);

Then provide get/set functions

static PyObject *
crmatrix_from_value(const GValue *value)
{
    cairo_matrix_t *matrix = g_value_get_boxed(value);

    return PycairoMatrix_FromMatrix(matrix);
}

static int
crmatrix_to_value(GValue *value, PyObject *object)
{
    cairo_matrix_t *matrix;

    if (!pygobject_check(object, &PycairoMatrix_Type)) {
            PyErr_SetString(PyExc_TypeError, "must be a cairo_matrix_t
object");            return -1;
    }
    matrix = &((PycairoMatrix *) object)->matrix;

    g_value_set_boxed(value, matrix);
    return 0;
}

If you dig long enough, it is possible to stumble upon anything.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20060321/630ae3ea/attachment.htm


More information about the pygtk mailing list