2006-12-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-color.h: * clutter/clutter-color.c: Add clutter_color_parse(), which parses a string containing a color definition as understood by XParseColor() (or pango_color_parse()).
This commit is contained in:
parent
6d87b1479c
commit
b45b844004
@ -1,3 +1,10 @@
|
||||
2006-12-05 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-color.h:
|
||||
* clutter/clutter-color.c: Add clutter_color_parse(),
|
||||
which parses a string containing a color definition as
|
||||
understood by XParseColor() (or pango_color_parse()).
|
||||
|
||||
2006-12-04 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
Avoid clutter segfaulting when used without invoking
|
||||
|
@ -34,7 +34,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-color.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-debug.h"
|
||||
|
||||
/**
|
||||
* clutter_color_add:
|
||||
@ -374,6 +377,45 @@ clutter_color_from_pixel (ClutterColor *dest,
|
||||
dest->alpha = pixel % 0xff;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_color_parse:
|
||||
* @color: a string specifiying a color
|
||||
* @dest: return location for a #ClutterColor
|
||||
*
|
||||
* Parses a string definition of a color, filling the
|
||||
* <structfield>red</structfield>, <structfield>green</structfield> and
|
||||
* <structfield>blue</structfield> channels of @dest. The
|
||||
* <structfield>alpha</structfield> channel is not changed. The
|
||||
* color in @dest is not allocated.
|
||||
*
|
||||
* The color may be defined by any of the formats understood by
|
||||
* <function>XParseColor</function>; these include literal color
|
||||
* names, like <literal>Red</literal> or <literal>DarkSlateGray</literal>,
|
||||
* or hexadecimal specifications like <literal>#3050b2</literal> or
|
||||
* <literal>#333</literal>.
|
||||
*
|
||||
* Return value: %TRUE if parsing succeeded.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
gboolean
|
||||
clutter_color_parse (const gchar *color,
|
||||
ClutterColor *dest)
|
||||
{
|
||||
PangoColor pango_color;
|
||||
|
||||
if (pango_color_parse (&pango_color, color))
|
||||
{
|
||||
dest->red = pango_color.red;
|
||||
dest->green = pango_color.green;
|
||||
dest->blue = pango_color.blue;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static ClutterColor *
|
||||
clutter_color_copy (ClutterColor *color)
|
||||
{
|
||||
|
@ -45,6 +45,8 @@ struct _ClutterColor
|
||||
|
||||
GType clutter_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean clutter_color_parse (const gchar *color,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_add (const ClutterColor *src1,
|
||||
const ClutterColor *src2,
|
||||
ClutterColor *dest);
|
||||
|
Loading…
Reference in New Issue
Block a user