From 7aa4cefa8e36f1ded3ebc59843d13ca64b2bf2bf Mon Sep 17 00:00:00 2001 From: Valentin Negoescu Date: Wed, 1 Mar 2017 18:08:58 +0200 Subject: [PATCH] source-dialog: update calendar image color After editing the color of a calendar its image is not updated as well. Fix this by updating the image when the edit is finished. https://bugzilla.gnome.org/show_bug.cgi?id=773869 --- src/gcal-source-dialog.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c index 987f6dc8..ad90f859 100644 --- a/src/gcal-source-dialog.c +++ b/src/gcal-source-dialog.c @@ -561,6 +561,31 @@ is_goa_source (GcalSourceDialog *dialog, return is_goa; } +static void +source_color_changed (GObject *source, + GParamSpec *pspec, + GtkImage *icon) +{ + ESourceSelectable *extension; + GdkPixbuf *pixbuf; + GdkRGBA out_color; + + extension = E_SOURCE_SELECTABLE (source); + + if (!gdk_rgba_parse (&out_color, e_source_selectable_get_color (extension))) + { + g_warning ("Error parsing color"); + return; + } + + if (gdk_rgba_parse (&out_color, e_source_selectable_get_color (extension))) + { + pixbuf = get_circle_pixbuf_from_color (&out_color, 24); + gtk_image_set_from_pixbuf (GTK_IMAGE (icon), pixbuf); + g_object_unref (pixbuf); + } +} + static void invalidate_calendar_listbox_sort (GObject *source, GParamSpec *pspec, @@ -592,6 +617,7 @@ make_row_from_source (GcalSourceDialog *dialog, GdkRGBA color; gchar *parent_name; + ESourceSelectable *extension; get_source_parent_name_color (dialog->manager, source, &parent_name, NULL); builder = gtk_builder_new_from_resource ("/org/gnome/calendar/calendar-row.ui"); @@ -615,6 +641,9 @@ make_row_from_source (GcalSourceDialog *dialog, g_signal_connect (source, "notify::display-name", G_CALLBACK (invalidate_calendar_listbox_sort), dialog->calendars_listbox); + extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR)); + g_signal_connect (extension, "notify::color", G_CALLBACK (source_color_changed), icon); + /* parent source name label */ bottom_label = GTK_WIDGET (gtk_builder_get_object (builder, "subtitle")); gtk_label_set_label (GTK_LABEL (bottom_label), parent_name);