summaryrefslogtreecommitdiff
path: root/pango/pango-color.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-12-06 22:46:47 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-12-06 22:46:47 +0000
commitb7c74a7787b624bdf1ef6a4f6dba2007317b9265 (patch)
treea476293161d06793ae6cae8d945f6511c186cdfa /pango/pango-color.c
parent520013cab0678357f8b15b8e719d6181a0246ca2 (diff)
downloadpango-b7c74a7787b624bdf1ef6a4f6dba2007317b9265.tar.gz
Bug 373856 – Wish: Function to convert a GdkColor to a string Patch from
2006-12-06 Behdad Esfahbod <behdad@gnome.org> Bug 373856 – Wish: Function to convert a GdkColor to a string Patch from Matthew Barnes * docs/pango-sections.txt: * docs/tmpl/text-attributes.sgml: * pango/pango-attributes.h: * pango/pango.def: * pango/pango-color.c (pango_color_to_string): New public function pango_color_to_string().
Diffstat (limited to 'pango/pango-color.c')
-rw-r--r--pango/pango-color.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/pango/pango-color.c b/pango/pango-color.c
index a471b4ce..13e38ff2 100644
--- a/pango/pango-color.c
+++ b/pango/pango-color.c
@@ -80,6 +80,27 @@ pango_color_free (PangoColor *color)
g_slice_free (PangoColor, color);
}
+/**
+ * pango_color_to_string:
+ * @color: a #PangoColor
+ *
+ * Returns a textual specification of @color in the hexadecimal form
+ * <literal>&num;rrrrggggbbbb</literal>, where <literal>r</literal>,
+ * <literal>g</literal> and <literal>b</literal> are hex digits representing
+ * the red, green, and blue components respectively.
+ *
+ * Return value: a newly-allocated text string that must be freed with g_free().
+ *
+ * Since: 1.16
+ **/
+gchar *
+pango_color_to_string (const PangoColor *color)
+{
+ g_return_val_if_fail (color != NULL, NULL);
+
+ return g_strdup_printf ("#%04x%04x%04x", color->red, color->green, color->blue);
+}
+
/* Color parsing
*/