From fee2f8fdbe5a851643bed55decb14e1cff84cb8a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 1 Feb 2016 18:07:18 -0600 Subject: in LiveSettings, add gschema support for notification app blacklisting --- src/settings-live.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 8 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 5c2addb..e63bcbe 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -19,6 +19,11 @@ #include +extern "C" +{ + #include +} + namespace ayatana { namespace indicator { namespace datetime { @@ -29,13 +34,19 @@ namespace datetime { LiveSettings::~LiveSettings() { + g_clear_object(&m_settings_cunh); g_clear_object(&m_settings); } -LiveSettings::LiveSettings(): - m_settings(g_settings_new(SETTINGS_INTERFACE)) +LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)) { - g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed), this); + g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this); + + 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); + } // init the Properties from the GSettings backend update_custom_time_format(); @@ -57,6 +68,7 @@ LiveSettings::LiveSettings(): update_alarm_duration(); update_alarm_haptic(); update_snooze_duration(); + update_muted_apps(); // now listen for clients to change the properties s.t. we can sync update GSettings @@ -64,6 +76,20 @@ LiveSettings::LiveSettings(): 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>& value){ + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ss)")); + for(const auto& app : value){ + const auto& pkgname {app.first}; + const auto& 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& value){ const int n = value.size(); gchar** strv = g_new0(gchar*, n+1); @@ -163,6 +189,27 @@ void LiveSettings::update_locations() locations.set(l); } +void LiveSettings::update_muted_apps() +{ + if (ayatana_common_utils_is_lomiri()) + { + std::set> 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); @@ -265,14 +312,31 @@ void LiveSettings::update_snooze_duration() **** ***/ -void LiveSettings::on_changed(GSettings* /*settings*/, - gchar* key, - gpointer gself) +void LiveSettings::on_changed_cunh(GSettings* /*settings*/, + gchar* key, + gpointer gself) +{ + static_cast(gself)->update_key_cunh(key); +} + +void LiveSettings::update_key_cunh(const std::string& key) +{ + if (key == SETTINGS_CUNH_BLACKLIST_S) + update_muted_apps(); +} + +/*** +**** +***/ + +void LiveSettings::on_changed_ccid(GSettings* /*settings*/, + gchar* key, + gpointer gself) { - static_cast(gself)->update_key(key); + static_cast(gself)->update_key_ccid(key); } -void LiveSettings::update_key(const std::string& key) +void LiveSettings::update_key_ccid(const std::string& key) { if (key == SETTINGS_LOCATIONS_S) update_locations(); -- cgit v1.2.3 From 295b91b74cfb0226b01c6f47467a3af1a626cd6a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 3 Feb 2016 14:25:19 -0600 Subject: in settings-live.cpp, use std::string instead of auto to make g++ 4.9.2 happy on vivid --- src/settings-live.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index e63bcbe..6504d7d 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -82,8 +82,8 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)) GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ss)")); for(const auto& app : value){ - const auto& pkgname {app.first}; - const auto& appname {app.second}; + 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)); -- cgit v1.2.3 From 525a38eb600292ffb764f6b5de058f9ba6ddd2b8 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Wed, 22 Jun 2016 15:37:55 -0300 Subject: Update indicator-datetime to work with the new notification settings --- src/settings-live.cpp | 115 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 46 deletions(-) (limited to 'src/settings-live.cpp') 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>& 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& 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> 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(gself)->update_key_cunh(key); + static_cast(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(); } /*** -- cgit v1.2.3 From f3f17677a2718fb47cda50cd6c64c9650448ea2e Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Thu, 23 Jun 2016 16:04:50 -0300 Subject: Set calendar notification settings to true in case GSettings schema is not available Make sure calendar notification settings are correct during tests --- src/settings-live.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index f908c05..39d8e18 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -299,27 +299,47 @@ void LiveSettings::update_snooze_duration() void LiveSettings::update_cal_notification_enabled() { - cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY)); + if (m_settings_cal_notification) { + cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY)); + } else { + cal_notification_enabled.set(true); + } } void LiveSettings::update_cal_notification_sounds() { - cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY)); + if (m_settings_cal_notification) { + cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY)); + } else { + cal_notification_sounds.set(true); + } } void LiveSettings::update_cal_notification_vibrations() { - cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY)); + if (m_settings_cal_notification) { + cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY)); + } else { + cal_notification_vibrations.set(true); + } } void LiveSettings::update_cal_notification_bubbles() { - cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY)); + if (m_settings_cal_notification) { + cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY)); + } else { + cal_notification_bubbles.set(true); + } } void LiveSettings::update_cal_notification_list() { - cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY)); + if (m_settings_cal_notification) { + cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY)); + } else { + cal_notification_list.set(true); + } } /*** -- cgit v1.2.3 From c5c092a25f41e3cfb8dc3b3578c5c40ecd6c0dd7 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Fri, 24 Jun 2016 11:45:30 -0300 Subject: Do not fail tests if schema is not installed --- src/settings-live.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 39d8e18..17c0ef7 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -38,14 +38,20 @@ LiveSettings::~LiveSettings() g_clear_object(&m_settings); } -LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)) +LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_gsettings_cal_notification(NULL) { g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this); if (ayatana_common_utils_is_lomiri()) { - 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); + GSettingsSchemaSource *source = g_settings_schema_source_get_default(); + if (g_settings_schema_source_lookup(source, SETTINGS_NOTIFY_SCHEMA_ID, true)) { + m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH); + } + + if (m_gsettings_cal_notification) { + g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this); + } } // init the Properties from the GSettings backend -- cgit v1.2.3 From 8ad06a88b53bcd0ac5d457a25f1161640da1d6bb Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Fri, 24 Jun 2016 11:49:11 -0300 Subject: Fix typo --- src/settings-live.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 17c0ef7..d1ea91b 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -38,7 +38,7 @@ LiveSettings::~LiveSettings() g_clear_object(&m_settings); } -LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_gsettings_cal_notification(NULL) +LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_settings_cal_notification(NULL) { g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this); @@ -46,10 +46,10 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_ { GSettingsSchemaSource *source = g_settings_schema_source_get_default(); if (g_settings_schema_source_lookup(source, SETTINGS_NOTIFY_SCHEMA_ID, true)) { - m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH); + m_settings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH); } - if (m_gsettings_cal_notification) { + if (m_settings_cal_notification) { g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this); } } -- cgit v1.2.3 From ff4a63eb5d7c9528d2cf204a2be3d28ec084b734 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Fri, 24 Jun 2016 16:55:50 -0300 Subject: Fix settings test check so we do not fail if GSettings schema is missing --- src/settings-live.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index d1ea91b..8060a08 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -305,7 +305,7 @@ void LiveSettings::update_snooze_duration() void LiveSettings::update_cal_notification_enabled() { - if (m_settings_cal_notification) { + if (m_settings_cal_notification != NULL) { cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY)); } else { cal_notification_enabled.set(true); @@ -314,7 +314,7 @@ void LiveSettings::update_cal_notification_enabled() void LiveSettings::update_cal_notification_sounds() { - if (m_settings_cal_notification) { + if (m_settings_cal_notification != NULL) { cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY)); } else { cal_notification_sounds.set(true); @@ -323,7 +323,7 @@ void LiveSettings::update_cal_notification_sounds() void LiveSettings::update_cal_notification_vibrations() { - if (m_settings_cal_notification) { + if (m_settings_cal_notification != NULL) { cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY)); } else { cal_notification_vibrations.set(true); @@ -332,7 +332,7 @@ void LiveSettings::update_cal_notification_vibrations() void LiveSettings::update_cal_notification_bubbles() { - if (m_settings_cal_notification) { + if (m_settings_cal_notification != NULL) { cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY)); } else { cal_notification_bubbles.set(true); @@ -341,7 +341,7 @@ void LiveSettings::update_cal_notification_bubbles() void LiveSettings::update_cal_notification_list() { - if (m_settings_cal_notification) { + if (m_settings_cal_notification != NULL) { cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY)); } else { cal_notification_list.set(true); -- cgit v1.2.3 From c12e9b28189aa11a28ca883cc4d5ecb4da57db7c Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Wed, 29 Jun 2016 21:31:01 -0300 Subject: Undo revisions 456/457 --- src/settings-live.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 8060a08..d1ea91b 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -305,7 +305,7 @@ void LiveSettings::update_snooze_duration() void LiveSettings::update_cal_notification_enabled() { - if (m_settings_cal_notification != NULL) { + if (m_settings_cal_notification) { cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY)); } else { cal_notification_enabled.set(true); @@ -314,7 +314,7 @@ void LiveSettings::update_cal_notification_enabled() void LiveSettings::update_cal_notification_sounds() { - if (m_settings_cal_notification != NULL) { + if (m_settings_cal_notification) { cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY)); } else { cal_notification_sounds.set(true); @@ -323,7 +323,7 @@ void LiveSettings::update_cal_notification_sounds() void LiveSettings::update_cal_notification_vibrations() { - if (m_settings_cal_notification != NULL) { + if (m_settings_cal_notification) { cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY)); } else { cal_notification_vibrations.set(true); @@ -332,7 +332,7 @@ void LiveSettings::update_cal_notification_vibrations() void LiveSettings::update_cal_notification_bubbles() { - if (m_settings_cal_notification != NULL) { + if (m_settings_cal_notification) { cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY)); } else { cal_notification_bubbles.set(true); @@ -341,7 +341,7 @@ void LiveSettings::update_cal_notification_bubbles() void LiveSettings::update_cal_notification_list() { - if (m_settings_cal_notification != NULL) { + if (m_settings_cal_notification) { cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY)); } else { cal_notification_list.set(true); -- cgit v1.2.3 From 8b5aee0a3ab3724481b8692faebe48d150c23e1b Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Fri, 1 Jul 2016 16:35:21 -0300 Subject: Do not fail gracefully if gsettings schema is not installed --- src/settings-live.cpp | 45 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index d1ea91b..01de7b8 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -38,21 +38,10 @@ LiveSettings::~LiveSettings() g_clear_object(&m_settings); } -LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_settings_cal_notification(NULL) +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)) { g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this); - - if (ayatana_common_utils_is_lomiri()) - { - GSettingsSchemaSource *source = g_settings_schema_source_get_default(); - if (g_settings_schema_source_lookup(source, SETTINGS_NOTIFY_SCHEMA_ID, true)) { - m_settings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH); - } - - if (m_settings_cal_notification) { - g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this); - } - } + g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this); // init the Properties from the GSettings backend update_custom_time_format(); @@ -305,47 +294,27 @@ void LiveSettings::update_snooze_duration() void LiveSettings::update_cal_notification_enabled() { - if (m_settings_cal_notification) { - cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY)); - } else { - cal_notification_enabled.set(true); - } + cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY)); } void LiveSettings::update_cal_notification_sounds() { - if (m_settings_cal_notification) { - cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY)); - } else { - cal_notification_sounds.set(true); - } + cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY)); } void LiveSettings::update_cal_notification_vibrations() { - if (m_settings_cal_notification) { - cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY)); - } else { - cal_notification_vibrations.set(true); - } + cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY)); } void LiveSettings::update_cal_notification_bubbles() { - if (m_settings_cal_notification) { - cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY)); - } else { - cal_notification_bubbles.set(true); - } + cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY)); } void LiveSettings::update_cal_notification_list() { - if (m_settings_cal_notification) { - cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY)); - } else { - cal_notification_list.set(true); - } + cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY)); } /*** -- cgit v1.2.3 From cd03321181ba64c66a93c60d444dfea59f293fa1 Mon Sep 17 00:00:00 2001 From: Arthur Mello Date: Mon, 4 Jul 2016 16:30:18 -0300 Subject: If in silent mode should only vibrate if the settings say so --- src/settings-live.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/settings-live.cpp') 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(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) -- cgit v1.2.3 From 5ab8ee23903ec5a1eb1779164d65cb944195dc76 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 6 Oct 2016 12:39:49 -0500 Subject: In main.cpp and tests where Snap is instantiated, provide the system_bus to Snap's constructor --- src/settings-live.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 66590e0..59c133f 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -40,13 +40,9 @@ LiveSettings::~LiveSettings() } 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)) + m_settings(g_settings_new(SETTINGS_INTERFACE)) { 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,12 +64,20 @@ LiveSettings::LiveSettings(): update_alarm_duration(); update_alarm_haptic(); update_snooze_duration(); - update_cal_notification_enabled(); - update_cal_notification_sounds(); - update_cal_notification_vibrations(); - update_cal_notification_bubbles(); - update_cal_notification_list(); - update_vibrate_silent_mode(); + + if (ayatana_common_utils_is_lomiri()) + { + 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_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); + update_cal_notification_enabled(); + update_cal_notification_sounds(); + 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 -- cgit v1.2.3 From 89201d7b7f2f68d7badd9e6966603ea94eda9051 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Thu, 15 Jul 2021 01:39:43 +0200 Subject: src/settings-live.cpp: initialise m_settings_cal_notification and m_settings_general_notification to NULL if we are not on Lomiri --- src/settings-live.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 59c133f..00caa74 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -78,6 +78,11 @@ LiveSettings::LiveSettings(): update_cal_notification_list(); update_vibrate_silent_mode(); } + else + { + m_settings_cal_notification = NULL; + m_settings_general_notification = NULL; + } // now listen for clients to change the properties s.t. we can sync update GSettings -- cgit v1.2.3 From 11f11fcf01b0add9ffb766ca7ea48eb9e27cbb0c Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sun, 29 Aug 2021 13:55:55 +0200 Subject: src/settings-live.cpp: White-space change, drop blanks in between parameters in function call. --- src/settings-live.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/settings-live.cpp') diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 00caa74..dc90d0e 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -42,7 +42,7 @@ LiveSettings::~LiveSettings() LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)) { - g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this); + g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this); // init the Properties from the GSettings backend update_custom_time_format(); -- cgit v1.2.3