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.
This commit is contained in:
Erick Pérez Castellanos
2015-02-06 09:21:33 -05:00
parent e942f6c885
commit 820d1cdb65
2 changed files with 39 additions and 0 deletions
+34
View File
@@ -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)
+5
View File
@@ -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);