aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArthur Mello <arthur.mello@canonical.com>2016-06-22 15:37:55 -0300
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:39 +0200
commit525a38eb600292ffb764f6b5de058f9ba6ddd2b8 (patch)
tree88dddd234ee3001af546a7e45adccd3c93305c1e /src
parent413b0e90af889a17b7ddbd3ce4709f9b736d6a21 (diff)
downloadayatana-indicator-datetime-525a38eb600292ffb764f6b5de058f9ba6ddd2b8.tar.gz
ayatana-indicator-datetime-525a38eb600292ffb764f6b5de058f9ba6ddd2b8.tar.bz2
ayatana-indicator-datetime-525a38eb600292ffb764f6b5de058f9ba6ddd2b8.zip
Update indicator-datetime to work with the new notification settings
Diffstat (limited to 'src')
-rw-r--r--src/settings-live.cpp115
-rw-r--r--src/snap.cpp45
2 files changed, 99 insertions, 61 deletions
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index 6504d7d..f908c05 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -34,7 +34,7 @@ namespace datetime {
LiveSettings::~LiveSettings()
{
- g_clear_object(&m_settings_cunh);
+ g_clear_object(&m_settings_cal_notification);
g_clear_object(&m_settings);
}
@@ -44,8 +44,8 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
if (ayatana_common_utils_is_lomiri())
{
- m_settings_cunh = g_settings_new(SETTINGS_CUNH_SCHEMA_ID);
- g_signal_connect (m_settings_cunh, "changed", G_CALLBACK(on_changed_cunh), this);
+ m_settings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
+ g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this);
}
// init the Properties from the GSettings backend
@@ -68,7 +68,11 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
update_alarm_duration();
update_alarm_haptic();
update_snooze_duration();
- update_muted_apps();
+ update_cal_notification_enabled();
+ update_cal_notification_sounds();
+ update_cal_notification_vibrations();
+ update_cal_notification_bubbles();
+ update_cal_notification_list();
// now listen for clients to change the properties s.t. we can sync update GSettings
@@ -76,20 +80,6 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
g_settings_set_string(m_settings, SETTINGS_CUSTOM_TIME_FORMAT_S, value.c_str());
});
- if (ayatana_common_utils_is_lomiri())
- {
- muted_apps.changed().connect([this](const std::set<std::pair<std::string,std::string>>& value){
- GVariantBuilder builder;
- g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ss)"));
- for(const auto& app : value){
- const std::string& pkgname {app.first};
- const std::string& appname {app.second};
- g_variant_builder_add(&builder, "(ss)", pkgname.c_str(), appname.c_str());
- }
- g_settings_set_value(m_settings_cunh, SETTINGS_CUNH_BLACKLIST_S, g_variant_builder_end(&builder));
- });
- }
-
locations.changed().connect([this](const std::vector<std::string>& value){
const int n = value.size();
gchar** strv = g_new0(gchar*, n+1);
@@ -166,6 +156,26 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
snooze_duration.changed().connect([this](unsigned int value){
g_settings_set_uint(m_settings, SETTINGS_SNOOZE_DURATION_S, value);
});
+
+ cal_notification_enabled.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY, value);
+ });
+
+ cal_notification_sounds.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY, value);
+ });
+
+ cal_notification_vibrations.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY, value);
+ });
+
+ cal_notification_bubbles.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY, value);
+ });
+
+ cal_notification_list.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY, value);
+ });
}
/***
@@ -189,27 +199,6 @@ void LiveSettings::update_locations()
locations.set(l);
}
-void LiveSettings::update_muted_apps()
-{
- if (ayatana_common_utils_is_lomiri())
- {
- std::set<std::pair<std::string,std::string>> apps;
-
- auto blacklist = g_settings_get_value(m_settings_cunh, SETTINGS_CUNH_BLACKLIST_S);
- GVariantIter* iter {nullptr};
- g_variant_get (blacklist, "a(ss)", &iter);
- gchar* pkgname;
- gchar* appname;
- while (g_variant_iter_loop (iter, "(ss)", &pkgname, &appname)) {
- apps.insert(std::make_pair(pkgname,appname));
- }
- g_variant_iter_free (iter);
- g_clear_pointer(&blacklist, g_variant_unref);
-
- muted_apps.set(apps);
- }
-}
-
void LiveSettings::update_show_calendar()
{
const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_CALENDAR_S);
@@ -308,21 +297,55 @@ void LiveSettings::update_snooze_duration()
snooze_duration.set(g_settings_get_uint(m_settings, SETTINGS_SNOOZE_DURATION_S));
}
+void LiveSettings::update_cal_notification_enabled()
+{
+ cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY));
+}
+
+void LiveSettings::update_cal_notification_sounds()
+{
+ cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY));
+}
+
+void LiveSettings::update_cal_notification_vibrations()
+{
+ cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY));
+}
+
+void LiveSettings::update_cal_notification_bubbles()
+{
+ cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY));
+}
+
+void LiveSettings::update_cal_notification_list()
+{
+ cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY));
+}
+
/***
****
***/
-void LiveSettings::on_changed_cunh(GSettings* /*settings*/,
- gchar* key,
- gpointer gself)
+void LiveSettings::on_changed_cal_notification(GSettings* /*settings*/,
+ gchar* key,
+ gpointer gself)
{
- static_cast<LiveSettings*>(gself)->update_key_cunh(key);
+ static_cast<LiveSettings*>(gself)->update_key_cal_notification(key);
}
-void LiveSettings::update_key_cunh(const std::string& key)
+
+void LiveSettings::update_key_cal_notification(const std::string& key)
{
- if (key == SETTINGS_CUNH_BLACKLIST_S)
- update_muted_apps();
+ if (key == SETTINGS_NOTIFY_ENABLED_KEY)
+ update_cal_notification_enabled();
+ else if (key == SETTINGS_NOTIFY_SOUNDS_KEY)
+ update_cal_notification_sounds();
+ else if (key == SETTINGS_NOTIFY_VIBRATIONS_KEY)
+ update_cal_notification_vibrations();
+ else if (key == SETTINGS_NOTIFY_BUBBLES_KEY)
+ update_cal_notification_bubbles();
+ else if (key == SETTINGS_NOTIFY_LIST_KEY)
+ update_cal_notification_list();
}
/***
diff --git a/src/snap.cpp b/src/snap.cpp
index 51d04ae..1e71e7b 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -83,9 +83,9 @@ public:
const Alarm& alarm,
response_func on_response)
{
- // 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());
+ // If calendar notifications are disabled, don't show them
+ if (!appointment.is_ubuntu_alarm() && !calendar_notifications_are_enabled()) {
+ g_debug("Skipping disabled calendar event '%s' notification", appointment.summary.c_str());
return;
}
@@ -96,13 +96,14 @@ public:
const bool interactive = appointment.is_ubuntu_alarm() && m_engine->supports_actions();
// force the system to stay awake
- auto awake = std::make_shared<ain::Awake>(m_engine->app_name());
+ std::shared_ptr<ain::Awake> awake;
+ if (calendar_bubbles_enabled()) {
+ awake = std::make_shared<uin::Awake>(m_engine->app_name());
+ }
// calendar events are muted in silent mode; alarm clocks never are
std::shared_ptr<ain::Sound> sound;
- // FIXME: only play sounds for alarms for now, we should itegrate it with
- // system settings to decide if we should play sounds for calendar notification or not
- if (appointment.is_ubuntu_alarm()) {
+ if (appointment.is_ubuntu_alarm() || calendar_sounds_enabled()) {
// create the sound.
const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";
const auto uri = get_alarm_uri(appointment, alarm, m_settings);
@@ -113,7 +114,7 @@ public:
// create the haptic feedback...
std::shared_ptr<ain::Haptic> haptic;
- if (should_vibrate()) {
+ if (should_vibrate() && 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());
@@ -189,15 +190,29 @@ public:
private:
- bool calendar_events_are_muted() const
+ bool calendar_notifications_are_enabled() const
{
- for(const auto& app : m_settings->muted_apps.get()) {
- if (app.first == "com.ubuntu.calendar") {
- return true;
- }
- }
+ return m_settings->cal_notification_enabled.get();
+ }
+
+ bool calendar_sounds_enabled() const
+ {
+ return m_settings->cal_notification_sounds.get();
+ }
- return false;
+ bool calendar_vibrations_enabled() const
+ {
+ return m_settings->cal_notification_vibrations.get();
+ }
+
+ bool calendar_bubbles_enabled() const
+ {
+ return m_settings->cal_notification_bubbles.get();
+ }
+
+ bool calendar_list_enabled() const
+ {
+ return m_settings->cal_notification_list.get();
}
static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself)