From b4ff1a2458802e3238d952c69f9dd664f013137b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 1 Feb 2016 18:05:45 -0600 Subject: don't show calendar event notifications if com.ubuntu.calendar's notifications are blacklisted --- include/datetime/settings.h | 1 + src/snap.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/datetime/settings.h b/include/datetime/settings.h index 253a00a..d5e81c6 100644 --- a/include/datetime/settings.h +++ b/include/datetime/settings.h @@ -61,6 +61,7 @@ public: core::Property alarm_volume; core::Property alarm_duration; core::Property snooze_duration; + core::Property>> muted_apps; }; } // namespace datetime diff --git a/src/snap.cpp b/src/snap.cpp index f0300af..934ad19 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -84,6 +84,12 @@ public: appointment_func snooze, appointment_func ok) { + // If calendar notifications are muted, don't show them + if (!appointment.is_ubuntu_alarm() && calendar_events_are_muted()) { + g_debug("Skipping muted calendar event '%s' notification", appointment.summary.c_str()); + return; + } + /* Alarms and calendar events are treated differently. Alarms should require manual intervention to dismiss. Calendar events are less urgent and shouldn't require manual @@ -159,6 +165,17 @@ public: private: + bool calendar_events_are_muted() const + { + for(const auto& app : m_settings->muted_apps.get()) { + if (app.first == "com.ubuntu.calendar") { + return true; + } + } + + return false; + } + static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself) { GError * error; -- cgit v1.2.3