[evolution-data-server] alarm-notify: Default notify-past-events to false plus few related fixes



commit 9131553fe1ba7eb13acf39c093a99dbd8cc96f90
Author: Milan Crha <mcrha redhat com>
Date:   Wed Mar 3 11:06:23 2021 +0100

    alarm-notify: Default notify-past-events to false plus few related fixes
    
    Let the default to notify about past events be false, to not show years
    of past reminders after a calendar is set up.
    
    The related fixes change how it's decided whether the reminder
    is past or not, fixing a missing absolute trigger as well.

 ...e.evolution-data-server.calendar.gschema.xml.in |  2 +-
 .../evolution-alarm-notify/e-alarm-notify.c        | 25 ++++++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/data/org.gnome.evolution-data-server.calendar.gschema.xml.in 
b/data/org.gnome.evolution-data-server.calendar.gschema.xml.in
index 1ed568de6..f6c9ecd66 100644
--- a/data/org.gnome.evolution-data-server.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution-data-server.calendar.gschema.xml.in
@@ -73,7 +73,7 @@
       <_summary>Show reminder notification for completed tasks</_summary>
     </key>
     <key name="notify-past-events" type="b">
-      <default>true</default>
+      <default>false</default>
       <_summary>Show reminder notification for past events</_summary>
     </key>
     <key name="notify-last-snooze-minutes" type="i">
diff --git a/src/services/evolution-alarm-notify/e-alarm-notify.c 
b/src/services/evolution-alarm-notify/e-alarm-notify.c
index 428a1bd8e..7b9ce0b3b 100644
--- a/src/services/evolution-alarm-notify/e-alarm-notify.c
+++ b/src/services/evolution-alarm-notify/e-alarm-notify.c
@@ -590,26 +590,43 @@ e_alarm_notify_process (EAlarmNotify *an,
 
        if (!snoozed && !g_settings_get_boolean (an->priv->settings, "notify-past-events")) {
                ECalComponentAlarmTrigger *trigger;
-               time_t offset = 0, event_relative, orig_trigger_day, today;
+               ICalTime *itt;
+               ICalDuration *duration = NULL;
+               time_t event_relative, orig_trigger_day, today;
 
                trigger = e_cal_component_alarm_get_trigger (alarm);
+               event_relative = e_cal_component_alarm_instance_get_occur_start (instance);
 
                switch (trigger ? e_cal_component_alarm_trigger_get_kind (trigger) : 
E_CAL_COMPONENT_ALARM_TRIGGER_NONE) {
                case E_CAL_COMPONENT_ALARM_TRIGGER_NONE:
+                       break;
                case E_CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE:
+                       itt = e_cal_component_alarm_trigger_get_absolute_time (trigger);
+                       if (itt)
+                               event_relative = i_cal_time_as_timet_with_zone (itt, 
i_cal_timezone_get_utc_timezone ());
                        break;
-
                case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START:
+                       duration = e_cal_component_alarm_trigger_get_duration (trigger);
+                       break;
                case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END:
-                       offset = i_cal_duration_as_int (e_cal_component_alarm_trigger_get_duration (trigger));
+                       event_relative = e_cal_component_alarm_instance_get_occur_end (instance);
+                       duration = e_cal_component_alarm_trigger_get_duration (trigger);
                        break;
 
                default:
                        break;
                }
 
+               /* The trigger time is set as "after the event start/end". */
+               if (duration && !i_cal_duration_is_neg (duration)) {
+                       gint offset;
+
+                       offset = i_cal_duration_as_int (duration);
+
+                       event_relative += offset;
+               }
+
                today = time (NULL);
-               event_relative = e_cal_component_alarm_instance_get_occur_start (instance) - offset;
 
                #define CLAMP_TO_DAY(x) ((x) - ((x) % (60 * 60 * 24)))
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]