Index: libedataserver/e-source.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-source.c,v
retrieving revision 1.24
diff -u -p -r1.24 e-source.c
--- libedataserver/e-source.c	3 Aug 2006 11:29:44 -0000	1.24
+++ libedataserver/e-source.c	9 Nov 2006 17:51:19 -0000
@@ -32,10 +32,6 @@
 #define ES_CLASS(obj)  E_SOURCE_CLASS (G_OBJECT_GET_CLASS (obj))
 
 
-/* String used to put the color in the XML.  */
-#define COLOR_FORMAT_STRING "%06x"
-
-
 /* Private members.  */
 
 struct _ESourcePrivate {
@@ -48,8 +44,7 @@ struct _ESourcePrivate {
 
 	gboolean readonly;
 	
-	gboolean has_color;
-	guint32 color;
+	gchar *color_spec;
 
 	GHashTable *properties;
 };
@@ -89,6 +84,7 @@ impl_finalize (GObject *object)
 	g_free (priv->name);
 	g_free (priv->relative_uri);
 	g_free (priv->absolute_uri);
+	g_free (priv->color_spec);
 
 	g_hash_table_destroy (priv->properties);
 
@@ -143,6 +139,31 @@ e_source_init (ESource *source)
 						  g_free, g_free);
 }
 
+/* Private methods. */
+
+static gboolean
+e_source_set_color_internal (ESource *source,
+                             const gchar *color_spec)
+{
+	ESourcePrivate *priv = source->priv;
+	gboolean do_cmp;
+
+	if (priv->readonly)
+		return FALSE;
+
+	if (color_spec == priv->color_spec)
+		return FALSE;
+
+	do_cmp = (color_spec != NULL && priv->color_spec != NULL);
+	if (do_cmp && g_ascii_strcasecmp (color_spec, priv->color_spec) == 0)
+		return FALSE;
+
+	g_free (priv->color_spec);
+	priv->color_spec = g_strdup (color_spec);
+
+	return TRUE;
+}
+
 /* Public methods.  */
 
 ESource *
