From 820d1cdb651dd701c7e2fffd6e3646f0177a58de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Wed, 4 Feb 2015 12:46:48 -0500 Subject: [PATCH] utils: API added + get_color_name_from_source + get_circle_pixbuf_from_color The first one is use plenty in the codebase, everytime we need a color, and the second one will be used when retrieving the search results. --- src/gcal-utils.c | 34 ++++++++++++++++++++++++++++++++++ src/gcal-utils.h | 5 +++++ 2 files changed, 39 insertions(+) diff --git a/src/gcal-utils.c b/src/gcal-utils.c index 40779b05..bf85a0af 100644 --- a/src/gcal-utils.c +++ b/src/gcal-utils.c @@ -273,6 +273,40 @@ gcal_get_pixbuf_from_color (GdkRGBA *color, return pix; } +GdkPixbuf* +get_circle_pixbuf_from_color (GdkRGBA *color, + gint size) +{ + cairo_surface_t *surface; + cairo_t *cr; + GdkPixbuf *pix; + + /* TODO: review size here, maybe not hardcoded */ + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size); + cr = cairo_create (surface); + + cairo_set_source_rgba (cr, + color->red, + color->green, + color->blue, + color->alpha); + cairo_arc (cr, size / 2.0, size / 2.0, size / 2.0, 0., 2 * M_PI); + cairo_fill (cr); + cairo_destroy (cr); + pix = gdk_pixbuf_get_from_surface (surface, + 0, 0, + size, size); + cairo_surface_destroy (surface); + return pix; +} + +const gchar* +get_color_name_from_source (ESource *source) +{ + ESourceSelectable *extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR)); + return e_source_selectable_get_color (extension); +} + gint gcal_compare_event_widget_by_date (gconstpointer a, gconstpointer b) diff --git a/src/gcal-utils.h b/src/gcal-utils.h index 5042a3f6..8399025f 100644 --- a/src/gcal-utils.h +++ b/src/gcal-utils.h @@ -72,6 +72,11 @@ gchar* gcal_get_month_name (gint GdkPixbuf* gcal_get_pixbuf_from_color (GdkRGBA *color, gint size); +GdkPixbuf* get_circle_pixbuf_from_color (GdkRGBA *color, + gint size); + +const gchar* get_color_name_from_source (ESource *source); + gint gcal_compare_event_widget_by_date (gconstpointer a, gconstpointer b);