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
This commit is contained in:
Isaque Galdino
2016-01-29 22:51:12 -02:00
committed by Georges Basile Stavracas Neto
parent 5cfee45f7a
commit e8c75cea32
2 changed files with 48 additions and 0 deletions
+13
View File
@@ -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;
+35
View File
@@ -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);