calendar-button: Bind calendar color with paintable
When updating the color of the calendar, the corresponding colored dot in the "Calendars" popover does not change. This is due to the fact that GListModel doesn't notify when one child changes internally. Any widget depicting a calendar should watch for changes on the data. To fix this, I used the same code as in GcalEventEditorDialog, which creates a binding between the calendar's color and the paintable inside the image.
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
972b88a97d
commit
dee98d1e20
@@ -50,6 +50,17 @@ static GParamSpec *properties [N_PROPS];
|
||||
* Auxiliary methods
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
paintable_from_gdk_rgb (GBinding *binding,
|
||||
const GValue *from_value,
|
||||
GValue *to_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkRGBA *rgba = g_value_get_boxed (from_value);
|
||||
g_value_take_object (to_value, get_circle_paintable_from_color (rgba, 16));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
create_row_func (gpointer data,
|
||||
gpointer user_data)
|
||||
@@ -57,7 +68,6 @@ create_row_func (gpointer data,
|
||||
g_autoptr (GdkPaintable) paintable = NULL;
|
||||
GcalCalendar *calendar;
|
||||
GtkWidget *label, *icon, *checkbox, *box, *row;
|
||||
const GdkRGBA *color;
|
||||
|
||||
calendar = GCAL_CALENDAR (data);
|
||||
|
||||
@@ -71,11 +81,16 @@ create_row_func (gpointer data,
|
||||
gtk_widget_set_margin_end (box, 6);
|
||||
|
||||
/* source color icon */
|
||||
color = gcal_calendar_get_color (calendar);
|
||||
paintable = get_circle_paintable_from_color (color, 16);
|
||||
icon = gtk_image_new_from_paintable (paintable);
|
||||
|
||||
icon = gtk_image_new ();
|
||||
gtk_widget_add_css_class (icon, "calendar-color-image");
|
||||
g_object_bind_property_full (calendar, "color",
|
||||
icon, "paintable",
|
||||
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
|
||||
paintable_from_gdk_rgb,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
||||
/* source name label */
|
||||
label = gtk_label_new (gcal_calendar_get_name (calendar));
|
||||
|
||||
Reference in New Issue
Block a user