Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 91 lines (70 sloc) 2.446 kb
a6d7e94 initial import
Gian Mario Tagliaretti authored
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include <pygobject.h>
dbc0f32 prevent PYGTK from being imported into goocanvasmodule, patch from Randa...
Gian Mario Tagliaretti authored
6 #define NO_IMPORT_PYGTK
a6d7e94 initial import
Gian Mario Tagliaretti authored
7 #include <pygtk/pygtk.h>
f4d0fd7 make the goocanvas #include more correct
Gustavo J. A. M. Carneiro authored
8 #include <goocanvas.h>
a6d7e94 initial import
Gian Mario Tagliaretti authored
9
3797eab fix import of pycairo in goocanvasmodule.c and some misc
Gian Mario Tagliaretti authored
10 # include <pycairo.h>
a6d7e94 initial import
Gian Mario Tagliaretti authored
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
cd86d7d Update to latest goocanvas API changes
Gustavo J. A. M. Carneiro authored
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
0fdf704 line dashes and pattern support
Gustavo J. A. M. Carneiro authored
35 static PyObject *
36 _cairo_pattern_from_gvalue(const GValue *value)
37 {
c90cfc6 Gian Mario Tagliaretti Fix a segfault due to a change in PyCairo API
gianmt authored
38 return PycairoPattern_FromPattern(cairo_pattern_reference((cairo_pattern_t *) g_value_get_boxed(value)), NULL);
0fdf704 line dashes and pattern support
Gustavo J. A. M. Carneiro authored
39 }
40
41 static int
42 _cairo_pattern_to_gvalue(GValue *value, PyObject *obj)
43 {
0d7533f Allow pattern=None in properties
Gustavo J. A. M. Carneiro authored
44 if (obj == Py_None) {
45 g_value_set_boxed(value, NULL);
46 return 0;
47 }
48
0fdf704 line dashes and pattern support
Gustavo J. A. M. Carneiro authored
49 if (!(PyObject_IsInstance(obj, (PyObject *) &PycairoPattern_Type)))
50 return -1;
51
8b1e820 postfix
Gustavo J. A. M. Carneiro authored
52 g_value_set_boxed(value, ((PycairoPattern*)(obj))->pattern);
0fdf704 line dashes and pattern support
Gustavo J. A. M. Carneiro authored
53 return 0;
54 }
cd86d7d Update to latest goocanvas API changes
Gustavo J. A. M. Carneiro authored
55
a6d7e94 initial import
Gian Mario Tagliaretti authored
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);
a1259cf fix enums/flags
Gustavo J. A. M. Carneiro authored
72 pygoocanvas_add_constants(m, "GOO_CANVAS_");
cd86d7d Update to latest goocanvas API changes
Gustavo J. A. M. Carneiro authored
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);
046bba1 fix object registration TYPE_CAIRO_PATTERN
Gian Mario Tagliaretti authored
77 PyModule_AddObject(m, "TYPE_CAIRO_PATTERN", pyg_type_wrapper_new(GOO_TYPE_CAIRO_PATTERN));
0fdf704 line dashes and pattern support
Gustavo J. A. M. Carneiro authored
78 pyg_register_gtype_custom(GOO_TYPE_CAIRO_PATTERN,
79 _cairo_pattern_from_gvalue,
80 _cairo_pattern_to_gvalue);
98dd499 Add pygoocanvas_version to the module.
Gustavo J. A. M. Carneiro authored
81
82 PyModule_AddObject(m, "pygoocanvas_version",
83 Py_BuildValue("iii",
84 PYGOOCANVAS_MAJOR_VERSION,
85 PYGOOCANVAS_MINOR_VERSION,
86 PYGOOCANVAS_MICRO_VERSION));
cd86d7d Update to latest goocanvas API changes
Gustavo J. A. M. Carneiro authored
87
a6d7e94 initial import
Gian Mario Tagliaretti authored
88 if (PyErr_Occurred ())
89 Py_FatalError ("can't initialise module goocanvas");
90 }
Something went wrong with that request. Please try again.