From fd564be3203400024147469faaa7de0884861566 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 19 Feb 2009 01:36:04 +0000 Subject: Clean up the EMFormat stack. Add some GObject properties to bind to. Add some handy color conversion functions to e-util. svn path=/branches/kill-bonobo/; revision=37290 --- e-util/e-binding.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'e-util/e-binding.c') diff --git a/e-util/e-binding.c b/e-util/e-binding.c index 26e62c6a23..26e23ee792 100644 --- a/e-util/e-binding.c +++ b/e-util/e-binding.c @@ -480,3 +480,55 @@ e_mutual_binding_unbind (EMutualBinding *binding) g_signal_handler_disconnect ( binding->reverse.dst_object, binding->direct.handler); } + +/** + * e_binding_transform_color_to_string: + * @src_value: a #GValue of type #GDK_TYPE_COLOR + * @dst_value: a #GValue of type #G_TYPE_STRING + * @user_data: not used + * + * Transforms a #GdkColor value to a color string specification. + * + * Returns: %TRUE always + **/ +gboolean +e_binding_transform_color_to_string (const GValue *src_value, + GValue *dst_value, + gpointer user_data) +{ + const GdkColor *color; + gchar *string; + + color = g_value_get_boxed (src_value); + string = gdk_color_to_string (color); + g_value_set_string (dst_value, string); + g_free (string); + + return TRUE; +} + +/** + * e_binding_transform_string_to_color: + * @src_value: a #GValue of type #G_TYPE_STRING + * @dst_value: a #GValue of type #GDK_TYPE_COLOR + * @user_data: not used + * + * Transforms a color string specification to a #GdkColor. + * + * Returns: %TRUE if color string specification was valid + **/ +gboolean +e_binding_transform_string_to_color (const GValue *src_value, + GValue *dst_value, + gpointer user_data) +{ + GdkColor color; + const gchar *string; + gboolean success; + + string = g_value_get_string (src_value); + if (gdk_color_parse (string, &color)) + g_value_set_boxed (dst_value, &color); + + return success; +} -- cgit v1.2.3