aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/notifications/notifications.h6
-rw-r--r--src/notifications.cpp23
-rw-r--r--src/snap.cpp8
3 files changed, 33 insertions, 4 deletions
diff --git a/include/notifications/notifications.h b/include/notifications/notifications.h
index 450c45b..a76ec45 100644
--- a/include/notifications/notifications.h
+++ b/include/notifications/notifications.h
@@ -77,6 +77,12 @@ public:
/** Sets the time-out callback. This will be called exactly once. */
void set_timeout_callback (std::function<void()>);
+ /** Sets if a notification bubble should be displayed. */
+ void set_show_notification_bubble (bool show);
+
+ /** Sets if notification should be posted to messaging menu after it is closed. */
+ void set_post_to_messaging_menu (bool post);
+
private:
friend class Engine;
diff --git a/src/notifications.cpp b/src/notifications.cpp
index 3c90e57..4a2c846 100644
--- a/src/notifications.cpp
+++ b/src/notifications.cpp
@@ -63,6 +63,8 @@ public:
std::vector<std::pair<std::string,std::string>> m_actions;
std::function<void(const std::string&)> m_closed_callback;
std::function<void()> m_timeout_callback;
+ bool m_show_notification_bubble;
+ bool m_post_to_messaging_menu;
};
Builder::Builder():
@@ -128,6 +130,18 @@ Builder::set_start_time (uint64_t time)
impl->m_start_time = time;
}
+void
+Builder::set_show_notification_bubble (bool show)
+{
+ impl->m_show_notification_bubble = show;
+}
+
+void
+Builder::set_post_to_messaging_menu (bool post)
+{
+ impl->m_post_to_messaging_menu = post;
+}
+
/***
****
***/
@@ -265,6 +279,11 @@ public:
g_signal_connect (nn.get(), "closed",
G_CALLBACK(on_notification_closed), this);
+ if (!info.m_show_notification_bubble) {
+ post(info);
+ return ret;
+ }
+
GError * error = nullptr;
if (notify_notification_show(nn.get(), &error))
{
@@ -284,6 +303,10 @@ public:
std::string post(const Builder::Impl& data)
{
+ if (!data.m_post_to_messaging_menu) {
+ return "";
+ }
+
if (!m_messaging_app) {
return std::string();
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 273f125..1b7c183 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -96,10 +96,7 @@ public:
const bool interactive = appointment.is_ubuntu_alarm() && m_engine->supports_actions();
// force the system to stay awake
- std::shared_ptr<ain::Awake> awake;
- if (appointment.is_ubuntu_alarm() || calendar_bubbles_enabled()) {
- awake = std::make_shared<ain::Awake>(m_engine->app_name());
- }
+ std::shared_ptr<ain::Awake> awake = std::make_shared<ain::Awake>(m_engine->app_name());
// calendar events are muted in silent mode; alarm clocks never are
std::shared_ptr<ain::Sound> sound;
@@ -183,6 +180,9 @@ public:
});
}
+ b.set_show_notification_bubble(appointment.is_ubuntu_alarm() || calendar_bubbles_enabled());
+ b.set_post_to_messaging_menu(appointment.is_ubuntu_alarm() || calendar_list_enabled());
+
const auto key = m_engine->show(b);
if (key)
m_notifications.insert (key);