From 107d4a067ebe4727953bfab0e12850eb2e36e19e Mon Sep 17 00:00:00 2001 From: mindonwarp Date: Sun, 30 Aug 2026 10:45:50 +0200 Subject: [PATCH] gui: Use the new GcalContext API to get week start day once This gets the globally set start-of-week setting on application startup. Making the views redraw themselves on setting change while running will be a later step. Part-of: --- src/gui/common/gcal-date-chooser.c | 2 +- src/gui/views/gcal-month-view.c | 7 +++++-- src/utils/gcal-date-time-utils.c | 7 ++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/common/gcal-date-chooser.c b/src/gui/common/gcal-date-chooser.c index 9cc83ed2..17a0666a 100644 --- a/src/gui/common/gcal-date-chooser.c +++ b/src/gui/common/gcal-date-chooser.c @@ -1083,7 +1083,7 @@ gcal_date_chooser_init (GcalDateChooser *self) self->date = g_date_time_new_now_local (); g_date_time_get_ymd (self->date, &self->this_year, NULL, NULL); - self->week_start = gcal_util_get_first_weekday_iso (); + self->week_start = gcal_context_get_week_start_day (context); gtk_widget_init_template (GTK_WIDGET (self)); diff --git a/src/gui/views/gcal-month-view.c b/src/gui/views/gcal-month-view.c index e5868c07..bf380eab 100644 --- a/src/gui/views/gcal-month-view.c +++ b/src/gui/views/gcal-month-view.c @@ -19,9 +19,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#include "config.h" + #define G_LOG_DOMAIN "GcalMonthView" -#include "config.h" #include "gcal-debug.h" #include "gcal-event-widget-pool.h" #include "gcal-gui-utils.h" @@ -194,7 +195,9 @@ allocate_overflow_popover (GcalMonthView *self, static inline void update_weekday_labels (GcalMonthView *self) { - const gint first_weekday = gcal_util_get_first_weekday_iso (); + GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION); + + const gint first_weekday = gcal_context_get_week_start_day (context); for (gint i = 0; i < GCAL_N_WEEKDAYS; i++) { diff --git a/src/utils/gcal-date-time-utils.c b/src/utils/gcal-date-time-utils.c index 202aecf3..84b8728a 100644 --- a/src/utils/gcal-date-time-utils.c +++ b/src/utils/gcal-date-time-utils.c @@ -19,6 +19,8 @@ */ #include "gcal-date-time-utils.h" +#include "gcal-application.h" +#include "gcal-context.h" #include "gcal-utils.h" /** @@ -76,6 +78,9 @@ gcal_date_time_get_days_in_month (GDateTime *date) GDateTime* gcal_date_time_get_start_of_week (GDateTime *date) { + GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION); + g_assert (GCAL_IS_CONTEXT (context)); + g_autoptr (GDateTime) start_of_week = NULL; gint n_days_after_week_start; gint first_weekday; @@ -83,7 +88,7 @@ gcal_date_time_get_start_of_week (GDateTime *date) g_assert (date != NULL); - first_weekday = gcal_util_get_first_weekday_iso (); + first_weekday = gcal_context_get_week_start_day (context); weekday = g_date_time_get_day_of_week (date) % GCAL_N_WEEKDAYS; n_days_after_week_start = (GCAL_N_WEEKDAYS + weekday - first_weekday) % GCAL_N_WEEKDAYS;