2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h: * clutter-color.c: Reimplement ClutterColor as a boxed type; add convenience API for color handling, like: add, subtract, shade, HSL color-space conversion, packing and unpacking. * clutter-private.h: Update ClutterMainContext, and export the main context pointer here. * clutter-rectangle.h: * clutter-rectangle.c: Update the color-related code; make clutter_rectangle_new() and empty constructor and provide clutter_rectangle_new_with_color(); provide color setter and getter API. * clutter-label.h: * clutter-label.c: Rename the "font" property to "font-name"; update the color-related code to the new ClutterColor object; rename clutter_label_new() to clutter_label_new_with_text(), and add setters and getters for the properties. * clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers generators. * clutter-stage.h: * clutter-stage.c: Rework the API: provide a default constructor for a singleton object, named clutter_stage_get_default(), which supercedes the clutter_stage() function in clutter-main; provide new events: button-press-event, button-release-event, key-press-event and key-release-event; update the color-related code; (clutter_stage_snapshot): Allow negative width and height when taking a snapshot (meaning: use full width/height). (clutter_stage_get_element_at_pos): Rename clutter_stage_pick(). * clutter-element.c (clutter_element_paint): Clean up the stage and color related code. * clutter-event.h: * clutter-event.c: Add generic ClutterAnyEvent type; add clutter_event_new(), clutter_event_copy() and clutter_event_free(); make ClutterEvent a boxed type. * clutter-main.h: * clutter-main.c: Remove clutter_stage(); add clutter_main_quit(), for cleanly quitting from clutter_main(); add multiple mainloops support; allocate the ClutterCntx instead of adding it to the stack; re-work the ClutterEvent dispatching. * clutter-group.c (clutter_group_add), (clutter_group_remove): Keep a reference on the element when added to a ClutterGroup. * examples/rects.py * examples/test.c: * examples/test-text.c: * examples/video-cube.c: * examples/super-oh.c: * examples/test-video.c: Update.
This commit is contained in:
@ -5,6 +5,18 @@
|
||||
|
||||
;; Boxed types
|
||||
|
||||
(define-boxed Color
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterColor")
|
||||
(gtype-id "CLUTTER_TYPE_COLOR")
|
||||
(fields
|
||||
'("guint8" "red")
|
||||
'("guint8" "green")
|
||||
'("guint8" "blue")
|
||||
'("guint8" "alpha")
|
||||
)
|
||||
)
|
||||
|
||||
(define-boxed ElementBox
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterElementBox")
|
||||
@ -17,6 +29,15 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define-boxed Event
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterEvent")
|
||||
(gtype-id "CLUTTER_TYPE_EVENT")
|
||||
(fields
|
||||
'("ClutterEventType" "type")
|
||||
)
|
||||
)
|
||||
|
||||
(define-boxed Geometry
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterGeometry")
|
||||
@ -31,16 +52,6 @@
|
||||
|
||||
;; 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")
|
||||
@ -51,11 +62,22 @@
|
||||
)
|
||||
)
|
||||
|
||||
(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-enum EventType
|
||||
(in-module "Clutter")
|
||||
(c-name "ClutterEventType")
|
||||
(gtype-id "CLUTTER_TYPE_EVENT_TYPE")
|
||||
(values
|
||||
'("nothing" "CLUTTER_NOTHING")
|
||||
'("key-press" "CLUTTER_KEY_PRESS")
|
||||
'("key-release" "CLUTTER_KEY_RELEASE")
|
||||
'("motion" "CLUTTER_MOTION")
|
||||
@ -134,13 +156,6 @@
|
||||
|
||||
;; 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")
|
||||
@ -148,6 +163,13 @@
|
||||
(gtype-id "CLUTTER_TYPE_CLONE_TEXTURE")
|
||||
)
|
||||
|
||||
(define-object Element
|
||||
(in-module "Clutter")
|
||||
(parent "GObject")
|
||||
(c-name "ClutterElement")
|
||||
(gtype-id "CLUTTER_TYPE_ELEMENT")
|
||||
)
|
||||
|
||||
(define-object Group
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterElement")
|
||||
@ -155,6 +177,13 @@
|
||||
(gtype-id "CLUTTER_TYPE_GROUP")
|
||||
)
|
||||
|
||||
(define-object Label
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterTexture")
|
||||
(c-name "ClutterLabel")
|
||||
(gtype-id "CLUTTER_TYPE_LABEL")
|
||||
)
|
||||
|
||||
(define-object Rectangle
|
||||
(in-module "Clutter")
|
||||
(parent "ClutterElement")
|
||||
@ -176,13 +205,6 @@
|
||||
(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")
|
||||
|
@ -113,9 +113,9 @@
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-function stage
|
||||
(c-name "clutter_stage")
|
||||
(return-type "ClutterGroup*")
|
||||
(define-function main_quit
|
||||
(c-name "clutter_main_quit")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-function redraw
|
||||
@ -164,6 +164,27 @@
|
||||
|
||||
;; From ../../clutter/clutter-event.h
|
||||
|
||||
(define-function clutter_event_new
|
||||
(c-name "clutter_event_new")
|
||||
(is-constructor-of "ClutterEvent")
|
||||
(return-type "ClutterEvent*")
|
||||
(parameters
|
||||
'("ClutterEventType" "type")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method copy
|
||||
(of-object "ClutterEvent")
|
||||
(c-name "clutter_event_copy")
|
||||
(return-type "ClutterEvent*")
|
||||
)
|
||||
|
||||
(define-method free
|
||||
(of-object "ClutterEvent")
|
||||
(c-name "clutter_event_free")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method type
|
||||
(of-object "ClutterKeyEvent")
|
||||
(c-name "clutter_key_event_type")
|
||||
@ -217,22 +238,22 @@
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function geometry_new
|
||||
(c-name "clutter_geometry_new")
|
||||
(is-constructor-of "ClutterGeometry")
|
||||
(return-type "ClutterGeometry")
|
||||
)
|
||||
;;(define-function geometry_new
|
||||
;; (c-name "clutter_geometry_new")
|
||||
;; (is-constructor-of "ClutterGeometry")
|
||||
;; (return-type "ClutterGeometry")
|
||||
;;)
|
||||
|
||||
(define-function clutter_element_box_get_type
|
||||
(c-name "clutter_element_box_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function element_box_new
|
||||
(c-name "clutter_element_box_new")
|
||||
(is-constructor-of "ClutterElementBox")
|
||||
(return-type "ClutterElementBox")
|
||||
)
|
||||
;;(define-function element_box_new
|
||||
;; (c-name "clutter_element_box_new")
|
||||
;; (is-constructor-of "ClutterElementBox")
|
||||
;; (return-type "ClutterElementBox")
|
||||
;;)
|
||||
|
||||
(define-function clutter_element_get_type
|
||||
(c-name "clutter_element_get_type")
|
||||
@ -513,17 +534,36 @@
|
||||
|
||||
;; From ../../clutter/clutter-rectangle.h
|
||||
|
||||
(define-function clutter_rectangle_get_type
|
||||
(c-name "clutter_rectangle_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function clutter_rectangle_new
|
||||
(c-name "clutter_rectangle_new")
|
||||
(is-constructor-of "ClutterRectangle")
|
||||
(return-type "ClutterElement*")
|
||||
)
|
||||
|
||||
(define-function clutter_rectangle_new_with_color
|
||||
(c-name "clutter_rectangle_new_with_color")
|
||||
(is-constructor-of "ClutterRectangle")
|
||||
(return-type "ClutterElement*")
|
||||
(properties
|
||||
'("color" (argname "col"))
|
||||
'("color" (argname "color"))
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_color
|
||||
(of-object "ClutterRectangle")
|
||||
(c-name "clutter_rectangle_get_color")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor*" "color")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_color
|
||||
(of-object "ClutterRectangle")
|
||||
(c-name "clutter_rectangle_set_color")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-ClutterColor*" "color")
|
||||
)
|
||||
)
|
||||
|
||||
@ -634,41 +674,97 @@
|
||||
|
||||
;; From ../../clutter/clutter-color.h
|
||||
|
||||
(define-function clutter_color_new
|
||||
(c-name "clutter_color_new")
|
||||
(return-type "ClutterColor")
|
||||
(define-function clutter_color_get_type
|
||||
(c-name "clutter_color_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method add
|
||||
(of-object "ClutterColor")
|
||||
(c-name "clutter_color_add")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint8" "r")
|
||||
'("guint8" "g")
|
||||
'("guint8" "b")
|
||||
'("guint8" "a")
|
||||
'("ClutterColor*" "src2")
|
||||
'("ClutterColor*" "dest")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set
|
||||
(define-method subtract
|
||||
(of-object "ClutterColor")
|
||||
(c-name "clutter_color_set")
|
||||
(c-name "clutter_color_subtract")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint8" "r")
|
||||
'("guint8" "g")
|
||||
'("guint8" "b")
|
||||
'("guint8" "a")
|
||||
'("ClutterColor*" "src2")
|
||||
'("ClutterColor*" "dest")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get
|
||||
(define-method lighten
|
||||
(of-object "ClutterColor")
|
||||
(c-name "clutter_color_get")
|
||||
(c-name "clutter_color_lighten")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint8*" "r")
|
||||
'("guint8*" "g")
|
||||
'("guint8*" "b")
|
||||
'("guint8*" "a")
|
||||
'("ClutterColor*" "dest")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method darken
|
||||
(of-object "ClutterColor")
|
||||
(c-name "clutter_color_darken")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor*" "dest")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method shade
|
||||
(of-object "ClutterColor")
|
||||
(c-name "clutter_color_shade")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor*" "dest")
|
||||
'("gdouble" "shade")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function color_to_hls
|
||||
(c-name "clutter_color_to_hls")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint8*" "hue")
|
||||
'("guint8*" "luminance")
|
||||
'("guint8*" "saturation")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function color_from_hls
|
||||
(c-name "clutter_color_from_hls")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint8" "hue")
|
||||
'("guint8" "luminance")
|
||||
'("guint8" "saturation")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function color_to_pixel
|
||||
(c-name "clutter_color_to_pixel")
|
||||
(return-type "guint32")
|
||||
(parameters
|
||||
'("ClutterColor" "src")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function color_from_pixel
|
||||
(c-name "clutter_color_from_pixel")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor" "dest")
|
||||
'("guint32" "pixel")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
;; From ../../clutter/clutter-clone-texture.h
|
||||
@ -850,21 +946,22 @@
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function clutter_label_new_with_text
|
||||
(c-name "clutter_label_new_with_text")
|
||||
(return-type "ClutterElement*")
|
||||
(parameters
|
||||
'("const-gchar*" "font_desc")
|
||||
'("const-gchar*" "text")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function clutter_label_new
|
||||
(c-name "clutter_label_new")
|
||||
(is-constructor-of "ClutterLabel")
|
||||
(return-type "ClutterElement*")
|
||||
)
|
||||
|
||||
(define-function clutter_label_new_with_text
|
||||
(c-name "clutter_label_new_with_text")
|
||||
(return-type "ClutterElement*")
|
||||
(is-constructor-of "ClutterLabel")
|
||||
(properties
|
||||
'("font-name" (argname "name") (optional))
|
||||
'("text" (argname "str") (optional))
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_text
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_set_text")
|
||||
@ -874,21 +971,42 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_font
|
||||
(define-method get_text
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_set_font")
|
||||
(c-name "clutter_label_get_text")
|
||||
(return-type "const-gchar*")
|
||||
)
|
||||
|
||||
(define-method set_font_name
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_set_font_name")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-gchar*" "desc")
|
||||
'("const-gchar*" "font_name")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_font_name
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_get_font_name")
|
||||
(return-type "const-gchar*")
|
||||
)
|
||||
|
||||
(define-method set_color
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_set_color")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint32" "pixel")
|
||||
'("const-ClutterColor*" "color")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_color
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_get_color")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor*" "color")
|
||||
)
|
||||
)
|
||||
|
||||
@ -902,6 +1020,16 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_text_extents
|
||||
(of-object "ClutterLabel")
|
||||
(c-name "clutter_label_get_text_extents")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gint*" "width")
|
||||
'("gint*" "height")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From ../../clutter/clutter-group.h
|
||||
@ -1005,6 +1133,11 @@
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function stage_get_default
|
||||
(c-name "clutter_stage_get_default")
|
||||
(return-type "ClutterElement*")
|
||||
)
|
||||
|
||||
(define-method get_xwindow
|
||||
(of-object "ClutterStage")
|
||||
(c-name "clutter_stage_get_xwindow")
|
||||
@ -1016,19 +1149,22 @@
|
||||
(c-name "clutter_stage_set_color")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor" "color")
|
||||
'("const-ClutterColor*" "color")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_color
|
||||
(of-object "ClutterStage")
|
||||
(c-name "clutter_stage_get_color")
|
||||
(return-type "ClutterColor")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("ClutterColor*" "color")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method pick
|
||||
(define-method get_element_at_pos
|
||||
(of-object "ClutterStage")
|
||||
(c-name "clutter_stage_pick")
|
||||
(c-name "clutter_stage_get_element_at_pos")
|
||||
(return-type "ClutterElement*")
|
||||
(parameters
|
||||
'("gint" "x")
|
||||
@ -1036,6 +1172,18 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define-method snapshot
|
||||
(of-object "ClutterStage")
|
||||
(c-name "clutter_stage_snapshot")
|
||||
(return-type "GdkPixbuf*")
|
||||
(parameters
|
||||
'("gint" "x")
|
||||
'("gint" "y")
|
||||
'("gint" "width")
|
||||
'("gint" "height")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From ../../clutter/clutter-enum-types.h
|
||||
|
@ -26,6 +26,7 @@ import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
|
||||
%%
|
||||
ignore
|
||||
clutter_video_texture_error_quark
|
||||
clutter_video_texture_get_metadata
|
||||
clutter_group_add_many_valist
|
||||
clutter_stage_get_xwindow
|
||||
clutter_init
|
||||
@ -132,7 +133,7 @@ static PySequenceMethods _wrap_clutter_geometry_tp_as_sequence = {
|
||||
%%
|
||||
override-attr ClutterGeometry.x
|
||||
static int
|
||||
_wrap_clutter_geomtry__set_x (PyGBoxed *self, PyObject *value, void *closure)
|
||||
_wrap_clutter_geometry__set_x (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
@ -485,6 +486,22 @@ _wrap_clutter_main (PyObject *self)
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_main_quit
|
||||
static PyObject *
|
||||
_wrap_clutter_main_quit (PyObject *self, PyObject *args)
|
||||
{
|
||||
/* sanity check to make sure we are in a main loop */
|
||||
if (clutter_main_level () == 0) {
|
||||
PyErr_SetString (PyExc_RuntimeError,
|
||||
"called outside of a mainloop");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clutter_main_quit ();
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_threads_enter noargs
|
||||
static PyObject *
|
||||
_wrap_clutter_threads_enter (PyObject *self)
|
||||
@ -498,3 +515,487 @@ _wrap_clutter_threads_enter (PyObject *self)
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_color_new kwargs
|
||||
static int
|
||||
_wrap_clutter_color_new (PyGBoxed *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "red", "green", "blue", "alpha", NULL };
|
||||
ClutterColor color = { 0, 0, 0, 0 };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"|iiii:ClutterColor.__init__",
|
||||
kwlist,
|
||||
&(color.red),
|
||||
&(color.green),
|
||||
&(color.blue),
|
||||
&(color.alpha)))
|
||||
return -1;
|
||||
|
||||
self->boxed = g_boxed_copy (CLUTTER_TYPE_COLOR, &color);
|
||||
self->free_on_dealloc = TRUE;
|
||||
self->gtype = CLUTTER_TYPE_COLOR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-slot ClutterColor.tp_as_sequence
|
||||
static int
|
||||
_wrap_clutter_color_length (PyGBoxed *self)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
static PyObject *
|
||||
_wrap_clutter_color_getitem (PyGBoxed *self, int pos)
|
||||
{
|
||||
ClutterColor *color;
|
||||
|
||||
if (pos < 0)
|
||||
pos += 4;
|
||||
|
||||
if (pos < 0 || pos >= 4) {
|
||||
PyErr_SetString (PyExc_IndexError, "index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color = pyg_boxed_get (self, ClutterColor);
|
||||
switch (pos) {
|
||||
case 0: return PyInt_FromLong (color->red);
|
||||
case 1: return PyInt_FromLong (color->green);
|
||||
case 2: return PyInt_FromLong (color->blue);
|
||||
case 3: return PyInt_FromLong (color->alpha);
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
static int
|
||||
_wrap_clutter_color_setitem (PyGBoxed *self, int pos, PyObject *value)
|
||||
{
|
||||
ClutterColor *color;
|
||||
gint val;
|
||||
|
||||
if (pos < 0)
|
||||
pos += 4;
|
||||
|
||||
if (pos < 0 || pos >= 4) {
|
||||
PyErr_SetString (PyExc_IndexError, "index out of range");
|
||||
return -1;
|
||||
}
|
||||
|
||||
color = pyg_boxed_get (self, ClutterColor);
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
switch (pos) {
|
||||
case 0: color->red = val; break;
|
||||
case 1: color->green = val; break;
|
||||
case 2: color->blue = val; break;
|
||||
case 3: color->alpha = val; break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static PySequenceMethods _wrap_clutter_color_tp_as_sequence = {
|
||||
(inquiry) _wrap_clutter_color_length,
|
||||
(binaryfunc) 0,
|
||||
(intargfunc) 0,
|
||||
(intargfunc) _wrap_clutter_color_getitem,
|
||||
(intintargfunc) 0,
|
||||
(intobjargproc) _wrap_clutter_color_setitem,
|
||||
(intintobjargproc) 0
|
||||
};
|
||||
%%
|
||||
override-attr ClutterColor.red
|
||||
static int
|
||||
_wrap_clutter_color__set_red (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterColor)->red = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterColor.green
|
||||
static int
|
||||
_wrap_clutter_color__set_green (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterColor)->green = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterColor.blue
|
||||
static int
|
||||
_wrap_clutter_color__set_blue (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get(self, ClutterColor)->blue = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr ClutterColor.alpha
|
||||
static int
|
||||
_wrap_clutter_color__set_alpha (PyGBoxed *self, PyObject *value, void *closure)
|
||||
{
|
||||
gint val;
|
||||
|
||||
val = PyInt_AsLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
pyg_boxed_get (self, ClutterColor)->alpha = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override clutter_stage_set_color
|
||||
static PyObject *
|
||||
_wrap_clutter_stage_set_color (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
int len, i;
|
||||
|
||||
if (PyTuple_Size (args) != 4) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a tuple of 4 integers: (r, g, b, a)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
PyObject *comp = PyTuple_GetItem (args, i);
|
||||
|
||||
if (!PyInt_Check (comp)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"component is not an integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0: color.red = (guint8) PyInt_AsLong (comp); break;
|
||||
case 1: color.green = (guint8) PyInt_AsLong (comp); break;
|
||||
case 2: color.blue = (guint8) PyInt_AsLong (comp); break;
|
||||
case 3: color.alpha = (guint8) PyInt_AsLong (comp); break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clutter_stage_set_color (CLUTTER_STAGE (self->obj), &color);
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_stage_get_color
|
||||
static PyObject *
|
||||
_wrap_clutter_stage_get_color (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
|
||||
clutter_stage_get_color (CLUTTER_STAGE (self->obj), &color);
|
||||
|
||||
return Py_BuildValue ("(iiii)", color.red,
|
||||
color.green,
|
||||
color.blue,
|
||||
color.alpha);
|
||||
}
|
||||
%%
|
||||
override clutter_color_to_hls
|
||||
static PyObject *
|
||||
_wrap_clutter_color_to_hls (PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
guint8 h, l, s;
|
||||
int i;
|
||||
|
||||
if (PyTuple_Size (args) != 4) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a tuple of 4 integers: (r, g, b, a)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
PyObject *comp = PyTuple_GetItem (args, i);
|
||||
|
||||
if (!PyInt_Check (comp)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"component is not an integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0: color.red = (guint8) PyInt_AsLong (comp); break;
|
||||
case 1: color.green = (guint8) PyInt_AsLong (comp); break;
|
||||
case 2: color.blue = (guint8) PyInt_AsLong (comp); break;
|
||||
case 3: color.alpha = (guint8) PyInt_AsLong (comp); break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clutter_color_to_hls (&color, &h, &l, &s);
|
||||
|
||||
return Py_BuildValue ("(iii)", (int) h, (int) l, (int) s);
|
||||
}
|
||||
%%
|
||||
override clutter_color_from_hls
|
||||
static PyObject *
|
||||
_wrap_clutter_color_from_hls (PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
guint8 h, l, s;
|
||||
int i;
|
||||
|
||||
if (PyTuple_Size (args) != 3) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a tuple of 3 integers: (h, l, s)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
PyObject *comp = PyTuple_GetItem (args, i);
|
||||
|
||||
if (!PyInt_Check (comp)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"component is not an integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0: h = (guint8) PyInt_AsLong (comp); break;
|
||||
case 1: l = (guint8) PyInt_AsLong (comp); break;
|
||||
case 2: s = (guint8) PyInt_AsLong (comp); break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clutter_color_from_hls (&color, h, l, s);
|
||||
|
||||
return Py_BuildValue ("(iiii)",
|
||||
(int) color.red,
|
||||
(int) color.green,
|
||||
(int) color.blue,
|
||||
(int) color.alpha);
|
||||
}
|
||||
%%
|
||||
override clutter_color_to_pixel
|
||||
static PyObject *
|
||||
_wrap_clutter_color_to_pixel (PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
guint32 pixel;
|
||||
int i;
|
||||
|
||||
if (PyTuple_Size (args) != 4) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a tuple of 4 integers: (r, g, b, a)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
PyObject *comp = PyTuple_GetItem (args, i);
|
||||
|
||||
if (!PyInt_Check (comp)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"component is not an integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0: color.red = (guint8) PyInt_AsLong (comp); break;
|
||||
case 1: color.green = (guint8) PyInt_AsLong (comp); break;
|
||||
case 2: color.blue = (guint8) PyInt_AsLong (comp); break;
|
||||
case 3: color.alpha = (guint8) PyInt_AsLong (comp); break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pixel = clutter_color_to_pixel (&color);
|
||||
|
||||
return PyInt_FromLong (pixel);
|
||||
}
|
||||
%%
|
||||
override clutter_color_from_pixel
|
||||
static PyObject *
|
||||
_wrap_clutter_color_from_pixel (PyObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
guint32 pixel;
|
||||
|
||||
if (!PyInt_Check (args)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a 32 bit encoded integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixel = (guint32) PyInt_AsLong (args);
|
||||
|
||||
clutter_color_from_pixel (&color, pixel);
|
||||
|
||||
return Py_BuildValue ("(iiii)",
|
||||
(int) color.red,
|
||||
(int) color.green,
|
||||
(int) color.blue,
|
||||
(int) color.alpha);
|
||||
}
|
||||
%%
|
||||
override clutter_label_get_text_extents
|
||||
static PyObject *
|
||||
_wrap_clutter_label_get_text_extents (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
gint width, height;
|
||||
|
||||
clutter_label_get_text_extents (CLUTTER_LABEL (self->obj),
|
||||
&width,
|
||||
&height);
|
||||
|
||||
return Py_BuildValue ("(ii)", width, height);
|
||||
}
|
||||
%%
|
||||
override clutter_rectangle_set_color
|
||||
static PyObject *
|
||||
_wrap_clutter_rectangle_set_color (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
int len, i;
|
||||
|
||||
if (PyTuple_Size (args) != 4) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a tuple of 4 integers: (r, g, b, a)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
PyObject *comp = PyTuple_GetItem (args, i);
|
||||
|
||||
if (!PyInt_Check (comp)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"component is not an integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0: color.red = (guint8) PyInt_AsLong (comp); break;
|
||||
case 1: color.green = (guint8) PyInt_AsLong (comp); break;
|
||||
case 2: color.blue = (guint8) PyInt_AsLong (comp); break;
|
||||
case 3: color.alpha = (guint8) PyInt_AsLong (comp); break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clutter_rectangle_set_color (CLUTTER_RECTANGLE (self->obj), &color);
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_rectangle_get_color
|
||||
static PyObject *
|
||||
_wrap_clutter_rectangle_get_color (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
|
||||
clutter_rectangle_get_color (CLUTTER_RECTANGLE (self->obj), &color);
|
||||
|
||||
return Py_BuildValue ("(iiii)", color.red,
|
||||
color.green,
|
||||
color.blue,
|
||||
color.alpha);
|
||||
}
|
||||
%%
|
||||
override clutter_label_set_color
|
||||
static PyObject *
|
||||
_wrap_clutter_label_set_color (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
int len, i;
|
||||
|
||||
if (PyTuple_Size (args) != 4) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"requires a tuple of 4 integers: (r, g, b, a)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
PyObject *comp = PyTuple_GetItem (args, i);
|
||||
|
||||
if (!PyInt_Check (comp)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"component is not an integer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0: color.red = (guint8) PyInt_AsLong (comp); break;
|
||||
case 1: color.green = (guint8) PyInt_AsLong (comp); break;
|
||||
case 2: color.blue = (guint8) PyInt_AsLong (comp); break;
|
||||
case 3: color.alpha = (guint8) PyInt_AsLong (comp); break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clutter_label_set_color (CLUTTER_LABEL (self->obj), &color);
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override clutter_label_get_color
|
||||
static PyObject *
|
||||
_wrap_clutter_label_get_color (PyGObject *self,
|
||||
PyObject *args)
|
||||
{
|
||||
ClutterColor color;
|
||||
|
||||
clutter_label_get_color (CLUTTER_LABEL (self->obj), &color);
|
||||
|
||||
return Py_BuildValue ("(iiii)", color.red,
|
||||
color.green,
|
||||
color.blue,
|
||||
color.alpha);
|
||||
}
|
||||
%%
|
||||
|
Reference in New Issue
Block a user