Merge gobject-branch into trunk
This commit is contained in:
91
bindings/python/Makefile.am
Normal file
91
bindings/python/Makefile.am
Normal file
@ -0,0 +1,91 @@
|
||||
AUTOMAKE_OPTIONS = 1.7
|
||||
|
||||
CLEANFILES =
|
||||
EXTRA_DIST =
|
||||
|
||||
CLUTTER_DEFS = clutter-base.defs
|
||||
CLUTTER_TYPES_DEFS = clutter-base-types.defs
|
||||
|
||||
CREATEDEFS = $(PYTHON) createdefs.py
|
||||
|
||||
CLUTTER_OVERRIDES = clutter.override
|
||||
|
||||
CLEANFILES += \
|
||||
clutter.defs \
|
||||
clutter-types.defs
|
||||
|
||||
EXTRA_DIST += \
|
||||
$(CLUTTER_DEFS) \
|
||||
$(CLUTTER_TYPES_DEFS) \
|
||||
$(CLUTTER_OVERRIDES)
|
||||
|
||||
clutter.defs: $(CLUTTER_DEFS)
|
||||
@echo "*** Creating clutter.defs" && \
|
||||
echo ";; -*- scheme -*-" > gen-cdefs && \
|
||||
echo ";; THIS FILE IS AUTOGENERATED" >> gen-cdefs && \
|
||||
for p in $(CLUTTER_DEFS); do \
|
||||
echo "(include \"$$p\")" >> gen-cdefs; \
|
||||
done && \
|
||||
(cmp -s gen-cdefs clutter.defs || cp gen-cdefs clutter.defs) && \
|
||||
rm -f gen-cdefs
|
||||
clutter.defs: Makefile
|
||||
|
||||
clutter-types.defs: $(CLUTTER_TYPES_DEFS)
|
||||
@echo "*** Creating clutter-types.defs" && \
|
||||
echo ";; -*- scheme -*-" > gen-ctdefs && \
|
||||
echo ";; THIS FILE IS AUTOGENERATED" >> gen-ctdefs && \
|
||||
for p in $(CLUTTER_TYPES_DEFS); do \
|
||||
echo "(include \"$$p\")" >> gen-ctdefs; \
|
||||
done && \
|
||||
(cmp -s gen-ctdefs clutter-types.defs || cp gen-ctdefs clutter-types.defs) && \
|
||||
rm -f gen-ctdefs
|
||||
clutter-types.defs: Makefile
|
||||
|
||||
clutter-pyglue.c: clutter.defs clutter-types.defs $(CLUTTER_OVERRIDES)
|
||||
$(PYGTK_CODEGEN) \
|
||||
--register $(PYGTK_DEFSDIR)/gdk-types.defs \
|
||||
--register $(PYGTK_DEFSDIR)/gtk-types.defs \
|
||||
--register $(PYGTK_DEFSDIR)/pango-types.defs \
|
||||
--register clutter-types.defs \
|
||||
--override $(CLUTTER_OVERRIDES) \
|
||||
--prefix clutter \
|
||||
clutter.defs > gen-$@ && \
|
||||
(cmp -s $@ gen-$@ || cp gen-$@ $@) && \
|
||||
rm -f gen-$@
|
||||
|
||||
CLEANFILES += clutter-pyglue.c
|
||||
|
||||
pythondir = $(libdir)/python${PY_VER}/site-packages
|
||||
python_LTLIBRARIES = clutter.la
|
||||
|
||||
INCLUDES = $(PYTHON_CFLAGS) $(PYGTK_CFLAGS) -I$(top_srcdir) $(CLUTTER_CFLAGS)
|
||||
|
||||
clutter_la_DEPENDENCIES = cluttermodule.c clutter-pyglue.c
|
||||
clutter_la_SOURCES = clutter-pyglue.c cluttermodule.c
|
||||
clutter_la_LIBADD = $(PYTHON_LIBS) $(PYGTK_LIBS) \
|
||||
$(top_builddir)/clutter/libclutter-@CLUTTER_MAJORMINOR@.la
|
||||
clutter_la_LDFLAGS = -module avoid-version -export-symbols-regex initclutter
|
||||
|
||||
# Run this to update the API and then copy then newly generated
|
||||
# definitions into clutter-base.defs and clutter-base-types.defs;
|
||||
# it's manual, as my might do some name mangling for static
|
||||
# methods.
|
||||
update-defs:
|
||||
$(PYTHON) $(PYGTK_CODEGENDIR)/h2def.py -v \
|
||||
$(top_srcdir)/clutter/clutter-keysyms.h \
|
||||
$(top_srcdir)/clutter/clutter-timeline.h \
|
||||
$(top_srcdir)/clutter/clutter-main.h \
|
||||
$(top_srcdir)/clutter/clutter-event.h \
|
||||
$(top_srcdir)/clutter/clutter-element.h \
|
||||
$(top_srcdir)/clutter/clutter-rectangle.h \
|
||||
$(top_srcdir)/clutter/clutter-texture.h \
|
||||
$(top_srcdir)/clutter/clutter-color.h \
|
||||
$(top_srcdir)/clutter/clutter-clone-texture.h \
|
||||
$(top_srcdir)/clutter/clutter-video-texture.h \
|
||||
$(top_srcdir)/clutter/clutter-label.h \
|
||||
$(top_srcdir)/clutter/clutter-group.h \
|
||||
$(top_srcdir)/clutter/clutter-stage.h \
|
||||
$(top_srcdir)/clutter/clutter-enum-types.h \
|
||||
> gen-cdefs && \
|
||||
(cmp -s gen-cdefs clutter-api.def || cp gen-cdefs clutter-api.def) && \
|
||||
rm -f gen-cdefs
|
207
bindings/python/clutter-base-types.defs
Normal file
207
bindings/python/clutter-base-types.defs
Normal file
@ -0,0 +1,207 @@
|
||||
;; -*- scheme -*-
|
||||
;;
|
||||
;; Try and keep everything sorted
|
||||
;;
|
||||
|
||||
;; Boxed types
|
||||
|
||||
(define-boxed ElementBox
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterElementBox")
|
||||
(gtype-id "CLUTTER_TYPE_ELEMENT_BOX")
|
||||
(fields
|
||||
'("gint" "x1")
|
||||
'("gint" "y1")
|
||||
'("gint" "x2")
|
||||
'("gint" "y2")
|
||||
)
|
||||
)
|
||||
|
||||
(define-boxed Geometry
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterGeometry")
|
||||
(gtype-id "CLUTTER_TYPE_GEOMETRY")
|
||||
(fields
|
||||
'("gint" "x")
|
||||
'("gint" "y")
|
||||
'("gint" "width")
|
||||
'("gint" "height")
|
||||
)
|
||||
)
|
||||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-flags ElementTransform
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterElementTransform")
|
||||
(gtype-id "CLUTTER_TYPE_ELEMENT_TRANSFORM")
|
||||
(values
|
||||
'("x" "CLUTTER_ELEMENT_MIRROR_X")
|
||||
'("y" "CLUTTER_ELEMENT_MIRROR_Y")
|
||||
)
|
||||
)
|
||||
|
||||
(define-flags ElementFlags
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterElementFlags")
|
||||
(gtype-id "CLUTTER_TYPE_ELEMENT_FLAGS")
|
||||
(values
|
||||
'("mapped" "CLUTTER_ELEMENT_MAPPED")
|
||||
'("realized" "CLUTTER_ELEMENT_REALIZED")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum EventType
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterEventType")
|
||||
(gtype-id "CLUTTER_TYPE_EVENT_TYPE")
|
||||
(values
|
||||
'("key-press" "CLUTTER_KEY_PRESS")
|
||||
'("key-release" "CLUTTER_KEY_RELEASE")
|
||||
'("motion" "CLUTTER_MOTION")
|
||||
'("button-press" "CLUTTER_BUTTON_PRESS")
|
||||
'("2button-press" "CLUTTER_2BUTTON_PRESS")
|
||||
'("button-release" "CLUTTER_BUTTON_RELEASE")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum VideoTextureAspectRatio
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterVideoTextureAspectRatio")
|
||||
(gtype-id "CLUTTER_TYPE_VIDEO_TEXTURE_ASPECT_RATIO")
|
||||
(values
|
||||
'("auto" "CLUTTER_VIDEO_TEXTURE_AUTO")
|
||||
'("square" "CLUTTER_VIDEO_TEXTURE_SQUARE")
|
||||
'("fourbythree" "CLUTTER_VIDEO_TEXTURE_FOURBYTHREE")
|
||||
'("anamorphic" "CLUTTER_VIDEO_TEXTURE_ANAMORPHIC")
|
||||
'("dvb" "CLUTTER_VIDEO_TEXTURE_DVB")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum VideoTextureError
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterVideoTextureError")
|
||||
(gtype-id "CLUTTER_TYPE_VIDEO_TEXTURE_ERROR")
|
||||
(values
|
||||
'("audio-plugin" "CLUTTER_VIDEO_TEXTURE_ERROR_AUDIO_PLUGIN")
|
||||
'("no-plugin-for-file" "CLUTTER_VIDEO_TEXTURE_ERROR_NO_PLUGIN_FOR_FILE")
|
||||
'("video-plugin" "CLUTTER_VIDEO_TEXTURE_ERROR_VIDEO_PLUGIN")
|
||||
'("audio-busy" "CLUTTER_VIDEO_TEXTURE_ERROR_AUDIO_BUSY")
|
||||
'("broken-file" "CLUTTER_VIDEO_TEXTURE_ERROR_BROKEN_FILE")
|
||||
'("file-generic" "CLUTTER_VIDEO_TEXTURE_ERROR_FILE_GENERIC")
|
||||
'("file-permission" "CLUTTER_VIDEO_TEXTURE_ERROR_FILE_PERMISSION")
|
||||
'("file-encrypted" "CLUTTER_VIDEO_TEXTURE_ERROR_FILE_ENCRYPTED")
|
||||
'("file-not-found" "CLUTTER_VIDEO_TEXTURE_ERROR_FILE_NOT_FOUND")
|
||||
'("dvd-encrypted" "CLUTTER_VIDEO_TEXTURE_ERROR_DVD_ENCRYPTED")
|
||||
'("invalid-device" "CLUTTER_VIDEO_TEXTURE_ERROR_INVALID_DEVICE")
|
||||
'("unknown-host" "CLUTTER_VIDEO_TEXTURE_ERROR_UNKNOWN_HOST")
|
||||
'("network-unreachable" "CLUTTER_VIDEO_TEXTURE_ERROR_NETWORK_UNREACHABLE")
|
||||
'("connection-refused" "CLUTTER_VIDEO_TEXTURE_ERROR_CONNECTION_REFUSED")
|
||||
'("unvalid-location" "CLUTTER_VIDEO_TEXTURE_ERROR_UNVALID_LOCATION")
|
||||
'("generic" "CLUTTER_VIDEO_TEXTURE_ERROR_GENERIC")
|
||||
'("codec-not-handled" "CLUTTER_VIDEO_TEXTURE_ERROR_CODEC_NOT_HANDLED")
|
||||
'("audio-only" "CLUTTER_VIDEO_TEXTURE_ERROR_AUDIO_ONLY")
|
||||
'("cannot-capture" "CLUTTER_VIDEO_TEXTURE_ERROR_CANNOT_CAPTURE")
|
||||
'("read-error" "CLUTTER_VIDEO_TEXTURE_ERROR_READ_ERROR")
|
||||
'("plugin-load" "CLUTTER_VIDEO_TEXTURE_ERROR_PLUGIN_LOAD")
|
||||
'("still-image" "CLUTTER_VIDEO_TEXTURE_ERROR_STILL_IMAGE")
|
||||
'("empty-file" "CLUTTER_VIDEO_TEXTURE_ERROR_EMPTY_FILE")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum VideoTextureMetadataType
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterVideoTextureMetadataType")
|
||||
(gtype-id "CLUTTER_TYPE_VIDEO_TEXTURE_METADATA_TYPE")
|
||||
(values
|
||||
'("title" "CLUTTER_INFO_TITLE")
|
||||
'("artist" "CLUTTER_INFO_ARTIST")
|
||||
'("year" "CLUTTER_INFO_YEAR")
|
||||
'("album" "CLUTTER_INFO_ALBUM")
|
||||
'("duration" "CLUTTER_INFO_DURATION")
|
||||
'("track-number" "CLUTTER_INFO_TRACK_NUMBER")
|
||||
'("has-video" "CLUTTER_INFO_HAS_VIDEO")
|
||||
'("dimension-x" "CLUTTER_INFO_DIMENSION_X")
|
||||
'("dimension-y" "CLUTTER_INFO_DIMENSION_Y")
|
||||
'("video-bitrate" "CLUTTER_INFO_VIDEO_BITRATE")
|
||||
'("video-codec" "CLUTTER_INFO_VIDEO_CODEC")
|
||||
'("fps" "CLUTTER_INFO_FPS")
|
||||
'("has-audio" "CLUTTER_INFO_HAS_AUDIO")
|
||||
'("audio-bitrate" "CLUTTER_INFO_AUDIO_BITRATE")
|
||||
'("audio-codec" "CLUTTER_INFO_AUDIO_CODEC")
|
||||
)
|
||||
)
|
||||
|
||||
;; Objects
|
||||
|
||||
(define-object Element
|
||||
(in-module "Clutter")
|
||||
(parent "GObject")
|
||||
(c-name "ClutterElement")
|
||||
(gtype-id "CLUTTER_TYPE_ELEMENT")
|
||||
)
|
||||
|
||||
(define-object CloneTexture
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterElement")
|
||||
(c-name "ClutterCloneTexture")
|
||||
(gtype-id "CLUTTER_TYPE_CLONE_TEXTURE")
|
||||
)
|
||||
|
||||
(define-object Group
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterElement")
|
||||
(c-name "ClutterGroup")
|
||||
(gtype-id "CLUTTER_TYPE_GROUP")
|
||||
)
|
||||
|
||||
(define-object Rectangle
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterElement")
|
||||
(c-name "ClutterRectangle")
|
||||
(gtype-id "CLUTTER_TYPE_RECTANGLE")
|
||||
)
|
||||
|
||||
(define-object Stage
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterGroup")
|
||||
(c-name "ClutterStage")
|
||||
(gtype-id "CLUTTER_TYPE_STAGE")
|
||||
)
|
||||
|
||||
(define-object Texture
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterElement")
|
||||
(c-name "ClutterTexture")
|
||||
(gtype-id "CLUTTER_TYPE_TEXTURE")
|
||||
)
|
||||
|
||||
(define-object Label
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterTexture")
|
||||
(c-name "ClutterLabel")
|
||||
(gtype-id "CLUTTER_TYPE_LABEL")
|
||||
)
|
||||
|
||||
(define-object Timeline
|
||||
(in-module "Clutter")
|
||||
(parent "GObject")
|
||||
(c-name "ClutterTimeline")
|
||||
(gtype-id "CLUTTER_TYPE_TIMELINE")
|
||||
)
|
||||
|
||||
(define-object VideoTexture
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterTexture")
|
||||
(c-name "ClutterVideoTexture")
|
||||
(gtype-id "CLUTTER_TYPE_VIDEO_TEXTURE")
|
||||
)
|
||||
|
||||
;; Pointers
|
||||
|
||||
|
||||
|
||||
;; Unsupported
|
||||
|
||||
|
||||
|
1073
bindings/python/clutter-base.defs
Normal file
1073
bindings/python/clutter-base.defs
Normal file
File diff suppressed because it is too large
Load Diff
500
bindings/python/clutter.override
Normal file
500
bindings/python/clutter.override
Normal file
@ -0,0 +1,500 @@
|
||||
/* -*- C -*- */
|
||||
%%
|
||||
headers
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#include "pygobject.h"
|
||||
#include <clutter/clutter-keysyms.h>
|
||||
#include <clutter/clutter-event.h>
|
||||
#include <clutter/clutter-main.h>
|
||||
#include <clutter/clutter-timeline.h>
|
||||
#include <clutter/clutter-stage.h>
|
||||
#include <clutter/clutter-color.h>
|
||||
#include <clutter/clutter-element.h>
|
||||
#include <clutter/clutter-rectangle.h>
|
||||
#include <clutter/clutter-group.h>
|
||||
#include <clutter/clutter-texture.h>
|
||||
#include <clutter/clutter-clone-texture.h>
|
||||
#include <clutter/clutter-video-texture.h>
|
||||
#include <clutter/clutter-label.h>
|
||||
#include <clutter/clutter-util.h>
|
||||
#include <clutter/clutter-enum-types.h>
|
||||
%%
|
||||
modulename clutter
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
|
||||
%%
|
||||
ignore
|
||||
clutter_video_texture_error_quark
|
||||
clutter_group_add_many_valist
|
||||
clutter_stage_get_xwindow
|
||||
clutter_init
|
||||
clutter_xdisplay
|
||||
clutter_root_xwindow
|
||||
clutter_gl_context
|
||||
%%
|
||||
ignore-glob
|
||||
*_get_type
|
||||
%%
|
||||
override clutter_geometry_new kwargs
|
||||
static int
|
||||
_wrap_clutter_geometry_new (PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "x", "y", "width", "height", NULL };
|
||||
ClutterGeometry geom = { 0, 0, 0, 0 };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"|iiii:ClutterGeometry.__init__",
|
||||
kwlist,
|
||||
&(geom.x), &(geom.y),
|
||||
&(geom.width), &(geom.height)))
|
||||
return -1;
|
||||
|
||||
self->boxed = g_boxed_copy (CLUTTER_TYPE_GEOMETRY, &geom);
|
||||
self->free_on_dealloc = TRUE;
|
||||
self->gtype = CLUTTER_TYPE_GEOMETRY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-slot ClutterGeometry.tp_as_sequence
|
||||
static int
|
||||
_wrap_clutter_geometry_length (PyGBoxed *self)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
static PyObject *
|
||||
_wrap_clutter_geometry_getitem(PyGBoxed *self, int pos)
|
||||
{
|
||||
ClutterGeometry *geom;
|
||||
|
||||
if (pos < 0)
|
||||
pos += 4;
|
||||
|
||||
if (pos < 0 || pos >= 4) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
geom = pyg_boxed_get (self, ClutterGeometry);
|
||||
switch (pos) {
|
||||
case 0: return PyInt_FromLong (geom->x);
|
||||
case 1: return PyInt_FromLong (geom->y);
|
||||
case 2: return PyInt_FromLong (geom->width);
|
||||
case 3: return PyInt_FromLong (geom->height);
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
static int
|
||||
_wrap_clutter_geometry_setitem (PyGBoxed *self, int pos, PyObject *value)
|
||||
{
|
||||
ClutterGeometry *geom;
|
||||
gint val;
|
||||
|
||||
if (pos < 0)
|
||||
pos += 4;
|
||||
|
||||
if (pos < 0 || pos >= 4) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
geom = pyg_boxed_get (self, ClutterGeometry);
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
switch(pos) {
|
||||
case 0: geom->x = val; break;
|
||||
case 1: geom->y = val; break;
|
||||
case 2: geom->width = val; break;
|
||||
case 3: geom->height = val; break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static PySequenceMethods _wrap_clutter_geometry_tp_as_sequence = {
|
||||
(inquiry) _wrap_clutter_geometry_length,
|
||||
(binaryfunc) 0,
|
||||
(intargfunc) 0,
|
||||
(intargfunc) _wrap_clutter_geometry_getitem,
|
||||
(intintargfunc) 0,
|
||||
(intobjargproc) _wrap_clutter_geometry_setitem,
|
||||
(intintobjargproc) 0
|
||||
};
|
||||
%%
|
||||
override-attr ClutterGeometry.x
|
||||
static int
|
||||
_wrap_clutter_geomtry__set_x (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterGeometry)->x = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterGeometry.y
|
||||
static int
|
||||
_wrap_clutter_geometry__set_y (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterGeometry)->y = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterGeometry.width
|
||||
static int
|
||||
_wrap_clutter_geometry__set_width (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get(self, ClutterGeometry)->width = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterGeometry.height
|
||||
static int
|
||||
_wrap_clutter_geometry__set_height (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterGeometry)->height = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override clutter_element_box_new kwargs
|
||||
static int
|
||||
_wrap_clutter_element_box_new (PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "x1", "y1", "x2", "y2", NULL };
|
||||
ClutterElementBox box = { 0, 0, 0, 0 };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"|iiii:ClutterElementBox.__init__",
|
||||
kwlist,
|
||||
&(box.x1), &(box.y1),
|
||||
&(box.x2), &(box.y2)))
|
||||
return -1;
|
||||
|
||||
self->boxed = g_boxed_copy (CLUTTER_TYPE_ELEMENT_BOX, &box);
|
||||
self->free_on_dealloc = TRUE;
|
||||
self->gtype = CLUTTER_TYPE_ELEMENT_BOX;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-slot ClutterElementBox.tp_as_sequence
|
||||
static int
|
||||
_wrap_clutter_element_box_length (PyGBoxed *self)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
static PyObject *
|
||||
_wrap_clutter_element_box_getitem(PyGBoxed *self, int pos)
|
||||
{
|
||||
ClutterElementBox *box;
|
||||
|
||||
if (pos < 0)
|
||||
pos += 4;
|
||||
|
||||
if (pos < 0 || pos >= 4) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
box = pyg_boxed_get (self, ClutterElementBox);
|
||||
switch (pos) {
|
||||
case 0: return PyInt_FromLong (box->x1);
|
||||
case 1: return PyInt_FromLong (box->y1);
|
||||
case 2: return PyInt_FromLong (box->x2);
|
||||
case 3: return PyInt_FromLong (box->y2);
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
static int
|
||||
_wrap_clutter_element_box_setitem (PyGBoxed *self, int pos, PyObject *value)
|
||||
{
|
||||
ClutterElementBox *box;
|
||||
gint val;
|
||||
|
||||
if (pos < 0)
|
||||
pos += 4;
|
||||
|
||||
if (pos < 0 || pos >= 4) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
box = pyg_boxed_get (self, ClutterElementBox);
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
switch(pos) {
|
||||
case 0: box->x1 = val; break;
|
||||
case 1: box->y1 = val; break;
|
||||
case 2: box->x2 = val; break;
|
||||
case 3: box->y2 = val; break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static PySequenceMethods _wrap_clutter_element_box_tp_as_sequence = {
|
||||
(inquiry) _wrap_clutter_element_box_length,
|
||||
(binaryfunc) 0,
|
||||
(intargfunc) 0,
|
||||
(intargfunc) _wrap_clutter_element_box_getitem,
|
||||
(intintargfunc) 0,
|
||||
(intobjargproc) _wrap_clutter_element_box_setitem,
|
||||
(intintobjargproc) 0
|
||||
};
|
||||
%%
|
||||
override-attr ClutterElementBox.x1
|
||||
static int
|
||||
_wrap_clutter_element_box__set_x1 (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterElementBox)->x1 = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterElementBox.y1
|
||||
static int
|
||||
_wrap_clutter_element_box__set_y1 (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterElementBox)->y1 = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterElementBox.x2
|
||||
static int
|
||||
_wrap_clutter_element_box__set_x2 (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get(self, ClutterElementBox)->x2 = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterElementBox.y2
|
||||
static int
|
||||
_wrap_clutter_element_box__set_y2 (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterElementBox)->y2 = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override clutter_element_get_coords
|
||||
static PyObject *
|
||||
_wrap_clutter_element_get_coords (PyGObject *self)
|
||||
{
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
clutter_element_get_coords (CLUTTER_ELEMENT (self->obj),
|
||||
&x1, &y1,
|
||||
&x2, &y2);
|
||||
return Py_BuildValue("(iiii)", x1, y1, x2, y2);
|
||||
}
|
||||
%%
|
||||
override clutter_element_get_abs_position
|
||||
static PyObject *
|
||||
_wrap_clutter_element_get_abs_position (PyGObject *self)
|
||||
{
|
||||
gint pos_x, pos_y;
|
||||
|
||||
clutter_element_get_abs_position (CLUTTER_ELEMENT (self->obj),
|
||||
&pos_x,
|
||||
&pos_y);
|
||||
return Py_BuildValue("(ii)", pos_x, pos_y);
|
||||
}
|
||||
%%
|
||||
override clutter_texture_get_base_size
|
||||
static PyObject *
|
||||
_wrap_clutter_texture_get_base_size (PyGObject *self)
|
||||
{
|
||||
gint width, height;
|
||||
|
||||
clutter_texture_get_base_size (CLUTTER_TEXTURE (self->obj),
|
||||
&width,
|
||||
&height);
|
||||
return Py_BuildValue ("(ii)", width, height);
|
||||
}
|
||||
%%
|
||||
override clutter_texture_get_n_tiles
|
||||
static PyObject *
|
||||
_wrap_clutter_texture_get_n_tiles (PyGObject *self)
|
||||
{
|
||||
gint n_x_tiles, n_y_tiles;
|
||||
|
||||
clutter_texture_get_n_tiles (CLUTTER_TEXTURE (self->obj),
|
||||
&n_x_tiles,
|
||||
&n_y_tiles);
|
||||
return Py_BuildValue ("(ii)", n_x_tiles, n_y_tiles);
|
||||
}
|
||||
%%
|
||||
override clutter_texture_get_x_tile_detail kwargs
|
||||
static PyObject *
|
||||
_wrap_clutter_texture_get_x_tile_detail (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "x_index", NULL };
|
||||
gint x_index;
|
||||
gint pos, size, waste;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs,
|
||||
"i:ClutterTexture.get_x_tile_detail",
|
||||
kwlist, &x_index))
|
||||
return NULL;
|
||||
|
||||
clutter_texture_get_x_tile_detail (CLUTTER_TEXTURE (self->obj),
|
||||
x_index,
|
||||
&pos, &size, &waste);
|
||||
return Py_BuildValue ("(iii)", pos, size, waste);
|
||||
}
|
||||
%%
|
||||
override clutter_texture_get_y_tile_detail kwargs
|
||||
static PyObject *
|
||||
_wrap_clutter_texture_get_y_tile_detail (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "y_index", NULL };
|
||||
gint y_index;
|
||||
gint pos, size, waste;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs,
|
||||
"i:ClutterTexture.get_y_tile_detail",
|
||||
kwlist, &y_index))
|
||||
return NULL;
|
||||
|
||||
clutter_texture_get_y_tile_detail (CLUTTER_TEXTURE (self->obj),
|
||||
y_index,
|
||||
&pos, &size, &waste);
|
||||
return Py_BuildValue ("(iii)", pos, size, waste);
|
||||
}
|
||||
%%
|
||||
override clutter_group_add_many
|
||||
static PyObject *
|
||||
_wrap_clutter_group_add_many (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterGroup *group;
|
||||
int i, len;
|
||||
|
||||
if ((len = PyTuple_Size(args)) < 1) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"requires at least one argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
group = CLUTTER_GROUP (self->obj);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
PyGObject *pyelement;
|
||||
ClutterElement *element;
|
||||
|
||||
pyelement = (PyGObject *) PyTuple_GetItem (args, i);
|
||||
if (!pygobject_check (pyelement, &PyClutterElement_Type)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"Expected a ClutterElement");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
element = CLUTTER_ELEMENT (pyelement->obj);
|
||||
|
||||
clutter_group_add (group, element);
|
||||
}
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_main noargs
|
||||
static PyObject *
|
||||
_wrap_clutter_main (PyObject *self)
|
||||
{
|
||||
pyg_begin_allow_threads;
|
||||
clutter_main ();
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (PyErr_Occurred ())
|
||||
return NULL;
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_threads_enter noargs
|
||||
static PyObject *
|
||||
_wrap_clutter_threads_enter (PyObject *self)
|
||||
{
|
||||
/* must allow threads while acquiring lock, or no other python
|
||||
* code will execute while we wait! */
|
||||
pyg_begin_allow_threads;
|
||||
clutter_threads_enter ();
|
||||
pyg_end_allow_threads;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
26
bindings/python/cluttermodule.c
Normal file
26
bindings/python/cluttermodule.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <pygobject.h>
|
||||
/* #include <pygtk/pygtk.h> */
|
||||
|
||||
void clutter_register_classes (PyObject *d);
|
||||
extern PyMethodDef clutter_functions[];
|
||||
|
||||
DL_EXPORT (void)
|
||||
initclutter (void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
init_pygobject ();
|
||||
/* init_pygtk(); */
|
||||
|
||||
m = Py_InitModule ("clutter", clutter_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
clutter_register_classes (d);
|
||||
|
||||
if (PyErr_Occurred ())
|
||||
{
|
||||
Py_FatalError ("can't initialise module clutter");
|
||||
}
|
||||
else
|
||||
clutter_init(NULL, NULL);
|
||||
}
|
Reference in New Issue
Block a user