aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-07-27 18:12:39 +0800
committerDan Vrátil <dvratil@redhat.com>2012-07-27 18:13:20 +0800
commit440e43d2894fdd517cc91302d4364b082e7d1d8b (patch)
tree7c39a2b70fe8bdef99ed1cce3c7b2e6d2406d0cc /e-util
parente03d9fbc7efba1a0239f85a8cf7339bbad6b1c7d (diff)
downloadgsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.gz
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.bz2
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.lz
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.xz
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.zst
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.zip
Bug #679404 - Read colors for message preview from Gtk theme
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c25
-rw-r--r--e-util/e-util.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index a57998576a..2f84c34d9e 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -835,6 +835,31 @@ e_color_to_value (GdkColor *color)
return (guint32) (((red << 16) | (green << 8) | blue) & 0xffffff);
}
+/**
+ * e_rgba_to_value:
+ * @rgba: a #GdkRGBA
+ *
+
+ * Converts #GdkRGBA to a 24-bit RGB color value
+ *
+ * Returns: a 24-bit color value
+ **/
+guint32
+e_rgba_to_value (GdkRGBA *rgba)
+{
+ guint16 red;
+ guint16 green;
+ guint16 blue;
+
+ g_return_val_if_fail (rgba != NULL, 0);
+
+ red = ((guint16) (G_MAXUINT16 * rgba->red)) >> 8;
+ green = ((guint16) (G_MAXUINT16 * rgba->green)) >> 8;
+ blue = ((guint16) (G_MAXUINT16 * rgba->blue)) >> 8;
+
+ return (guint32) (((red << 16) | (green << 8) | blue) & 0xffffff);
+}
+
static gint
epow10 (gint number)
{
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 11dd77541e..fa98153223 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -86,6 +86,8 @@ gint e_int_compare (gconstpointer x,
gconstpointer y);
guint32 e_color_to_value (GdkColor *color);
+guint32 e_rgba_to_value (GdkRGBA *rgba);
+
/* This only makes a filename safe for usage as a filename.
* It still may have shell meta-characters in it. */
gchar * e_format_number (gint number);