From e8468ec0df978a684f70b5b25a22996948646ff2 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 30 Nov 2017 14:14:01 -0200 Subject: [PATCH] event-widget: use a 16px rounded rectangle for event colors This looks better than the thin borders, helps a lot colorblind people and makes the overall layout just as good. Ship it! [#211] --- data/ui/event-widget.ui | 17 +++++++++++++++-- src/css-code.h | 11 ++++++----- src/gcal-event-widget.c | 15 ++++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/data/ui/event-widget.ui b/data/ui/event-widget.ui index 8eb78c9e..f98b09ea 100644 --- a/data/ui/event-widget.ui +++ b/data/ui/event-widget.ui @@ -18,6 +18,19 @@ True False 4 + + + True + False + + + + 0 + 0 + + True @@ -27,7 +40,7 @@ end - 0 + 1 0 @@ -40,7 +53,7 @@ - 1 + 2 0 diff --git a/src/css-code.h b/src/css-code.h index f8f3d1ad..a10912d0 100644 --- a/src/css-code.h +++ b/src/css-code.h @@ -23,13 +23,14 @@ ".color-%1$d {"\ " background-color: %2$s"\ "}"\ -".color-%1$d.horizontal.timed:dir(ltr) {"\ +".color-%1$d.horizontal.timed {"\ " background-color: transparent;"\ -" border-left: solid 4px %2$s;"\ "}"\ -".color-%1$d.horizontal.timed:dir(rtl) {"\ -" background-color: transparent;"\ -" border-right: solid 4px %2$s;"\ +".color-%1$d.horizontal.timed box.icon-box{"\ +" background-color: %2$s;"\ +" border-radius: 2px;"\ +" min-height: 16px;"\ +" min-width: 16px;"\ "}"\ ".color-%1$d.slanted {"\ " background-color: transparent;"\ diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c index b4f2ffd3..fc236257 100644 --- a/src/gcal-event-widget.c +++ b/src/gcal-event-widget.c @@ -38,6 +38,7 @@ struct _GcalEventWidget GDateTime *dt_end; /* widgets */ + GtkWidget *color_box; GtkWidget *horizontal_grid; GtkWidget *hour_label; GtkWidget *stack; @@ -173,6 +174,7 @@ gcal_event_widget_update_style (GcalEventWidget *self) GtkStyleContext *context; gboolean slanted_start; gboolean slanted_end; + gboolean timed; context = gtk_widget_get_style_context (GTK_WIDGET (self)); slanted_start = FALSE; @@ -221,17 +223,19 @@ gcal_event_widget_update_style (GcalEventWidget *self) * If the event is a timed, single-day event, draw it differently * from all-day or multi-day events. */ - if (!gcal_event_get_all_day (self->event) && !gcal_event_is_multiday (self->event)) + timed = !gcal_event_get_all_day (self->event) && !gcal_event_is_multiday (self->event); + + gtk_widget_set_visible (self->color_box, timed); + + if (timed) { GtkStyleContext *context; context = gtk_widget_get_style_context (GTK_WIDGET (self)); - gtk_style_context_add_class (context, "timed"); - /* XXX: hardcoding these values isn't really great... */ - if (self->orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_widget_set_margin_start (self->stack, 8); + gtk_widget_set_margin_start (self->stack, 0); + gtk_widget_set_margin_end (self->stack, 2); } } @@ -924,6 +928,7 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/event-widget.ui"); + gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, color_box); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, horizontal_grid); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, hour_label); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, stack);