[evolution] Bug 747751 - Do not display reminders for past events/tasks/memos by default



commit e4d477620bba98514029425cb524b10a475fb85e
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jan 19 12:35:04 2017 +0100

    Bug 747751 - Do not display reminders for past events/tasks/memos by default

 data/org.gnome.evolution.calendar.gschema.xml.in |    5 +++++
 src/calendar/alarm-notify/alarm-queue.c          |    8 +++++++-
 src/calendar/alarm-notify/config-data.c          |    8 ++++++++
 src/calendar/alarm-notify/config-data.h          |    2 ++
 src/modules/calendar/e-calendar-preferences.c    |    6 ++++++
 src/modules/calendar/e-calendar-preferences.ui   |   21 ++++++++++++++++++---
 6 files changed, 46 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in 
b/data/org.gnome.evolution.calendar.gschema.xml.in
index f76d41f..5436d1a 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -234,6 +234,11 @@
       <_summary>Last reminder time</_summary>
       <_description>Time the last reminder ran, in time_t</_description>
     </key>
+    <key name="allow-past-reminders" type="b">
+      <default>false</default>
+      <_summary>Allow past reminders</_summary>
+      <_description>Whether can show reminders for events/tasks/memos which already happened</_description>
+    </key>
     <key name="marcus-bains-color-dayview" type="s">
       <default>'#ff0000'</default>
       <_summary>Marcus Bains Line Color — Day View</_summary>
diff --git a/src/calendar/alarm-notify/alarm-queue.c b/src/calendar/alarm-notify/alarm-queue.c
index 50a9aa3..106e6f3 100644
--- a/src/calendar/alarm-notify/alarm-queue.c
+++ b/src/calendar/alarm-notify/alarm-queue.c
@@ -495,6 +495,12 @@ alarm_trigger_cb (gpointer alarm_id,
        if (!qa)
                return;
 
+       /* Skip non-snoozed passed reminders, if setup to do so */
+       if (!qa->snooze && qa->orig_trigger < (time (NULL) - (5 * 60)) &&
+           !config_data_get_allow_past_reminders ()) {
+               return;
+       }
+
        /* Decide what to do based on the alarm action.  We use the trigger that
         * is passed to us instead of the one from the instance structure
         * because this may be a snoozed alarm instead of an original
@@ -503,7 +509,7 @@ alarm_trigger_cb (gpointer alarm_id,
 
        alarm = e_cal_component_get_alarm (comp, qa->instance->auid);
        if (!alarm)
-                return;
+               return;
 
        e_cal_component_alarm_get_action (alarm, &action);
        e_cal_component_alarm_free (alarm);
diff --git a/src/calendar/alarm-notify/config-data.c b/src/calendar/alarm-notify/config-data.c
index 9f209d2..937d440 100644
--- a/src/calendar/alarm-notify/config-data.c
+++ b/src/calendar/alarm-notify/config-data.c
@@ -122,6 +122,14 @@ config_data_get_default_snooze_minutes (void)
        return g_settings_get_int (calendar_settings, "default-snooze-minutes");
 }
 
+gboolean
+config_data_get_allow_past_reminders (void)
+{
+       ensure_inited ();
+
+       return g_settings_get_boolean (calendar_settings, "allow-past-reminders");
+}
+
 static void
 source_written_cb (GObject *source_object,
                    GAsyncResult *result,
diff --git a/src/calendar/alarm-notify/config-data.h b/src/calendar/alarm-notify/config-data.h
index 57eafa2..01e8b73 100644
--- a/src/calendar/alarm-notify/config-data.h
+++ b/src/calendar/alarm-notify/config-data.h
@@ -38,6 +38,8 @@ gboolean      config_data_get_task_reminder_for_completed
                                                (void);
 gint           config_data_get_default_snooze_minutes
                                                (void);
+gboolean       config_data_get_allow_past_reminders
+                                               (void);
 void           config_data_set_last_notification_time
                                                (ECalClient *cal,
                                                 time_t t);
diff --git a/src/modules/calendar/e-calendar-preferences.c b/src/modules/calendar/e-calendar-preferences.c
index d5a788c..4283bfc 100644
--- a/src/modules/calendar/e-calendar-preferences.c
+++ b/src/modules/calendar/e-calendar-preferences.c
@@ -1074,6 +1074,12 @@ calendar_preferences_construct (ECalendarPreferences *prefs,
                widget, "active",
                G_SETTINGS_BIND_DEFAULT);
 
+       widget = e_builder_get_widget (prefs->priv->builder, "allow-past-reminders");
+       g_settings_bind (
+               settings, "allow-past-reminders",
+               widget, "active",
+               G_SETTINGS_BIND_DEFAULT);
+
        widget = e_builder_get_widget (prefs->priv->builder, "default-snooze-minutes-spin");
        g_settings_bind (
                settings, "default-snooze-minutes",
diff --git a/src/modules/calendar/e-calendar-preferences.ui b/src/modules/calendar/e-calendar-preferences.ui
index 60b5d25..825883f 100644
--- a/src/modules/calendar/e-calendar-preferences.ui
+++ b/src/modules/calendar/e-calendar-preferences.ui
@@ -1376,6 +1376,21 @@
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkCheckButton" id="allow-past-reminders">
+                    <property name="label" translatable="yes">Display reminders for _past events</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkHBox" id="hbox6">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -1442,7 +1457,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">4</property>
+                    <property name="position">5</property>
                   </packing>
                 </child>
                 <child>
@@ -1512,7 +1527,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">5</property>
+                    <property name="position">6</property>
                   </packing>
                 </child>
                 <child>
@@ -1551,7 +1566,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">6</property>
+                    <property name="position">7</property>
                   </packing>
                 </child>
               </object>


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