[gnome-calendar/gbsneto/recurring-event-editing-fixes: 21/24] event-editor/dialog: Improve detection of MOD_ALL exclusion cases
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/recurring-event-editing-fixes: 21/24] event-editor/dialog: Improve detection of MOD_ALL exclusion cases
- Date: Tue, 18 Oct 2022 02:36:35 +0000 (UTC)
commit 102346534a0454a3985632d6ddbf71f4602bb1c1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Oct 17 14:03:41 2022 -0300
event-editor/dialog: Improve detection of MOD_ALL exclusion cases
src/gui/event-editor/gcal-event-editor-dialog.c | 18 +++++++-----------
src/gui/event-editor/gcal-schedule-section.c | 17 +++++++++++++++++
src/gui/event-editor/gcal-schedule-section.h | 2 ++
3 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/src/gui/event-editor/gcal-event-editor-dialog.c b/src/gui/event-editor/gcal-event-editor-dialog.c
index 3f83e7a1..6c3527db 100644
--- a/src/gui/event-editor/gcal-event-editor-dialog.c
+++ b/src/gui/event-editor/gcal-event-editor-dialog.c
@@ -331,7 +331,7 @@ on_done_button_clicked_cb (GtkButton *button,
GcalCalendar *selected_calendar;
GcalCalendar *calendar;
GcalManager *manager;
- gboolean schedule_changed;
+ gboolean can_show_mod_all;
gboolean was_recurrent;
gint i;
@@ -341,7 +341,7 @@ on_done_button_clicked_cb (GtkButton *button,
if (gcal_calendar_is_read_only (calendar))
GCAL_GOTO (out);
- schedule_changed = FALSE;
+ can_show_mod_all = TRUE;
if (!self->event_is_new)
{
gboolean anything_changed = FALSE;
@@ -352,18 +352,14 @@ on_done_button_clicked_cb (GtkButton *button,
section_changed = gcal_event_editor_section_changed (self->sections[i]);
anything_changed |= section_changed;
-
- if (self->sections[i] == self->schedule_section)
- schedule_changed = section_changed;
}
- GCAL_TRACE_MSG ("Event %s changed: %d, schedule changed: %d",
- gcal_event_get_uid (self->event),
- anything_changed,
- schedule_changed);
-
if (!anything_changed)
goto out;
+
+ can_show_mod_all =
+ !gcal_schedule_section_recurrence_changed (GCAL_SCHEDULE_SECTION (self->schedule_section)) &&
+ !gcal_schedule_section_day_changed (GCAL_SCHEDULE_SECTION (self->schedule_section));
}
/*
@@ -399,7 +395,7 @@ on_done_button_clicked_cb (GtkButton *button,
{
gcal_utils_ask_recurrence_modification_type (GTK_WIDGET (self),
self->event,
- !schedule_changed,
+ can_show_mod_all,
on_ask_recurrence_response_save_cb,
self);
return;
diff --git a/src/gui/event-editor/gcal-schedule-section.c b/src/gui/event-editor/gcal-schedule-section.c
index 93f5e029..2aed8e30 100644
--- a/src/gui/event-editor/gcal-schedule-section.c
+++ b/src/gui/event-editor/gcal-schedule-section.c
@@ -827,3 +827,20 @@ gcal_schedule_section_recurrence_changed (GcalScheduleSection *self)
GCAL_RETURN (!gcal_recurrence_is_equal (recurrence, gcal_event_get_recurrence (self->event)));
}
+
+gboolean
+gcal_schedule_section_day_changed (GcalScheduleSection *self)
+{
+ g_autoptr (GDateTime) start_date = NULL;
+ g_autoptr (GDateTime) end_date = NULL;
+
+ g_return_val_if_fail (GCAL_IS_SCHEDULE_SECTION (self), FALSE);
+
+ GCAL_ENTRY;
+
+ start_date = get_date_start (self);
+ end_date = get_date_end (self);
+
+ GCAL_RETURN (gcal_date_time_compare_date (start_date, gcal_event_get_date_start (self->event)) < 0 ||
+ gcal_date_time_compare_date (end_date, gcal_event_get_date_end (self->event)) > 0);
+}
diff --git a/src/gui/event-editor/gcal-schedule-section.h b/src/gui/event-editor/gcal-schedule-section.h
index ee676a82..def974c3 100644
--- a/src/gui/event-editor/gcal-schedule-section.h
+++ b/src/gui/event-editor/gcal-schedule-section.h
@@ -29,4 +29,6 @@ G_DECLARE_FINAL_TYPE (GcalScheduleSection, gcal_schedule_section, GCAL, SCHEDULE
gboolean gcal_schedule_section_recurrence_changed (GcalScheduleSection *self);
+gboolean gcal_schedule_section_day_changed (GcalScheduleSection *self);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]