From e2a3d315325e994d335050cf732ec90b3d126b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Fri, 25 Aug 2023 23:12:42 -0400 Subject: [PATCH] month-cell: Use full-length month names when safe to do so Full month names are easier to notice and read while scrolling, and would be read more naturally by text-to-speech screen readers. An exception must be made when today is near the beginning of the month, as the weather forecast temperatures labels might also appear there. In that case, use the abbreviated version of the month name label. Fixes issue #962 --- src/gui/views/gcal-month-cell.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gui/views/gcal-month-cell.c b/src/gui/views/gcal-month-cell.c index 86bf2dfc..85f952a8 100644 --- a/src/gui/views/gcal-month-cell.c +++ b/src/gui/views/gcal-month-cell.c @@ -182,12 +182,15 @@ update_weather (GcalMonthCell *self) GcalWeatherService *weather_service; GcalWeatherInfo *weather_info; GDate date; + gint day_of_month; if (!self->context) return; + day_of_month = g_date_time_get_day_of_month (self->date); + g_date_set_dmy (&date, - g_date_time_get_day_of_month (self->date), + day_of_month, g_date_time_get_month (self->date), g_date_time_get_year (self->date)); @@ -211,11 +214,25 @@ update_weather (GcalMonthCell *self) gtk_image_set_from_icon_name (self->weather_icon, icon_name); gtk_label_set_text (self->temp_label, temp_str); + + /* Use a short month name label to avoid conflicting with the weather forecast's labels */ + if (day_of_month == 1) + { + g_autofree gchar *month_name = g_date_time_format (self->date, "%b"); + gtk_label_set_text (self->month_name_label, month_name); + } } else { gtk_image_clear (self->weather_icon); gtk_label_set_text (self->temp_label, ""); + + /* No risk of conflicting with the weather forecast labels in their absence, use the full month name label */ + if (day_of_month == 1) + { + g_autofree gchar *month_name = g_date_time_format (self->date, "%B"); + gtk_label_set_text (self->month_name_label, month_name); + } } } @@ -486,7 +503,7 @@ gcal_month_cell_set_date (GcalMonthCell *self, gtk_widget_set_visible (GTK_WIDGET (self->month_name_label), day_of_month == 1); if (day_of_month == 1) { - g_autofree gchar *month_name = g_date_time_format (date, "%b"); + g_autofree gchar *month_name = g_date_time_format (date, "%B"); gtk_label_set_text (self->month_name_label, month_name); gtk_widget_add_css_class (GTK_WIDGET (self->month_name_label), "heading"); gtk_widget_add_css_class (GTK_WIDGET (self->day_label), "heading");