Add a _sugar.cairo_surface_from_gdk_pixbuf() function

generic function to create a surface from a gdk pixbuf
This commit is contained in:
Dan Williams
2007-01-07 01:20:42 -05:00
parent 70a5e27edd
commit 0265f06b3e
5 changed files with 40 additions and 0 deletions
+22
View File
@@ -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);
}
%%