From da90b94bbd1a0ec80a0bf27a5d626564f66a7168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20H=C3=BCgel?= <129184-gwastar@users.noreply.gitlab.gnome.org> Date: Sat, 4 Nov 2023 13:23:45 +0100 Subject: [PATCH] views/month: Jump to first day of month with PgUp/PgDown With this we always jump to the first day of the next/previous month when pressing the PgDown/PgUp key in the month view. Partially fixes the regression described in https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1103 Co-authored-by: Maximiliano Sandoval Part-of: --- src/gui/views/gcal-month-view.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/views/gcal-month-view.c b/src/gui/views/gcal-month-view.c index 18125fb4..84e66c67 100644 --- a/src/gui/views/gcal-month-view.c +++ b/src/gui/views/gcal-month-view.c @@ -1227,9 +1227,14 @@ static GDateTime* gcal_month_view_get_next_date (GcalView *view) { GcalMonthView *self = GCAL_MONTH_VIEW (view); + g_autoptr (GDateTime) date = NULL; + gint year, month; - g_assert (self->date != NULL); - return g_date_time_add_months (self->date, 1); + g_assert_nonnull (self->date); + date = g_date_time_add_months (self->date, 1); + g_date_time_get_ymd (date, &year, &month, NULL); + + return g_date_time_new_local (year, month, 1, 0, 0, 0); } @@ -1237,9 +1242,14 @@ static GDateTime* gcal_month_view_get_previous_date (GcalView *view) { GcalMonthView *self = GCAL_MONTH_VIEW (view); + g_autoptr (GDateTime) date = NULL; + gint year, month; - g_assert (self->date != NULL); - return g_date_time_add_months (self->date, -1); + g_assert_nonnull (self->date); + date = g_date_time_add_months (self->date, -1); + g_date_time_get_ymd (date, &year, &month, NULL); + + return g_date_time_new_local (year, month, 1, 0, 0, 0); } static void