From b4f0c229fe3f6b1c74bff1caf3aca774a1c0e0f6 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Fri, 4 Feb 2011 16:15:47 +0000 Subject: Added ESource Colours a circle drawn onto a cairo surface, however this code has one caveat, it's un-testable with evolution as evolutions color peek is currently broken. However I've used a very similar method of exchanging GdkDrawables and cairo_surface_t before and it worked... Lets see this time :/ --- src/datetime-service.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 736e89e..3f5aa80 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -24,9 +24,12 @@ with this program. If not, see . #include #include +#include #include #include +#include +#include #include #include #include @@ -41,6 +44,7 @@ with this program. If not, see . #include // Other users of ecal seem to also include these, not sure why they should be included by the above #include +#include #include @@ -417,28 +421,29 @@ update_appointment_menu_items (gpointer user_data) { g_debug("Command to Execute: %s", cmd); - // Get the colour E_CAL_COMPONENT_FIELD_COLOR - // Get the icon, either EVENT or MEMO or TODO? - // needs EDS, ecal component colours are broken... - //gdouble red, blue, green; - //ECalSource *source = e_cal_get_source (ecalcomp->client); - //if (!ecalcomp->color && e_source_get_color (source, &source_color)) { - //g_free (comp_data->color); - //ecalcomp->color = g_strdup_printf ("#%06x", source_color & 0xffffff); - //} - //g_debug("Colour to use: %s", ecalcomp->color); - - //cairo_surface_t *cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); - //cairo_t *cr = cairo_create(cs); - - // TODO: Draw the correct icon for the appointment type and then tint it using mask fill. + ESource *source = e_cal_get_source (ecal); + //e_source_get_color (source, &source_color); api has been changed + const gchar *color_spec = e_source_peek_color_spec(source); + GdkColor color; + g_debug("Colour to use: %s", color_spec); + + // Draw the correct icon for the appointment type and then tint it using mask fill. // For now we'll create a circle + if (color_spec != NULL) { + gdk_color_parse (color_spec, &color); + + cairo_surface_t *cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); + cairo_t *cr = cairo_create(cs); + cairo_arc (cr, width/2, height/2, width/2, 0, 2 * M_PI); + gdk_cairo_set_source_color(cr, &color); + cairo_fill(cr); - - //GdkPixbuf * pixbuf = gdk_pixbuf_get_from_drawable(NULL, (GdkDrawable*)cs, 0,0,0,0, width, height); - - //dbusmenu_menuitem_property_set_image (item, APPOINTMENT_MENUITEM_PROP_ICON, pixbuf); - + GdkPixbuf * pixbuf = gdk_pixbuf_get_from_drawable(NULL, (GdkDrawable*)cs, + gdk_colormap_new(gdk_drawable_get_visual((GdkDrawable*)cs), TRUE), 0,0,0,0, width, height); + cairo_destroy(cr); + + dbusmenu_menuitem_property_set_image (item, APPOINTMENT_MENUITEM_PROP_ICON, pixbuf); + } dbusmenu_menuitem_child_add_position (root, item, 4+i); appointments = g_list_append (appointments, item); // Keep track of the items here to make them east to remove -- cgit v1.2.3