Move recurrence fields into GcalScheduleSectionValues, split it into "orig" and "curr" values

This commit does a bit too much, but with these themes:

- Move the recurrence fields into GcalScheduleValues.  This was needed
  for consistency, anyway, and...

- ... the next step was to make ::changed() work, which actually
  required knowing the original and current values of the recurrence as
  well as the dates.

- But then, having a field "orig_foo" for each field "foo" starts
  getting unwieldy.  So, I moved things around:

  - GcalScheduleValues has start/end dates and all_day, and the recurrence.

  - GcalScheduleSectionValues is new; it has the "orig" and "curr"
    values of the previous type.  This simplifies memory management
    since each field can be freed with gcal_schedule_values_free()
    instead of duplicating _free() for each sub-field.

  - GcalScheduleSectionValues also has time_format, as a way to
    decouple that value from GcalContext.  It's not in orig/curr
    because it does not pertain the event; it's just a display-related
    thing.

- Actually fix gcal_schedule_section_changed(),
  gcal_schedule_section_recurrence_changed(), and
  gcal_schedule_section_day_changed().  These become simple since they
  just look at the orig/curr fields, without having to touch widgetry.

- All test pass.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/550>
This commit is contained in:
Federico Mena Quintero
2025-08-27 20:00:00 -03:00
committed by Georges Basile Stavracas Neto
parent dfc3833253
commit 324e3ef71c
2 changed files with 341 additions and 323 deletions
File diff suppressed because it is too large Load Diff
+16 -12
View File
@@ -41,29 +41,33 @@ typedef struct
{
gboolean all_day;
/* Original times from the GcalEvent. We keep these around to be able to reconstruct
* the event's duration in case the all-day toggle gets turned on and off repeatedly.
*/
gboolean orig_all_day;
GDateTime *orig_date_start;
GDateTime *orig_date_end;
GDateTime *date_start;
GDateTime *date_end;
GcalRecurrence *recur;
GcalTimeFormat time_format;
} GcalScheduleValues;
typedef struct
{
/* original values from event */
GcalScheduleValues orig;
/* current values, as modified by actions from widgets */
GcalScheduleValues curr;
/* copied from GcalContext to avoid a dependency on it */
GcalTimeFormat time_format;
} GcalScheduleSectionValues;
gboolean gcal_schedule_section_recurrence_changed (GcalScheduleSection *self);
gboolean gcal_schedule_section_day_changed (GcalScheduleSection *self);
GcalScheduleValues *gcal_schedule_values_from_event (GcalEvent *event,
GcalTimeFormat time_format);
void gcal_schedule_values_free (GcalScheduleValues *values);
GcalScheduleSectionValues *gcal_schedule_section_values_from_event (GcalEvent *event,
GcalTimeFormat time_format);
void gcal_schedule_section_values_free (GcalScheduleSectionValues *values);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GcalScheduleValues, gcal_schedule_values_free);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GcalScheduleSectionValues, gcal_schedule_section_values_free);
/* Tests */