~ubuntu-branches/ubuntu/maverick/gcompris/maverick

« back to all changes in this revision

Viewing changes to src/boards/goocanvasmodule.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Gariepy, Marc Gariepy, Stephane Graber
  • Date: 2010-01-04 17:42:49 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174249-7bupatd9dtxyhvs4
Tags: 9.0-0ubuntu1
[Marc Gariepy]
* New upstream release (9.0).
* Remove cache.c from POTFILES to avoid FTBFS
* Remove unneeded rm in debian/rules (file no longer exists upstream)

[Stephane Graber]
* Bump Debian standards to 3.8.3
* Add patch system (dpatch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#include "config.h"
 
3
#endif
 
4
 
 
5
#include <pygobject.h>
 
6
#define NO_IMPORT_PYGTK
 
7
#include <pygtk/pygtk.h>
 
8
#include <goocanvas.h>
 
9
 
 
10
# include <pycairo.h>
 
11
Pycairo_CAPI_t *Pycairo_CAPI;
 
12
 
 
13
 
 
14
void pygoocanvas_register_classes (PyObject *d); 
 
15
void pygoocanvas_add_constants(PyObject *module, const gchar *strip_prefix);
 
16
 
 
17
extern PyMethodDef pygoocanvas_functions[];
 
18
 
 
19
static PyObject *
 
20
_cairo_matrix_from_gvalue(const GValue *value)
 
21
{
 
22
    return PycairoMatrix_FromMatrix((cairo_matrix_t *) g_value_get_boxed(value));
 
23
}
 
24
 
 
25
static int
 
26
_cairo_matrix_to_gvalue(GValue *value, PyObject *obj)
 
27
{
 
28
    if (!(PyObject_IsInstance(obj, (PyObject *) &PycairoMatrix_Type)))
 
29
        return -1;
 
30
 
 
31
    g_value_set_boxed(value, &((PycairoMatrix*)(obj))->matrix);
 
32
    return 0;
 
33
}
 
34
 
 
35
static PyObject *
 
36
_cairo_pattern_from_gvalue(const GValue *value)
 
37
{
 
38
    return PycairoPattern_FromPattern(cairo_pattern_reference((cairo_pattern_t *) g_value_get_boxed(value)), NULL);
 
39
}
 
40
 
 
41
static int
 
42
_cairo_pattern_to_gvalue(GValue *value, PyObject *obj)
 
43
{
 
44
    if (obj == Py_None) {
 
45
        g_value_set_boxed(value, NULL);
 
46
        return 0;
 
47
    }
 
48
 
 
49
    if (!(PyObject_IsInstance(obj, (PyObject *) &PycairoPattern_Type)))
 
50
        return -1;
 
51
 
 
52
    g_value_set_boxed(value, ((PycairoPattern*)(obj))->pattern);
 
53
    return 0;
 
54
}
 
55
 
 
56
DL_EXPORT (void)
 
57
initgoocanvas (void)
 
58
{
 
59
    PyObject *m, *d;
 
60
 
 
61
 
 
62
    Pycairo_IMPORT;
 
63
    if (Pycairo_CAPI == NULL)
 
64
        return;
 
65
 
 
66
    m = Py_InitModule ("goocanvas", pygoocanvas_functions);
 
67
    d = PyModule_GetDict (m);
 
68
    
 
69
    init_pygobject ();
 
70
    
 
71
    pygoocanvas_register_classes (d);
 
72
    pygoocanvas_add_constants(m, "GOO_CANVAS_");
 
73
    PyModule_AddObject(m, "TYPE_CAIRO_MATRIX", pyg_type_wrapper_new(GOO_TYPE_CAIRO_MATRIX));
 
74
    pyg_register_gtype_custom(GOO_TYPE_CAIRO_MATRIX,
 
75
                              _cairo_matrix_from_gvalue,
 
76
                              _cairo_matrix_to_gvalue);
 
77
    PyModule_AddObject(m, "TYPE_CAIRO_PATTERN", pyg_type_wrapper_new(GOO_TYPE_CAIRO_PATTERN));
 
78
    pyg_register_gtype_custom(GOO_TYPE_CAIRO_PATTERN,
 
79
                              _cairo_pattern_from_gvalue,
 
80
                              _cairo_pattern_to_gvalue);
 
81
 
 
82
    PyModule_AddObject(m, "pygoocanvas_version",
 
83
                       Py_BuildValue("iii",
 
84
                                     PYGOOCANVAS_MAJOR_VERSION,
 
85
                                     PYGOOCANVAS_MINOR_VERSION,
 
86
                                     PYGOOCANVAS_MICRO_VERSION));
 
87
    
 
88
    if (PyErr_Occurred ())
 
89
        Py_FatalError ("can't initialise module goocanvas");
 
90
}