[clutter] color: Add initializers for ClutterColor
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] color: Add initializers for ClutterColor
- Date: Fri, 27 Apr 2012 11:32:25 +0000 (UTC)
commit 0fc4053613a4dff7c0aad2d4348c2d86be9b41d5
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Fri Apr 13 11:26:38 2012 +0100
color: Add initializers for ClutterColor
Similar to the ones we have for the other boxed types in Clutter.
clutter/clutter-color.c | 56 +++++++++++++++++++++++++++++++++++++++++++---
clutter/clutter-color.h | 19 ++++++++++++++++
2 files changed, 71 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter-color.c b/clutter/clutter-color.c
index cef0109..723349a 100644
--- a/clutter/clutter-color.c
+++ b/clutter/clutter-color.c
@@ -968,6 +968,12 @@ clutter_color_free (ClutterColor *color)
*
* Creates a new #ClutterColor with the given values.
*
+ * This function is the equivalent of:
+ *
+ * |[
+ * clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);
+ * ]|
+ *
* Return value: (transfer full): the newly allocated color.
* Use clutter_color_free() when done
*
@@ -979,13 +985,55 @@ clutter_color_new (guint8 red,
guint8 blue,
guint8 alpha)
{
- ClutterColor *color;
+ return clutter_color_init (clutter_color_alloc (),
+ red,
+ green,
+ blue,
+ alpha);
+}
- color = g_slice_new (ClutterColor);
+/**
+ * clutter_color_alloc:
+ *
+ * Allocates a new, transparent black #ClutterColor.
+ *
+ * Return value: (transfer full): the newly allocated #ClutterColor; use
+ * clutter_color_free() to free its resources
+ *
+ * Since: 1.12
+ */
+ClutterColor *
+clutter_color_alloc (void)
+{
+ return g_slice_new0 (ClutterColor);
+}
+
+/**
+ * clutter_color_init:
+ * @color: a #ClutterColor
+ * @red: red component of the color, between 0 and 255
+ * @green: green component of the color, between 0 and 255
+ * @blue: blue component of the color, between 0 and 255
+ * @alpha: alpha component of the color, between 0 and 255
+ *
+ * Initializes @color with the given values.
+ *
+ * Return value: (transfer none): the initialized #ClutterColor
+ *
+ * Since: 1.12
+ */
+ClutterColor *
+clutter_color_init (ClutterColor *color,
+ guint8 red,
+ guint8 green,
+ guint8 blue,
+ guint8 alpha)
+{
+ g_return_val_if_fail (color != NULL, NULL);
- color->red = red;
+ color->red = red;
color->green = green;
- color->blue = blue;
+ color->blue = blue;
color->alpha = alpha;
return color;
diff --git a/clutter/clutter-color.h b/clutter/clutter-color.h
index 4bfcb47..393eee4 100644
--- a/clutter/clutter-color.h
+++ b/clutter/clutter-color.h
@@ -55,12 +55,31 @@ struct _ClutterColor
guint8 alpha;
};
+/**
+ * CLUTTER_COLOR_INIT:
+ * @r: value for the red channel, between 0 and 255
+ * @g: value for the green channel, between 0 and 255
+ * @b: value for the blue channel, between 0 and 255
+ * @a: value for the alpha channel, between 0 and 255
+ *
+ * A macro that initializes a #ClutterColor, to be used when declaring it.
+ *
+ * Since: 1.12
+ */
+#define CLUTTER_COLOR_INIT(r,g,b,a) { (r), (g), (b), (a) }
+
GType clutter_color_get_type (void) G_GNUC_CONST;
ClutterColor *clutter_color_new (guint8 red,
guint8 green,
guint8 blue,
guint8 alpha);
+ClutterColor *clutter_color_alloc (void);
+ClutterColor *clutter_color_init (ClutterColor *color,
+ guint8 red,
+ guint8 green,
+ guint8 blue,
+ guint8 alpha);
ClutterColor *clutter_color_copy (const ClutterColor *color);
void clutter_color_free (ClutterColor *color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]