Commit d519d8c2 authored by Renato Florentino Garcia's avatar Renato Florentino Garcia Committed by Christoph Reiter

Add cairo_matrix_t converter to GValue.

parent 627dd81a
......@@ -583,6 +583,36 @@ cairo_matrix_release (GIBaseInfo *base_info,
Py_RETURN_NONE;
}
static int
cairo_matrix_to_gvalue (GValue *value, PyObject *obj)
{
cairo_matrix_t *matrix;
if (!PyObject_TypeCheck (obj, &PycairoMatrix_Type)) {
PyErr_SetString (PyExc_TypeError, "Expected cairo.Matrix");
return -1;
}
matrix = &(( (PycairoMatrix*) obj)->matrix);
if (!matrix) {
return -1;
}
g_value_set_boxed (value, matrix);
return 0;
}
static PyObject *
cairo_matrix_from_gvalue (const GValue *value)
{
cairo_matrix_t *matrix = g_value_get_boxed(value);
if (!matrix) {
Py_RETURN_NONE;
}
return PycairoMatrix_FromMatrix (matrix);
}
static PyMethodDef _gi_cairo_functions[] = { {0,} };
PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
{
......@@ -644,6 +674,10 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
cairo_region_from_arg,
cairo_region_release);
pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_MATRIX,
cairo_matrix_from_gvalue,
cairo_matrix_to_gvalue);
pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_CONTEXT,
cairo_context_from_gvalue,
cairo_context_to_gvalue);
......
......@@ -34,12 +34,14 @@ class Test(unittest.TestCase):
def test_gvalue_converters(self):
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
context = cairo.Context(surface)
matrix = cairo.Matrix()
objects = {
'CairoContext': context,
'CairoSurface': surface,
'CairoFontFace': context.get_font_face(),
'CairoScaledFont': context.get_scaled_font(),
'CairoPattern': context.get_source(),
'CairoMatrix': matrix,
}
for type_name, cairo_obj in objects.items():
gtype = GObject.type_from_name(type_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment