aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/settings-live.cpp38
-rw-r--r--src/snap.cpp20
2 files changed, 49 insertions, 9 deletions
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index 01de7b8..66590e0 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -34,14 +34,19 @@ namespace datetime {
LiveSettings::~LiveSettings()
{
+ g_clear_object(&m_settings_general_notification);
g_clear_object(&m_settings_cal_notification);
g_clear_object(&m_settings);
}
-LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_settings_cal_notification(g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH))
+LiveSettings::LiveSettings():
+ m_settings(g_settings_new(SETTINGS_INTERFACE)),
+ m_settings_cal_notification(g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH)),
+ m_settings_general_notification(g_settings_new(SETTINGS_NOTIFY_APPS_SCHEMA_ID))
{
- g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this);
- g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this);
+ g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this);
+ g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this);
+ g_signal_connect (m_settings_general_notification, "changed", G_CALLBACK(on_changed_general_notification), this);
// init the Properties from the GSettings backend
update_custom_time_format();
@@ -68,6 +73,7 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_
update_cal_notification_vibrations();
update_cal_notification_bubbles();
update_cal_notification_list();
+ update_vibrate_silent_mode();
// now listen for clients to change the properties s.t. we can sync update GSettings
@@ -171,6 +177,10 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_
cal_notification_list.changed().connect([this](bool value){
g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY, value);
});
+
+ vibrate_silent_mode.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_general_notification, SETTINGS_VIBRATE_SILENT_KEY, value);
+ });
}
/***
@@ -317,6 +327,11 @@ void LiveSettings::update_cal_notification_list()
cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY));
}
+void LiveSettings::update_vibrate_silent_mode()
+{
+ vibrate_silent_mode.set(g_settings_get_boolean(m_settings_general_notification, SETTINGS_VIBRATE_SILENT_KEY));
+}
+
/***
****
***/
@@ -347,6 +362,23 @@ void LiveSettings::update_key_cal_notification(const std::string& key)
****
***/
+void LiveSettings::on_changed_general_notification(GSettings* /*settings*/,
+ gchar* key,
+ gpointer gself)
+{
+ static_cast<LiveSettings*>(gself)->update_key_general_notification(key);
+}
+
+void LiveSettings::update_key_general_notification(const std::string& key)
+{
+ if (key == SETTINGS_VIBRATE_SILENT_KEY)
+ update_vibrate_silent_mode();
+}
+
+/***
+****
+***/
+
void LiveSettings::on_changed_ccid(GSettings* /*settings*/,
gchar* key,
gpointer gself)
diff --git a/src/snap.cpp b/src/snap.cpp
index d0c12a0..363e0df 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -97,9 +97,9 @@ public:
// 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());
- }
+ if (appointment.is_ubuntu_alarm() || calendar_bubbles_enabled() || calendar_list_enabled()) {
+ 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;
@@ -115,9 +115,12 @@ public:
// create the haptic feedback...
std::shared_ptr<ain::Haptic> haptic;
if (should_vibrate() && (appointment.is_ubuntu_alarm() || calendar_vibrations_enabled())) {
- const auto haptic_mode = m_settings->alarm_haptic.get();
- if (haptic_mode == "pulse")
- haptic = std::make_shared<ain::Haptic>(ain::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm());
+ // when in silent mode should only vibrate if user defined so
+ if (!silent_mode() || vibrate_in_silent_mode_enabled()) {
+ const auto haptic_mode = m_settings->alarm_haptic.get();
+ if (haptic_mode == "pulse")
+ haptic = std::make_shared<ain::Haptic>(ain::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm());
+ }
}
// show a notification...
@@ -218,6 +221,11 @@ private:
return m_settings->cal_notification_list.get();
}
+ bool vibrate_in_silent_mode_enabled() const
+ {
+ return m_settings->vibrate_silent_mode.get();
+ }
+
static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself)
{
GError * error;