[gnome-calendar] year-view: Added visual clue for days with events
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] year-view: Added visual clue for days with events
- Date: Sat, 30 Jan 2016 00:52:58 +0000 (UTC)
commit e8c75cea3219c88000f4bca6d224506cf8ad1375
Author: Isaque Galdino <igaldino gmail com>
Date: Wed Jan 27 16:57:47 2016 -0200
year-view: Added visual clue for days with events
Year view didn't have hints for days with events and this feature was
requested to be added to gnome-calendar.
This is an old request but in the past gnome-design team though it would
be better to keep the layout simple without hints for days with events.
Now with the changes in gnome-shell calendar and in order to keep them
in sync, this feature was added to gnome-calendar.
In order to implement this code we had to add a few css styles and a
code to add a small circle below everyday with events. Although
gnome-shell calendar uses an svg image with a 3x3 dot, we chose to use a
pango function to draw the dot.
https://bugzilla.gnome.org/show_bug.cgi?id=743317
data/theme/gtk-styles.css | 13 +++++++++++++
src/gcal-year-view.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index 14e8dd1..7d0eda2 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -120,6 +120,19 @@ calendar-view.second-view-header {
font-weight: bold;
}
+.year-navigator.with-events {
+ background-color: @theme_fg_color;
+ border-radius: 3px;
+}
+
+.year-navigator.with-events-selected {
+ background-color: @theme_selected_bg_color;
+}
+
+.year-navigator.with-events-sunday {
+ background-color: alpha(@theme_fg_color, 0.5);
+}
+
.sidebar-header {
font-weight: bold;
font-size: 11px;
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index df9543b..503a21f 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -28,6 +28,7 @@
#define NAVIGATOR_CELL_WIDTH (210 + 15)
#define NAVIGATOR_CELL_HEIGHT 210
#define SIDEBAR_PREFERRED_WIDTH 200
+#define VISUAL_CLUES_SIDE 3.0
typedef struct
{
@@ -526,6 +527,8 @@ draw_month_grid (GcalYearView *year_view,
gint days_delay, days, shown_rows, sunday_idx;
gchar *str, *nr_day, *nr_week;
gboolean selected_day;
+ GList *events;
+ icaltimetype start_date, end_date;
cairo_save (cr);
context = gtk_widget_get_style_context (widget);
@@ -590,6 +593,19 @@ draw_month_grid (GcalYearView *year_view,
shown_rows = ceil (days / 7.0);
sunday_idx = year_view->k * 6 + sw * ((7 - year_view->first_weekday) % 7);
+ start_date.day = 1;
+ start_date.month = month_nr + 1;
+ start_date.year = year_view->date->year;
+ start_date.hour = 0;
+ start_date.minute = 0;
+ start_date.second = 0;
+ end_date.day = 1;
+ end_date.month = month_nr + 1;
+ end_date.year = year_view->date->year;
+ end_date.hour = 23;
+ end_date.minute = 59;
+ end_date.second = 59;
+
for (i = 0; i < 7 * shown_rows; i++)
{
column = i % 7;
@@ -695,6 +711,25 @@ draw_month_grid (GcalYearView *year_view,
layout);
}
+ start_date.day = end_date.day = j;
+ events = gcal_manager_get_events (year_view->manager, &start_date, &end_date);
+ if (events != NULL)
+ {
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, "with-events");
+ if (selected_day)
+ gtk_style_context_add_class (context, "with-events-selected");
+ else if (column == sunday_idx)
+ gtk_style_context_add_class (context, "with-events-sunday");
+ box_padding_start = (box_side - VISUAL_CLUES_SIDE) / 2 > 0 ? (box_side - VISUAL_CLUES_SIDE) / 2 :
0;
+ gtk_render_background (context, cr,
+ box_side * (column + 0.5 + year_view->k) + x + sw * box_padding_start -
year_view->k * VISUAL_CLUES_SIDE,
+ box_side * (row + 1) + y + box_padding_top + layout_height + 2.0,
+ VISUAL_CLUES_SIDE, VISUAL_CLUES_SIDE);
+ gtk_style_context_restore (context);
+ g_list_free_full (events, g_free);
+ }
+
g_free (nr_day);
}
pango_font_description_free (font_desc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]