[gnome-calendar] utils: API added



commit 820d1cdb651dd701c7e2fffd6e3646f0177a58de
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Wed Feb 4 12:46:48 2015 -0500

    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(+), 0 deletions(-)
---
diff --git a/src/gcal-utils.c b/src/gcal-utils.c
index 40779b0..bf85a0a 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 5042a3f..8399025 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);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]