From fa17f1b6958bf180b23952975bc35096b4ae425c Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Thu, 29 Apr 2004 21:21:56 +0000 Subject: use the source color if it is set. Yay for ugly colors. 2004-04-29 Larry Ewing * gui/e-cal-model.c (ecm_get_color_for_component): use the source color if it is set. Yay for ugly colors. * gui/e-cal-model.h: add a color holder to the ECalModelComponent since the return value of the color stuff is const. svn path=/trunk/; revision=25696 --- calendar/gui/e-cal-model.c | 24 ++++++++++++++++++++++-- calendar/gui/e-cal-model.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 3d3d8b3c3a..25a866db3a 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -191,6 +191,11 @@ free_comp_data (ECalModelComponent *comp_data) comp_data->completed = NULL; } + if (comp_data->color) { + g_free (comp_data->color); + comp_data->color = NULL; + } + g_free (comp_data); } @@ -892,6 +897,8 @@ typedef struct { static const char * ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) { + ESource *source; + guint32 source_color; ECalModelPrivate *priv; gint i, first_empty = 0; static AssignedColorData assigned_colors[] = { @@ -910,7 +917,14 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); priv = model->priv; - + + source = e_cal_get_source (comp_data->client); + if (e_source_get_color (source, &source_color)) { + g_free (comp_data->color); + comp_data->color = g_strdup_printf ("#%06x", source_color & 0xffffff); + return comp_data->color; + } + for (i = 0; i < G_N_ELEMENTS (assigned_colors); i++) { GList *l; @@ -1236,6 +1250,10 @@ e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_d g_free (comp_data->completed); comp_data->completed = NULL; } + if (comp_data->color) { + g_free (comp_data->color); + comp_data->color = NULL; + } comp_data->icalcomp = icalcomponent_new_clone (l->data); @@ -1776,7 +1794,7 @@ copy_ecdv (ECellDateEditValue *ecdv) } /** - * e_cal_model_free_component_data + * e_cal_model_copy_component_data */ ECalModelComponent * e_cal_model_copy_component_data (ECalModelComponent *comp_data) @@ -1823,6 +1841,8 @@ e_cal_model_free_component_data (ECalModelComponent *comp_data) g_free (comp_data->due); if (comp_data->completed) g_free (comp_data->completed); + if (comp_data->color) + g_free (comp_data->color); g_free (comp_data); } diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index 8437e4d1c5..aef2e3d539 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -61,6 +61,7 @@ typedef struct { ECellDateEditValue *dtend; ECellDateEditValue *due; ECellDateEditValue *completed; + gchar *color; } ECalModelComponent; typedef struct { -- cgit v1.2.3