From 006437bf61e5fee0240978e1496769d01d3224bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Thu, 22 Feb 2024 10:56:05 -0500 Subject: [PATCH] Avoid duplication when adding online calendars When subscribing to one or multiple online Webcal or CalDAV calendars, do not unexpectedly create an extra local calendar. While this doesn't allow customizing names & colors while subscribing, users can still easily set those just after adding the subscriptions, as they are then returned to the "Calendars" page of "Manage Calendars". Punting this to a separate step might not seem like the "perfect" flow, but it works well enough and fixes the buggy UX that we currently had. Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/566 Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/978 --- .../calendar-management/gcal-new-calendar-page.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/calendar-management/gcal-new-calendar-page.c b/src/gui/calendar-management/gcal-new-calendar-page.c index 8086f9d1..4a1d1b04 100644 --- a/src/gui/calendar-management/gcal-new-calendar-page.c +++ b/src/gui/calendar-management/gcal-new-calendar-page.c @@ -147,10 +147,10 @@ update_add_button (GcalNewCalendarPage *self) gtk_widget_set_sensitive (self->add_button, valid); n_calendars = 0; - if (self->local_source) - n_calendars++; if (self->remote_sources) n_calendars += self->remote_sources->len; + else if (self->local_source) + n_calendars++; if (n_calendars > 0) { @@ -391,10 +391,6 @@ on_add_button_clicked_cb (GtkWidget *button, manager = gcal_context_get_manager (self->context); - /* Commit the new source */ - if (self->local_source) - gcal_manager_save_source (manager, self->local_source); - /* Commit each new remote source */ if (self->remote_sources) { @@ -406,6 +402,11 @@ on_add_button_clicked_cb (GtkWidget *button, g_clear_pointer (&self->remote_sources, g_ptr_array_unref); } + else + { + gcal_manager_save_source (manager, self->local_source); + } + gcal_calendar_management_page_switch_page (GCAL_CALENDAR_MANAGEMENT_PAGE (self), "calendars", NULL);