Add a _sugar.cairo_surface_from_gdk_pixbuf() function
generic function to create a surface from a gdk pixbuf
This commit is contained in:
parent
70a5e27edd
commit
0265f06b3e
@ -38,6 +38,8 @@ AC_SUBST(GNOMEPYTHONEXTRAS_DEFSDIR)
|
|||||||
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
|
PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
|
||||||
AC_SUBST(PYGTK_DEFSDIR)
|
AC_SUBST(PYGTK_DEFSDIR)
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES(PYCAIRO, pycairo)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Setup GETTEXT
|
# Setup GETTEXT
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(PYTHON_INCLUDES) \
|
$(PYTHON_INCLUDES) \
|
||||||
$(PYGTK_CFLAGS) \
|
$(PYGTK_CFLAGS) \
|
||||||
|
$(PYCAIRO_CFLAGS) \
|
||||||
$(LIB_CFLAGS) \
|
$(LIB_CFLAGS) \
|
||||||
-I $(top_srcdir)/lib/src
|
-I $(top_srcdir)/lib/src
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ pkgpyexec_LTLIBRARIES = _sugar.la
|
|||||||
_sugar_la_LDFLAGS = -module -avoid-version -R$(MOZILLA_HOME)
|
_sugar_la_LDFLAGS = -module -avoid-version -R$(MOZILLA_HOME)
|
||||||
_sugar_la_LIBADD = \
|
_sugar_la_LIBADD = \
|
||||||
$(LIB_LIBS) \
|
$(LIB_LIBS) \
|
||||||
|
$(PYCAIRO_LIBS) \
|
||||||
$(top_builddir)/lib/src/libsugarprivate.la
|
$(top_builddir)/lib/src/libsugarprivate.la
|
||||||
|
|
||||||
_sugar_la_SOURCES = \
|
_sugar_la_SOURCES = \
|
||||||
|
@ -247,6 +247,15 @@
|
|||||||
'("GdkPixbuf*" "pixbuf")
|
'("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 ...
|
;; Enumerations and flags ...
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,9 +13,11 @@ headers
|
|||||||
#include "sugar-download.h"
|
#include "sugar-download.h"
|
||||||
#include "sugar-audio-manager.h"
|
#include "sugar-audio-manager.h"
|
||||||
|
|
||||||
|
#include "pycairo.h"
|
||||||
#include <pygtk/pygtk.h>
|
#include <pygtk/pygtk.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
extern Pycairo_CAPI_t *Pycairo_CAPI;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
modulename gecko
|
modulename gecko
|
||||||
@ -159,3 +161,23 @@ _wrap_sugar_hippo_canvas_image_set_image_from_gdk_pixbuf(PyGObject *self, PyObje
|
|||||||
return Py_None;
|
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);
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||||
#include <pygobject.h>
|
#include <pygobject.h>
|
||||||
|
|
||||||
|
#include <pycairo.h>
|
||||||
|
Pycairo_CAPI_t *Pycairo_CAPI;
|
||||||
|
|
||||||
void py_sugar_register_classes (PyObject *d);
|
void py_sugar_register_classes (PyObject *d);
|
||||||
|
|
||||||
extern PyMethodDef py_sugar_functions[];
|
extern PyMethodDef py_sugar_functions[];
|
||||||
@ -16,6 +19,8 @@ init_sugar(void)
|
|||||||
|
|
||||||
init_pygobject ();
|
init_pygobject ();
|
||||||
|
|
||||||
|
Pycairo_IMPORT;
|
||||||
|
|
||||||
m = Py_InitModule ("_sugar", py_sugar_functions);
|
m = Py_InitModule ("_sugar", py_sugar_functions);
|
||||||
d = PyModule_GetDict (m);
|
d = PyModule_GetDict (m);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user