@@ -300,14 +321,14 @@ e_source_update_from_xml_node (ESource *
 	xmlChar *name;
 	xmlChar *relative_uri;
 	xmlChar *absolute_uri;
-	xmlChar *color_string;
+	xmlChar *color_spec;
 	gboolean retval;
 	gboolean changed = FALSE;
 
 	name = xmlGetProp (node, "name");
 	relative_uri = xmlGetProp (node, "relative_uri");
 	absolute_uri = xmlGetProp (node, "uri");
-	color_string = xmlGetProp (node, "color");
+	color_spec = xmlGetProp (node, "color");
 
 	if (name == NULL || (relative_uri == NULL && absolute_uri == NULL)) {
 		retval = FALSE;
@@ -334,21 +355,8 @@ e_source_update_from_xml_node (ESource *
 		changed = TRUE;
 	}
 
-	if (color_string == NULL) {
-		if (source->priv->has_color) {
-			source->priv->has_color = FALSE;
-			changed = TRUE;
-		}
-	} else {
-		guint32 color = 0;
+	changed |= e_source_set_color_internal (source, color_spec);
 
-		sscanf (color_string, COLOR_FORMAT_STRING, &color);
-		if (! source->priv->has_color || source->priv->color != color) {
-			source->priv->has_color = TRUE;
-			source->priv->color = color;
-			changed = TRUE;
-		}
-	}
 	if (g_hash_table_size (source->priv->properties) && !node->children) {
 		g_hash_table_destroy (source->priv->properties);
 		source->priv->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -387,8 +395,8 @@ e_source_update_from_xml_node (ESource *
 		xmlFree (relative_uri);
 	if (absolute_uri != NULL)
 		xmlFree (absolute_uri);
-	if (color_string != NULL)
-		xmlFree (color_string);
+	if (color_spec != NULL)
+		xmlFree (color_spec);
 
 	return retval;
 }
@@ -548,37 +556,25 @@ e_source_set_readonly (ESource  *source,
 	
 }
 
+/**
+ * e_source_set_color:
+ * @source: an ESource
+ * @color_spec: a string specifying the color
+ *
+ * Store a textual representation of a color in @source.  The @color_spec
+ * string should be parsable by #gdk_color_parse(), or %NULL to unset the
+ * color in @source.
+ **/
 void
 e_source_set_color (ESource *source,
-		    guint32 color)
-{
-	g_return_if_fail (E_IS_SOURCE (source));
-
-	if (source->priv->readonly)
-		return;
-	
-	if (source->priv->has_color && source->priv->color == color)
-		return;
-
-	source->priv->has_color = TRUE;
-	source->priv->color = color;
-
-	g_signal_emit (source, signals[CHANGED], 0);
-}
-
-void
-e_source_unset_color (ESource *source)
+		    const gchar *color_spec)
 {
 	g_return_if_fail (E_IS_SOURCE (source));
 
-	if (! source->priv->has_color)
-		return;
-
-	source->priv->has_color = FALSE;
-	g_signal_emit (source, signals[CHANGED], 0);
+	if (e_source_set_color_internal (source, color_spec))
+		g_signal_emit (source, signals[CHANGED], 0);
 }
 
-
 ESourceGroup *
 e_source_peek_group (ESource *source)
 {
@@ -630,28 +626,19 @@ e_source_get_readonly (ESource *source)
 
 /**
  * e_source_get_color:
- * @source: An ESource
- * @color_return: Pointer to a variable where the returned color will be
- * stored.
+ * @source: an ESource
  * 
- * If @source has an associated color, return it in *@color_return.
+ * Return the textual representation of the color for @source, or %NULL if it
+ * has none.  The returned string should be parsable by #gdk_color_parse().
  * 
- * Return value: %TRUE if the @source has a defined color (and hence
- * *@color_return was set), %FALSE otherwise.
+ * Return value: a string specifying the color
  **/
-gboolean
-e_source_get_color (ESource *source,
-		    guint32 *color_return)
+const gchar *
+e_source_get_color (ESource *source)
 {
-	g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
-
-	if (! source->priv->has_color)
-		return FALSE;
-
-	if (color_return != NULL)
-		*color_return = source->priv->color;
+	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
 
-	return TRUE;
+	return source->priv->color_spec;
 }
 
 char *
@@ -689,8 +676,6 @@ dump_common_to_xml_node (ESource *source
 			 xmlNodePtr parent_node)
 {
 	ESourcePrivate *priv;
-	gboolean has_color;
-	guint32 color;
 	xmlNodePtr node;
 	const char *abs_uri = NULL, *relative_uri = NULL;
 
@@ -709,13 +694,9 @@ dump_common_to_xml_node (ESource *source
 		xmlSetProp (node, "uri", abs_uri);
 	if (relative_uri)
 		xmlSetProp (node, "relative_uri", relative_uri);
-	
-	has_color = e_source_get_color (source, &color);
-	if (has_color) {
-		char *color_string = g_strdup_printf (COLOR_FORMAT_STRING, color);
-		xmlSetProp (node, "color", color_string);
-		g_free (color_string);
-	}
+
+	if (priv->color_spec != NULL)
+		xmlSetProp (node, "color", priv->color_spec);
 
 	if (g_hash_table_size (priv->properties) != 0) {
 		xmlNodePtr properties_node;
@@ -848,7 +829,6 @@ ESource *
 e_source_copy (ESource *source)
 {
 	ESource *new_source;
-	guint32  color;
 
 	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
 
@@ -857,8 +837,7 @@ e_source_copy (ESource *source)
 
 	e_source_set_name (new_source, e_source_peek_name (source));
 
-	if (e_source_get_color (source, &color))
-		e_source_set_color (new_source, color);
+	new_source->priv->color_spec = g_strdup (source->priv->color_spec);
 
 	new_source->priv->absolute_uri = g_strdup (e_source_peek_absolute_uri (source));
 
Index: libedataserver/e-source.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-source.h,v
retrieving revision 1.11
diff -u -p -r1.11 e-source.h
--- libedataserver/e-source.h	31 Aug 2005 04:26:10 -0000	1.11
+++ libedataserver/e-source.h	9 Nov 2006 17:51:19 -0000
@@ -85,8 +85,7 @@ void  e_source_set_absolute_uri  (ESourc
 void  e_source_set_readonly      (ESource      *source,
 				  gboolean      readonly);
 void  e_source_set_color         (ESource      *source,
-				  guint32       color);
-void  e_source_unset_color       (ESource      *source);
+				  const gchar  *color_spec);
 
 ESourceGroup *e_source_peek_group         (ESource *source);
 const char   *e_source_peek_uid           (ESource *source);
@@ -94,8 +93,7 @@ const char   *e_source_peek_name        
 const char   *e_source_peek_relative_uri  (ESource *source);
 const char   *e_source_peek_absolute_uri  (ESource *source);
 gboolean      e_source_get_readonly       (ESource *source);
-gboolean      e_source_get_color          (ESource *source,
-					   guint32 *color_return);
+const gchar  *e_source_get_color          (ESource *source);
 
 char *e_source_get_uri  (ESource *source);
 
Index: libedataserver/test-source-list.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/test-source-list.c,v
retrieving revision 1.7
diff -u -p -r1.7 test-source-list.c
--- libedataserver/test-source-list.c	14 Oct 2005 11:31:40 -0000	1.7
+++ libedataserver/test-source-list.c	9 Nov 2006 17:51:19 -0000
@@ -91,17 +91,16 @@ static void
 dump_source (ESource *source)
 {
 	char *uri = e_source_get_uri (source);
-	gboolean has_color;
-	guint32 color;
+	const gchar *spec;
 
 	g_print ("\tSource %s\n", e_source_peek_uid (source));
 	g_print ("\t\tname: %s\n", e_source_peek_name (source));
 	g_print ("\t\trelative_uri: %s\n", e_source_peek_relative_uri (source));
 	g_print ("\t\tabsolute_uri: %s\n", uri);
 
-	has_color = e_source_get_color (source, &color);
-	if (has_color)
-		g_print ("\t\tcolor: %06x\n", color);
+	spec = e_source_get_color (source);
+	if (spec != NULL)
+		g_print ("\t\tcolor: %s\n", spec);
 
 	g_print ("\t\tproperties:\n");
 	e_source_foreach_property (source, (GHFunc) dump_property, NULL);
@@ -429,7 +428,6 @@ on_idle_do_stuff (void *unused_data)
 
 	if (set_color_arg != NULL) {
 		ESource *source;
-		guint32 color;
 
 		if (add_source_arg == NULL && source_arg == NULL) {
 			fprintf (stderr,
@@ -442,8 +440,7 @@ on_idle_do_stuff (void *unused_data)
 		else
 			source = e_source_list_peek_source_by_uid (list, source_arg);
 
-		sscanf (set_color_arg, "%06x", &color);
-		e_source_set_color (source, color);
+		e_source_set_color (source, set_color_arg);
 		e_source_list_sync (list, NULL);
 	}
 
@@ -461,7 +458,7 @@ on_idle_do_stuff (void *unused_data)
 		else
 			source = e_source_list_peek_source_by_uid (list, source_arg);
 
-		e_source_unset_color (source);
+		e_source_set_color (source, NULL);
 		e_source_list_sync (list, NULL);
 	}
 
Index: libedataserverui/e-source-selector.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-source-selector.c,v
retrieving revision 1.32
diff -u -p -r1.32 e-source-selector.c
--- libedataserverui/e-source-selector.c	26 Apr 2006 08:21:21 -0000	1.32
+++ libedataserverui/e-source-selector.c	9 Nov 2006 17:51:20 -0000
@@ -411,15 +411,24 @@ pixbuf_cell_data_func (GtkTreeViewColumn
 			      NULL);
 	} else {	
 		ESource *source;
-		guint32 color;
 		GdkPixbuf *pixbuf = NULL;
+		const gchar *spec;
+		GdkColor color;
 
 		g_assert (E_IS_SOURCE (data));
 		source = E_SOURCE (data);
 		
-		if (e_source_get_color (source, &color)) {
+		spec = e_source_get_color (source);
+		if (spec != NULL && gdk_color_parse (spec, &color)) {
+			guint32 rgba;
+
 			pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 16, 16);
-			gdk_pixbuf_fill (pixbuf, color << 8);
+
+			rgba = (((color.red & 0xff00) << 8) |
+				((color.green & 0xff00)) |
+				((color.blue & 0xff00) >> 8)) << 8;
+
+			gdk_pixbuf_fill (pixbuf, rgba);
 		}
 			
 		g_object_set (renderer,
