[pygobject] foreign: Register cairo.Path and cairo.FontOptions foreign structs
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] foreign: Register cairo.Path and cairo.FontOptions foreign structs
- Date: Tue, 5 Jun 2012 13:51:14 +0000 (UTC)
commit b21f66d2a399b8c9a36a1758107b7bdff0ec8eaa
Author: Bastian Winkler <buz netbuz org>
Date: Wed May 9 19:04:01 2012 +0200
foreign: Register cairo.Path and cairo.FontOptions foreign structs
They are rarely used, but they are used at least by Gdk, PangoCairo and
Clutter.
clutter.Path is not used by any API that the test suite uses, so leave that
without a test for now.
https://bugzilla.gnome.org/show_bug.cgi?id=677388
Signed-off-by: Martin Pitt <martinpitt gnome org>
gi/pygi-foreign-cairo.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++
tests/test_everything.py | 8 ++++
2 files changed, 93 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index 4e12df3..ef3b0ab 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -112,6 +112,79 @@ cairo_surface_release (GIBaseInfo *base_info,
Py_RETURN_NONE;
}
+
+PyObject *
+cairo_path_to_arg (PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
+ GIArgument *arg)
+{
+ cairo_path_t *path;
+
+ g_assert (transfer == GI_TRANSFER_NOTHING);
+
+ path = ( (PycairoPath*) value)->path;
+ if (!path) {
+ PyErr_SetString (PyExc_ValueError, "Path instance wrapping a NULL path");
+ return NULL;
+ }
+
+ arg->v_pointer = path;
+ Py_RETURN_NONE;
+}
+
+PyObject *
+cairo_path_from_arg (GIInterfaceInfo *interface_info, gpointer data)
+{
+ cairo_path_t *path = (cairo_path_t*) data;
+
+ return PycairoPath_FromPath (path);
+}
+
+PyObject *
+cairo_path_release (GIBaseInfo *base_info,
+ gpointer struct_)
+{
+ cairo_path_destroy ( (cairo_path_t*) struct_);
+ Py_RETURN_NONE;
+}
+
+PyObject *
+cairo_font_options_to_arg (PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
+ GIArgument *arg)
+{
+ cairo_font_options_t *font_options;
+
+ g_assert (transfer == GI_TRANSFER_NOTHING);
+
+ font_options = ( (PycairoFontOptions*) value)->font_options;
+ if (!font_options) {
+ PyErr_SetString (PyExc_ValueError, "FontOptions instance wrapping a NULL font_options");
+ return NULL;
+ }
+
+ arg->v_pointer = font_options;
+ Py_RETURN_NONE;
+}
+
+PyObject *
+cairo_font_options_from_arg (GIInterfaceInfo *interface_info, gpointer data)
+{
+ cairo_font_options_t *font_options = (cairo_font_options_t*) data;
+
+ return PycairoFontOptions_FromFontOptions (cairo_font_options_copy (font_options));
+}
+
+PyObject *
+cairo_font_options_release (GIBaseInfo *base_info,
+ gpointer struct_)
+{
+ cairo_font_options_destroy ( (cairo_font_options_t*) struct_);
+ Py_RETURN_NONE;
+}
+
static PyMethodDef _gi_cairo_functions[] = { {0,} };
PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
{
@@ -135,5 +208,17 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
cairo_surface_to_arg,
cairo_surface_from_arg,
cairo_surface_release);
+
+ pygi_register_foreign_struct ("cairo",
+ "Path",
+ cairo_path_to_arg,
+ cairo_path_from_arg,
+ cairo_path_release);
+
+ pygi_register_foreign_struct ("cairo",
+ "FontOptions",
+ cairo_font_options_to_arg,
+ cairo_font_options_from_arg,
+ cairo_font_options_release);
}
PYGLIB_MODULE_END;
diff --git a/tests/test_everything.py b/tests/test_everything.py
index f6c13a8..728d58a 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -18,6 +18,7 @@ except ImportError:
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
+from gi.repository import Gtk
from gi.repository import Regress as Everything
if sys.version_info < (3, 0):
@@ -672,3 +673,10 @@ class TestSignals(unittest.TestCase):
obj.connect('sig-with-obj', callback)
obj.emit_sig_with_obj()
+
+
+class TestPango(unittest.TestCase):
+ def test_cairo_font_options(self):
+ screen = Gtk.Window().get_screen()
+ font_opts = screen.get_font_options()
+ self.assertEqual(type(font_opts.get_subpixel_order()), int)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]