Debian Codegraph @

gi/pygi-foreign-cairo.c

raw
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /*
3 * Copyright (c) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include <cairo-gobject.h>
25 #include <cairo.h>
26 #include <py3cairo.h>
27
28 /* Limit includes from PyGI to APIs which do not have link dependencies
29 * (pygobject.h and pygi-foreign-api.h) since _gi_cairo is built as a separate
30 * shared library that interacts with PyGI through a PyCapsule API at runtime.
31 */
32 #include <pygi-foreign-api.h>
33
34 static int _gi_cairo_exec (PyObject *module);
35
36 /*
37 * cairo_t marshaling
38 */
39
40 static PyObject *
41 cairo_context_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
42 GITransfer transfer, GIArgument *arg)
43 {
44 cairo_t *cr;
45
46 if (!PyObject_TypeCheck (value, &PycairoContext_Type)) {
47 PyErr_SetString (PyExc_TypeError, "Expected cairo.Context");
48 return NULL;
49 }
50
51 cr = PycairoContext_GET (value);
52 if (!cr) {
53 return NULL;
54 }
55
56 if (transfer != GI_TRANSFER_NOTHING) cr = cairo_reference (cr);
57
58 arg->v_pointer = cr;
59 Py_RETURN_NONE;
60 }
61
62 static PyObject *
63 cairo_context_from_arg (GIRegisteredTypeInfo *interface_info,
64 GITransfer transfer, gpointer data)
65 {
66 cairo_t *context = (cairo_t *)data;
67
68 if (transfer == GI_TRANSFER_NOTHING) cairo_reference (context);
69
70 return PycairoContext_FromContext (context, &PycairoContext_Type, NULL);
71 }
72
73
74 static PyObject *
75 cairo_context_release (GIBaseInfo *base_info, gpointer struct_)
76 {
77 cairo_destroy ((cairo_t *)struct_);
78 Py_RETURN_NONE;
79 }
80
81 static int
82 cairo_context_to_gvalue (GValue *value, PyObject *obj)
83 {
84 cairo_t *cr;
85
86 if (!PyObject_TypeCheck (obj, &PycairoContext_Type)) {
87 PyErr_SetString (PyExc_TypeError, "Expected cairo.Context");
88 return -1;
89 }
90
91 cr = PycairoContext_GET (obj);
92 if (!cr) {
93 return -1;
94 }
95
96 /* PycairoContext_GET returns a borrowed reference, use set_boxed
97 * to add new ref to the context which will be managed by the GValue. */
98 g_value_set_boxed (value, cr);
99 return 0;
100 }
101
102 static PyObject *
103 cairo_context_from_gvalue (const GValue *value)
104 {
105 /* PycairoContext_FromContext steals a ref, so we dup it out of the GValue. */
106 cairo_t *cr = g_value_dup_boxed (value);
107 if (!cr) {
108 Py_RETURN_NONE;
109 }
110
111 return PycairoContext_FromContext (cr, &PycairoContext_Type, NULL);
112 }
113
114
115 /*
116 * cairo_surface_t marshaling
117 */
118
119 static PyObject *
120 cairo_surface_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
121 GITransfer transfer, GIArgument *arg)
122 {
123 cairo_surface_t *surface;
124
125 if (!PyObject_TypeCheck (value, &PycairoSurface_Type)) {
126 PyErr_SetString (PyExc_TypeError, "Expected cairo.Surface");
127 return NULL;
128 }
129
130 surface = ((PycairoSurface *)value)->surface;
131 if (!surface) {
132 PyErr_SetString (PyExc_ValueError,
133 "Surface instance wrapping a NULL surface");
134 return NULL;
135 }
136
137 if (transfer != GI_TRANSFER_NOTHING)
138 surface = cairo_surface_reference (surface);
139
140 arg->v_pointer = surface;
141 Py_RETURN_NONE;
142 }
143
144 static PyObject *
145 cairo_surface_from_arg (GIRegisteredTypeInfo *interface_info,
146 GITransfer transfer, gpointer data)
147 {
148 cairo_surface_t *surface = (cairo_surface_t *)data;
149
150 if (transfer == GI_TRANSFER_NOTHING) cairo_surface_reference (surface);
151
152 return PycairoSurface_FromSurface (surface, NULL);
153 }
154
155 static PyObject *
156 cairo_surface_release (GIBaseInfo *base_info, gpointer struct_)
157 {
158 cairo_surface_destroy ((cairo_surface_t *)struct_);
159 Py_RETURN_NONE;
160 }
161
162 static int
163 cairo_surface_to_gvalue (GValue *value, PyObject *obj)
164 {
165 cairo_surface_t *surface;
166
167 if (!PyObject_TypeCheck (obj, &PycairoSurface_Type)) {
168 PyErr_SetString (PyExc_TypeError, "Expected cairo.Surface");
169 return -1;
170 }
171
172 surface = ((PycairoSurface *)obj)->surface;
173 if (!surface) {
174 return -1;
175 }
176
177 /* surface is a borrowed reference, use set_boxed
178 * to add new ref to the context which will be managed by the GValue. */
179 g_value_set_boxed (value, surface);
180 return 0;
181 }
182
183 static PyObject *
184 cairo_surface_from_gvalue (const GValue *value)
185 {
186 /* PycairoSurface_FromSurface steals a ref, so we dup it out of the GValue. */
187 cairo_surface_t *surface = g_value_dup_boxed (value);
188 if (!surface) {
189 Py_RETURN_NONE;
190 }
191
192 return PycairoSurface_FromSurface (surface, NULL);
193 }
194
195
196 /*
197 * cairo_path_t marshaling
198 */
199
200 static cairo_path_t *
201 _cairo_path_copy (cairo_path_t *path)
202 {
203 cairo_t *cr;
204 cairo_surface_t *surface;
205 cairo_path_t *copy;
206
207 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0);
208 cr = cairo_create (surface);
209 cairo_append_path (cr, path);
210 copy = cairo_copy_path (cr);
211 cairo_destroy (cr);
212 cairo_surface_destroy (surface);
213
214 return copy;
215 }
216
217 static PyObject *
218 cairo_path_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
219 GITransfer transfer, GIArgument *arg)
220 {
221 cairo_path_t *path;
222
223 if (!PyObject_TypeCheck (value, &PycairoPath_Type)) {
224 PyErr_SetString (PyExc_TypeError, "Expected cairo.Path");
225 return NULL;
226 }
227
228 path = ((PycairoPath *)value)->path;
229 if (!path) {
230 PyErr_SetString (PyExc_ValueError,
231 "Path instance wrapping a NULL path");
232 return NULL;
233 }
234
235 if (transfer != GI_TRANSFER_NOTHING) path = _cairo_path_copy (path);
236
237 arg->v_pointer = path;
238 Py_RETURN_NONE;
239 }
240
241 static PyObject *
242 cairo_path_from_arg (GIRegisteredTypeInfo *interface_info, GITransfer transfer,
243 gpointer data)
244 {
245 cairo_path_t *path = (cairo_path_t *)data;
246
247 if (transfer == GI_TRANSFER_NOTHING) {
248 PyErr_SetString (
249 PyExc_TypeError,
250 "Unsupported annotation (transfer none) for cairo.Path return");
251 return NULL;
252 }
253
254 return PycairoPath_FromPath (path);
255 }
256
257 static PyObject *
258 cairo_path_release (GIBaseInfo *base_info, gpointer struct_)
259 {
260 cairo_path_destroy ((cairo_path_t *)struct_);
261 Py_RETURN_NONE;
262 }
263
264
265 /*
266 * cairo_font_face_t marshaling
267 */
268
269 static PyObject *
270 cairo_font_face_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
271 GITransfer transfer, GIArgument *arg)
272 {
273 cairo_font_face_t *font_face;
274
275 if (!PyObject_TypeCheck (value, &PycairoFontFace_Type)) {
276 PyErr_SetString (PyExc_TypeError, "Expected cairo.FontFace");
277 return NULL;
278 }
279
280 font_face = ((PycairoFontFace *)value)->font_face;
281 if (!font_face) {
282 PyErr_SetString (PyExc_ValueError,
283 "FontFace instance wrapping a NULL font_face");
284 return NULL;
285 }
286
287 if (transfer != GI_TRANSFER_NOTHING)
288 font_face = cairo_font_face_reference (font_face);
289
290 arg->v_pointer = font_face;
291 Py_RETURN_NONE;
292 }
293
294 static PyObject *
295 cairo_font_face_from_arg (GIRegisteredTypeInfo *interface_info,
296 GITransfer transfer, gpointer data)
297 {
298 cairo_font_face_t *font_face = (cairo_font_face_t *)data;
299
300 if (transfer == GI_TRANSFER_NOTHING) cairo_font_face_reference (font_face);
301
302 return PycairoFontFace_FromFontFace (font_face);
303 }
304
305 static PyObject *
306 cairo_font_face_release (GIBaseInfo *base_info, gpointer struct_)
307 {
308 cairo_font_face_destroy ((cairo_font_face_t *)struct_);
309 Py_RETURN_NONE;
310 }
311
312 static int
313 cairo_font_face_to_gvalue (GValue *value, PyObject *obj)
314 {
315 cairo_font_face_t *font_face;
316
317 if (!PyObject_TypeCheck (obj, &PycairoFontFace_Type)) {
318 PyErr_SetString (PyExc_TypeError, "Expected cairo.FontFace");
319 return -1;
320 }
321
322 font_face = ((PycairoFontFace *)obj)->font_face;
323 if (!font_face) {
324 return -1;
325 }
326
327 g_value_set_boxed (value, font_face);
328 return 0;
329 }
330
331 static PyObject *
332 cairo_font_face_from_gvalue (const GValue *value)
333 {
334 cairo_font_face_t *font_face = g_value_dup_boxed (value);
335 if (!font_face) {
336 Py_RETURN_NONE;
337 }
338
339 return PycairoFontFace_FromFontFace (font_face);
340 }
341
342
343 /*
344 * cairo_font_options_t marshaling
345 */
346
347 static PyObject *
348 cairo_font_options_to_arg (PyObject *value,
349 GIRegisteredTypeInfo *interface_info,
350 GITransfer transfer, GIArgument *arg)
351 {
352 cairo_font_options_t *font_options;
353
354 if (!PyObject_TypeCheck (value, &PycairoFontOptions_Type)) {
355 PyErr_SetString (PyExc_TypeError, "Expected cairo.FontOptions");
356 return NULL;
357 }
358
359 font_options = ((PycairoFontOptions *)value)->font_options;
360 if (!font_options) {
361 PyErr_SetString (PyExc_ValueError,
362 "FontOptions instance wrapping a NULL font_options");
363 return NULL;
364 }
365
366 if (transfer != GI_TRANSFER_NOTHING)
367 font_options = cairo_font_options_copy (font_options);
368
369 arg->v_pointer = font_options;
370 Py_RETURN_NONE;
371 }
372
373 static PyObject *
374 cairo_font_options_from_arg (GIRegisteredTypeInfo *interface_info,
375 GITransfer transfer, gpointer data)
376 {
377 cairo_font_options_t *font_options = (cairo_font_options_t *)data;
378
379 if (transfer == GI_TRANSFER_NOTHING)
380 font_options = cairo_font_options_copy (font_options);
381
382 return PycairoFontOptions_FromFontOptions (font_options);
383 }
384
385 static PyObject *
386 cairo_font_options_release (GIBaseInfo *base_info, gpointer struct_)
387 {
388 cairo_font_options_destroy ((cairo_font_options_t *)struct_);
389 Py_RETURN_NONE;
390 }
391
392
393 /*
394 * scaled_font_t marshaling
395 */
396
397 static PyObject *
398 cairo_scaled_font_to_arg (PyObject *value,
399 GIRegisteredTypeInfo *interface_info,
400 GITransfer transfer, GIArgument *arg)
401 {
402 cairo_scaled_font_t *scaled_font;
403
404 if (!PyObject_TypeCheck (value, &PycairoScaledFont_Type)) {
405 PyErr_SetString (PyExc_TypeError, "Expected cairo.ScaledFont");
406 return NULL;
407 }
408
409 scaled_font = ((PycairoScaledFont *)value)->scaled_font;
410 if (!scaled_font) {
411 PyErr_SetString (PyExc_ValueError,
412 "ScaledFont instance wrapping a NULL scaled_font");
413 return NULL;
414 }
415
416 if (transfer != GI_TRANSFER_NOTHING)
417 scaled_font = cairo_scaled_font_reference (scaled_font);
418
419 arg->v_pointer = scaled_font;
420 Py_RETURN_NONE;
421 }
422
423 static PyObject *
424 cairo_scaled_font_from_arg (GIRegisteredTypeInfo *interface_info,
425 GITransfer transfer, gpointer data)
426 {
427 cairo_scaled_font_t *scaled_font = (cairo_scaled_font_t *)data;
428
429 if (transfer == GI_TRANSFER_NOTHING)
430 cairo_scaled_font_reference (scaled_font);
431
432 return PycairoScaledFont_FromScaledFont (scaled_font);
433 }
434
435 static PyObject *
436 cairo_scaled_font_release (GIBaseInfo *base_info, gpointer struct_)
437 {
438 cairo_scaled_font_destroy ((cairo_scaled_font_t *)struct_);
439 Py_RETURN_NONE;
440 }
441
442 static int
443 cairo_scaled_font_to_gvalue (GValue *value, PyObject *obj)
444 {
445 cairo_scaled_font_t *scaled_font;
446
447 if (!PyObject_TypeCheck (obj, &PycairoScaledFont_Type)) {
448 PyErr_SetString (PyExc_TypeError, "Expected cairo.ScaledFont");
449 return -1;
450 }
451
452 scaled_font = ((PycairoScaledFont *)obj)->scaled_font;
453 if (!scaled_font) {
454 return -1;
455 }
456
457 /* scaled_font is a borrowed reference, use set_boxed
458 * to add new ref to the context which will be managed by the GValue. */
459 g_value_set_boxed (value, scaled_font);
460 return 0;
461 }
462
463 static PyObject *
464 cairo_scaled_font_from_gvalue (const GValue *value)
465 {
466 /* PycairoScaledFont_FromScaledFont steals a ref, so we dup it out of the GValue. */
467 cairo_scaled_font_t *scaled_font = g_value_dup_boxed (value);
468 if (!scaled_font) {
469 Py_RETURN_NONE;
470 }
471
472 return PycairoScaledFont_FromScaledFont (scaled_font);
473 }
474
475
476 /*
477 * cairo_pattern_t marshaling
478 */
479
480 static PyObject *
481 cairo_pattern_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
482 GITransfer transfer, GIArgument *arg)
483 {
484 cairo_pattern_t *pattern;
485
486 if (!PyObject_TypeCheck (value, &PycairoPattern_Type)) {
487 PyErr_SetString (PyExc_TypeError, "Expected cairo.Pattern");
488 return NULL;
489 }
490
491 pattern = ((PycairoPattern *)value)->pattern;
492 if (!pattern) {
493 PyErr_SetString (PyExc_ValueError,
494 "Pattern instance wrapping a NULL pattern");
495 return NULL;
496 }
497
498 if (transfer != GI_TRANSFER_NOTHING)
499 pattern = cairo_pattern_reference (pattern);
500
501 arg->v_pointer = pattern;
502 Py_RETURN_NONE;
503 }
504
505 static PyObject *
506 cairo_pattern_from_arg (GIRegisteredTypeInfo *interface_info,
507 GITransfer transfer, gpointer data)
508 {
509 cairo_pattern_t *pattern = (cairo_pattern_t *)data;
510
511 if (transfer == GI_TRANSFER_NOTHING)
512 pattern = cairo_pattern_reference (pattern);
513
514 return PycairoPattern_FromPattern (pattern, NULL);
515 }
516
517 static PyObject *
518 cairo_pattern_release (GIBaseInfo *base_info, gpointer struct_)
519 {
520 cairo_pattern_destroy ((cairo_pattern_t *)struct_);
521 Py_RETURN_NONE;
522 }
523
524 static int
525 cairo_pattern_to_gvalue (GValue *value, PyObject *obj)
526 {
527 cairo_pattern_t *pattern;
528
529 if (!PyObject_TypeCheck (obj, &PycairoPattern_Type)) {
530 PyErr_SetString (PyExc_TypeError, "Expected cairo.Pattern");
531 return -1;
532 }
533
534 pattern = ((PycairoPattern *)obj)->pattern;
535 if (!pattern) {
536 return -1;
537 }
538
539 /* pattern is a borrowed reference, use set_boxed
540 * to add new ref to the context which will be managed by the GValue. */
541 g_value_set_boxed (value, pattern);
542 return 0;
543 }
544
545 static PyObject *
546 cairo_pattern_from_gvalue (const GValue *value)
547 {
548 /* PycairoPattern_FromPattern steals a ref, so we dup it out of the GValue. */
549 cairo_pattern_t *pattern = g_value_dup_boxed (value);
550 if (!pattern) {
551 Py_RETURN_NONE;
552 }
553
554 return PycairoPattern_FromPattern (pattern, NULL);
555 }
556
557 static PyObject *
558 cairo_region_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
559 GITransfer transfer, GIArgument *arg)
560 {
561 cairo_region_t *region;
562
563 if (!PyObject_TypeCheck (value, &PycairoRegion_Type)) {
564 PyErr_SetString (PyExc_TypeError, "Expected cairo.Region");
565 return NULL;
566 }
567
568 region = ((PycairoRegion *)value)->region;
569 if (!region) {
570 PyErr_SetString (PyExc_ValueError,
571 "Region instance wrapping a NULL region");
572 return NULL;
573 }
574
575 if (transfer != GI_TRANSFER_NOTHING) region = cairo_region_copy (region);
576
577 arg->v_pointer = region;
578 Py_RETURN_NONE;
579 }
580
581 static PyObject *
582 cairo_region_from_arg (GIRegisteredTypeInfo *interface_info,
583 GITransfer transfer, gpointer data)
584 {
585 cairo_region_t *region = (cairo_region_t *)data;
586
587 if (transfer == GI_TRANSFER_NOTHING) cairo_region_reference (region);
588
589 return PycairoRegion_FromRegion (region);
590 }
591
592 static PyObject *
593 cairo_region_release (GIBaseInfo *base_info, gpointer struct_)
594 {
595 cairo_region_destroy ((cairo_region_t *)struct_);
596 Py_RETURN_NONE;
597 }
598
599 static PyObject *
600 cairo_matrix_from_arg (GIRegisteredTypeInfo *interface_info,
601 GITransfer transfer, gpointer data)
602 {
603 cairo_matrix_t *matrix = (cairo_matrix_t *)data;
604
605 if (transfer != GI_TRANSFER_NOTHING) {
606 PyErr_SetString (
607 PyExc_TypeError,
608 "Unsupported annotation (transfer full) for cairo.Matrix");
609 return NULL;
610 }
611
612 if (matrix == NULL) {
613 /* NULL in case of caller-allocates */
614 cairo_matrix_t temp = { 0 };
615 return PycairoMatrix_FromMatrix (&temp);
616 }
617
618 return PycairoMatrix_FromMatrix (matrix);
619 }
620
621 static PyObject *
622 cairo_matrix_to_arg (PyObject *value, GIRegisteredTypeInfo *interface_info,
623 GITransfer transfer, GIArgument *arg)
624 {
625 cairo_matrix_t *matrix;
626
627 if (!PyObject_TypeCheck (value, &PycairoMatrix_Type)) {
628 PyErr_SetString (PyExc_TypeError, "Expected cairo.Matrix");
629 return NULL;
630 }
631
632 matrix = &(((PycairoMatrix *)value)->matrix);
633
634 arg->v_pointer = matrix;
635 Py_RETURN_NONE;
636 }
637
638 static PyObject *
639 cairo_matrix_release (GIBaseInfo *base_info, gpointer struct_)
640 {
641 Py_RETURN_NONE;
642 }
643
644 static int
645 cairo_matrix_to_gvalue (GValue *value, PyObject *obj)
646 {
647 cairo_matrix_t *matrix;
648
649 if (!PyObject_TypeCheck (obj, &PycairoMatrix_Type)) {
650 PyErr_SetString (PyExc_TypeError, "Expected cairo.Matrix");
651 return -1;
652 }
653
654 matrix = &(((PycairoMatrix *)obj)->matrix);
655 if (!matrix) {
656 return -1;
657 }
658
659 g_value_set_boxed (value, matrix);
660 return 0;
661 }
662
663 static PyObject *
664 cairo_matrix_from_gvalue (const GValue *value)
665 {
666 cairo_matrix_t *matrix = g_value_get_boxed (value);
667 if (!matrix) {
668 Py_RETURN_NONE;
669 }
670
671 return PycairoMatrix_FromMatrix (matrix);
672 }
673
674 #ifdef __GNUC__
675 #define PYGI_MODINIT_FUNC \
676 __attribute__ ((visibility ("default"))) PyMODINIT_FUNC
677 #else
678 #define PYGI_MODINIT_FUNC PyMODINIT_FUNC
679 #endif
680
681 static PyMethodDef _gi_cairo_functions[] = {
682 {
683 0,
684 },
685 };
686
687 static PyModuleDef_Slot _gi_cairo_slots[] = {
688 { Py_mod_exec, _gi_cairo_exec },
689 { 0, NULL },
690 };
691
692 static struct PyModuleDef __gi_cairomodule = {
693 PyModuleDef_HEAD_INIT, "_gi_cairo", NULL, 0, _gi_cairo_functions,
694 _gi_cairo_slots, NULL, NULL, NULL,
695 };
696
697 PYGI_MODINIT_FUNC PyInit__gi_cairo (void);
698
699 PYGI_MODINIT_FUNC
700 PyInit__gi_cairo (void) { return PyModuleDef_Init (&__gi_cairomodule); }
701
702
703 static int
704 _gi_cairo_exec (PyObject *module)
705 {
706 PyObject *gobject_mod;
707
708 import_cairo ();
709
710 if (Pycairo_CAPI == NULL) return -1;
711
712 gobject_mod = pygobject_init (3, 13, 2);
713 if (gobject_mod == NULL) return -1;
714 Py_DECREF (gobject_mod);
715
716 pygi_register_foreign_struct ("cairo", "Matrix", cairo_matrix_to_arg,
717 cairo_matrix_from_arg, cairo_matrix_release);
718
719 pygi_register_foreign_struct ("cairo", "Context", cairo_context_to_arg,
720 cairo_context_from_arg,
721 cairo_context_release);
722
723 pygi_register_foreign_struct ("cairo", "Surface", cairo_surface_to_arg,
724 cairo_surface_from_arg,
725 cairo_surface_release);
726
727 pygi_register_foreign_struct ("cairo", "Path", cairo_path_to_arg,
728 cairo_path_from_arg, cairo_path_release);
729
730 pygi_register_foreign_struct ("cairo", "FontFace", cairo_font_face_to_arg,
731 cairo_font_face_from_arg,
732 cairo_font_face_release);
733
734 pygi_register_foreign_struct (
735 "cairo", "FontOptions", cairo_font_options_to_arg,
736 cairo_font_options_from_arg, cairo_font_options_release);
737
738 pygi_register_foreign_struct ("cairo", "Pattern", cairo_pattern_to_arg,
739 cairo_pattern_from_arg,
740 cairo_pattern_release);
741
742 pygi_register_foreign_struct ("cairo", "Region", cairo_region_to_arg,
743 cairo_region_from_arg, cairo_region_release);
744
745 pygi_register_foreign_struct (
746 "cairo", "ScaledFont", cairo_scaled_font_to_arg,
747 cairo_scaled_font_from_arg, cairo_scaled_font_release);
748
749 pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_MATRIX,
750 cairo_matrix_from_gvalue,
751 cairo_matrix_to_gvalue);
752
753 pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_CONTEXT,
754 cairo_context_from_gvalue,
755 cairo_context_to_gvalue);
756
757 pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_SURFACE,
758 cairo_surface_from_gvalue,
759 cairo_surface_to_gvalue);
760
761 pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_FONT_FACE,
762 cairo_font_face_from_gvalue,
763 cairo_font_face_to_gvalue);
764
765 pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_SCALED_FONT,
766 cairo_scaled_font_from_gvalue,
767 cairo_scaled_font_to_gvalue);
768
769 pyg_register_gtype_custom (CAIRO_GOBJECT_TYPE_PATTERN,
770 cairo_pattern_from_gvalue,
771 cairo_pattern_to_gvalue);
772
773 return 0;
774 }