diff options
author | Dan Williams <dcbw@localhost.localdomain> | 2007-01-07 06:20:42 (GMT) |
---|---|---|
committer | Dan Williams <dcbw@localhost.localdomain> | 2007-01-07 06:20:42 (GMT) |
commit | 0265f06b3e039aee88312cda7b6c0e98aefe067d (patch) | |
tree | 143173185c7d1723b3a133b80d94460d280a38b6 /lib | |
parent | 70a5e27edd2ef7fc299f406025b47103f6b82542 (diff) |
Add a _sugar.cairo_surface_from_gdk_pixbuf() function
generic function to create a surface from a gdk pixbuf
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/Makefile.am | 2 | ||||
-rw-r--r-- | lib/python/_sugar.defs | 9 | ||||
-rw-r--r-- | lib/python/_sugar.override | 22 | ||||
-rw-r--r-- | lib/python/_sugarmodule.c | 5 |
4 files changed, 38 insertions, 0 deletions
diff --git a/lib/python/Makefile.am b/lib/python/Makefile.am index be712d7..6f28d33 100644 --- a/lib/python/Makefile.am +++ b/lib/python/Makefile.am @@ -1,6 +1,7 @@ INCLUDES = \ $(PYTHON_INCLUDES) \ $(PYGTK_CFLAGS) \ + $(PYCAIRO_CFLAGS) \ $(LIB_CFLAGS) \ -I $(top_srcdir)/lib/src @@ -11,6 +12,7 @@ pkgpyexec_LTLIBRARIES = _sugar.la _sugar_la_LDFLAGS = -module -avoid-version -R$(MOZILLA_HOME) _sugar_la_LIBADD = \ $(LIB_LIBS) \ + $(PYCAIRO_LIBS) \ $(top_builddir)/lib/src/libsugarprivate.la _sugar_la_SOURCES = \ diff --git a/lib/python/_sugar.defs b/lib/python/_sugar.defs index bead7b4..4ea9b8d 100644 --- a/lib/python/_sugar.defs +++ b/lib/python/_sugar.defs @@ -247,6 +247,15 @@ '("GdkPixbuf*" "pixbuf") ) ) + +(define-function cairo_surface_from_gdk_pixbuf + (c-name "sugar_cairo_surface_from_gdk_pixbuf") + (return-type "cairo_surface_t*") + (parameters + '("GdkPixbuf*" "pixbuf") + ) +) + ;; Enumerations and flags ... diff --git a/lib/python/_sugar.override b/lib/python/_sugar.override index 6e0fe72..8dd90f9 100644 --- a/lib/python/_sugar.override +++ b/lib/python/_sugar.override @@ -13,9 +13,11 @@ headers #include "sugar-download.h" #include "sugar-audio-manager.h" +#include "pycairo.h" #include <pygtk/pygtk.h> #include <glib.h> +extern Pycairo_CAPI_t *Pycairo_CAPI; %% modulename gecko @@ -159,3 +161,23 @@ _wrap_sugar_hippo_canvas_image_set_image_from_gdk_pixbuf(PyGObject *self, PyObje return Py_None; } %% +override sugar_cairo_surface_from_gdk_pixbuf kwargs +static PyObject* +_wrap_sugar_cairo_surface_from_gdk_pixbuf(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "pixbuf", NULL }; + PyGObject *child; + cairo_surface_t *surface; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:sugar.cairo_surface_from_gdk_pixbuf", kwlist, &PyGdkPixbuf_Type, &child)) + return NULL; + + surface = _cairo_surface_from_pixbuf(GDK_PIXBUF (child->obj)); + if (surface == NULL) { + PyErr_SetString(PyExc_RuntimeError, "pixbuf could not be converted"); + return NULL; + } + + return PycairoSurface_FromSurface(surface, NULL); +} +%% diff --git a/lib/python/_sugarmodule.c b/lib/python/_sugarmodule.c index 4d8511b..c576efb 100644 --- a/lib/python/_sugarmodule.c +++ b/lib/python/_sugarmodule.c @@ -5,6 +5,9 @@ /* include this first, before NO_IMPORT_PYGOBJECT is defined */ #include <pygobject.h> +#include <pycairo.h> +Pycairo_CAPI_t *Pycairo_CAPI; + void py_sugar_register_classes (PyObject *d); extern PyMethodDef py_sugar_functions[]; @@ -16,6 +19,8 @@ init_sugar(void) init_pygobject (); + Pycairo_IMPORT; + m = Py_InitModule ("_sugar", py_sugar_functions); d = PyModule_GetDict (m); |