[gnome-calendar] app: handle calendars colours better
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] app: handle calendars colours better
- Date: Fri, 6 Mar 2015 16:35:05 +0000 (UTC)
commit c7563da2d02a3fce63088a57ea8e73cf547d2fec
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Fri Mar 6 11:32:32 2015 -0500
app: handle calendars colours better
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=745487
src/gcal-application.c | 8 ++++++--
src/gcal-edit-dialog.c | 6 +++---
src/gcal-event-widget.c | 8 +++++---
src/gcal-manager.c | 1 -
src/gcal-search-view.c | 2 +-
src/gcal-shell-search-provider.c | 2 +-
src/gcal-utils.c | 9 ++++++---
src/gcal-utils.h | 3 ++-
src/gcal-window.c | 2 +-
9 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 677d678..b3e33a4 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -132,7 +132,8 @@ process_sources (GcalApplication *application)
gint arr_length, i = 0;
GQuark color_id;
- const gchar* color_str;
+ GdkRGBA color;
+ gchar* color_str;
gchar **new_css_snippets;
gchar *new_css_data;
@@ -148,10 +149,13 @@ process_sources (GcalApplication *application)
{
source = l->data;
- color_str = get_color_name_from_source (source);
+ get_color_name_from_source (source, &color);
+ color_str = gdk_rgba_to_string (&color);
color_id = g_quark_from_string (color_str);
new_css_snippets[i] = g_strdup_printf (CSS_TEMPLATE, color_id, color_str);
+
+ g_free (color_str);
}
g_list_free (sources);
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index c421e48..c1a4a67 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -135,7 +135,7 @@ fill_sources_menu (GcalEditDialog *dialog)
source = E_SOURCE (aux->data);
/* retrieve color */
- gdk_rgba_parse (&color, get_color_name_from_source (source));
+ get_color_name_from_source (source, &color);
pix = gcal_get_pixbuf_from_color (&color, 16);;
/* menu item */
@@ -195,7 +195,7 @@ on_calendar_selected (GtkWidget *menu_item,
GdkPixbuf *pix;
/* retrieve color */
- gdk_rgba_parse (&color, get_color_name_from_source (source));
+ get_color_name_from_source (source, &color);
pix = gcal_get_pixbuf_from_color (&color, 16);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->source_image), pix);
@@ -821,7 +821,7 @@ gcal_edit_dialog_set_event_data (GcalEditDialog *dialog,
gtk_entry_set_text (GTK_ENTRY (priv->summary_entry), e_summary.value);
/* dialog titlebar's title & subtitle */
- gdk_rgba_parse (&color, get_color_name_from_source (data->source));
+ get_color_name_from_source (data->source, &color);
pix = gcal_get_pixbuf_from_color (&color, 16);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->source_image), pix);
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index d08e561..0dfa545 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -680,7 +680,7 @@ gcal_event_widget_new_from_data (GcalEventData *data)
GQuark color_id;
GdkRGBA color;
- gchar *custom_css_class;
+ gchar *color_str, *custom_css_class;
ECalComponentDateTime dt;
icaltimetype *date;
@@ -715,13 +715,15 @@ gcal_event_widget_new_from_data (GcalEventData *data)
gcal_event_widget_set_summary (event, (gchar*) e_summary.value);
/* color */
- gdk_rgba_parse (&color, get_color_name_from_source (priv->source));
+ get_color_name_from_source (priv->source, &color);
gcal_event_widget_set_color (event, &color);
- color_id = g_quark_from_string (get_color_name_from_source (priv->source));
+ color_str = gdk_rgba_to_string (&color);
+ color_id = g_quark_from_string (color_str);
custom_css_class = g_strdup_printf ("color-%d", color_id);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), custom_css_class);
g_free (custom_css_class);
+ g_free (color_str);
/* start date */
e_cal_component_get_dtstart (priv->component, &dt);
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index f184fab..75b6cb6 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -880,7 +880,6 @@ gcal_manager_get_sources (GcalManager *manager)
if (!unit->enabled)
continue;
aux = g_list_append (aux, key);
-
}
return aux;
}
diff --git a/src/gcal-search-view.c b/src/gcal-search-view.c
index 005db5f..0122e57 100644
--- a/src/gcal-search-view.c
+++ b/src/gcal-search-view.c
@@ -320,7 +320,7 @@ make_row_for_event_data (GcalSearchView *view,
priv = gcal_search_view_get_instance_private (view);
/* get event color */
- gdk_rgba_parse (&color, get_color_name_from_source (data->source));
+ get_color_name_from_source (data->source, &color);
pixbuf = gcal_get_pixbuf_from_color (&color, 16);
/* make an image of the color */
diff --git a/src/gcal-shell-search-provider.c b/src/gcal-shell-search-provider.c
index 1b9b07e..16469ee 100644
--- a/src/gcal-shell-search-provider.c
+++ b/src/gcal-shell-search-provider.c
@@ -237,7 +237,7 @@ get_result_metas_cb (GcalShellSearchProvider *search_provider,
e_cal_component_get_summary (data->event_component, &summary);
g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (summary.value));
- gdk_rgba_parse (&color, get_color_name_from_source (data->source));
+ get_color_name_from_source (data->source, &color);
gicon = get_circle_pixbuf_from_color (&color, 128);
icon_variant = g_icon_serialize (G_ICON (gicon));
g_variant_builder_add (&builder, "{sv}", "icon", icon_variant);
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index cf5dc91..741d4a8 100644
--- a/src/gcal-utils.c
+++ b/src/gcal-utils.c
@@ -161,11 +161,14 @@ get_circle_pixbuf_from_color (GdkRGBA *color,
return pix;
}
-const gchar*
-get_color_name_from_source (ESource *source)
+void
+get_color_name_from_source (ESource *source, GdkRGBA *out_color)
{
ESourceSelectable *extension = E_SOURCE_SELECTABLE (e_source_get_extension (source,
E_SOURCE_EXTENSION_CALENDAR));
- return e_source_selectable_get_color (extension);
+
+ /* FIXME: We should handle calendars colours better */
+ if (!gdk_rgba_parse (out_color, e_source_selectable_get_color (extension)))
+ gdk_rgba_parse (out_color, "#becedd"); /* calendar default colour */
}
gint
diff --git a/src/gcal-utils.h b/src/gcal-utils.h
index 08f58f3..55f457d 100644
--- a/src/gcal-utils.h
+++ b/src/gcal-utils.h
@@ -63,7 +63,8 @@ GdkPixbuf* gcal_get_pixbuf_from_color (GdkRGBA
GdkPixbuf* get_circle_pixbuf_from_color (GdkRGBA *color,
gint size);
-const gchar* get_color_name_from_source (ESource *source);
+void get_color_name_from_source (ESource *source,
+ GdkRGBA *out_color);
gint gcal_compare_event_widget_by_date (gconstpointer a,
gconstpointer b);
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 7937670..6334832 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -745,7 +745,7 @@ add_source (GcalManager *manager,
/* retrieve the source's color & build item name */
item_name = g_strdup_printf ("%s", e_source_get_uid (source));
- gdk_rgba_parse (&color, get_color_name_from_source (source));
+ get_color_name_from_source (source, &color);
pix = gcal_get_pixbuf_from_color (&color, 16);
/* create the menu item */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]