aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/settings-live.cpp14
-rw-r--r--src/snap.cpp18
2 files changed, 24 insertions, 8 deletions
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index 3475d5e..206b762 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -52,6 +52,7 @@ LiveSettings::LiveSettings():
update_show_year();
update_time_format_mode();
update_timezone_name();
+ update_calendar_sound();
update_alarm_sound();
update_alarm_volume();
update_alarm_duration();
@@ -121,6 +122,10 @@ LiveSettings::LiveSettings():
g_settings_set_string(m_settings, SETTINGS_TIMEZONE_NAME_S, value.c_str());
});
+ calendar_sound.changed().connect([this](const std::string& value){
+ g_settings_set_string(m_settings, SETTINGS_CALENDAR_SOUND_S, value.c_str());
+ });
+
alarm_sound.changed().connect([this](const std::string& value){
g_settings_set_string(m_settings, SETTINGS_ALARM_SOUND_S, value.c_str());
});
@@ -230,6 +235,13 @@ void LiveSettings::update_timezone_name()
g_free(val);
}
+void LiveSettings::update_calendar_sound()
+{
+ auto val = g_settings_get_string(m_settings, SETTINGS_CALENDAR_SOUND_S);
+ calendar_sound.set(val);
+ g_free(val);
+}
+
void LiveSettings::update_alarm_sound()
{
auto val = g_settings_get_string(m_settings, SETTINGS_ALARM_SOUND_S);
@@ -300,6 +312,8 @@ void LiveSettings::update_key(const std::string& key)
update_show_detected_locations();
else if (key == SETTINGS_TIMEZONE_NAME_S)
update_timezone_name();
+ else if (key == SETTINGS_CALENDAR_SOUND_S)
+ update_calendar_sound();
else if (key == SETTINGS_ALARM_SOUND_S)
update_alarm_sound();
else if (key == SETTINGS_ALARM_VOLUME_S)
diff --git a/src/snap.cpp b/src/snap.cpp
index 326e676..f0300af 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -98,8 +98,7 @@ public:
if (appointment.is_ubuntu_alarm() || !silent_mode()) {
// create the sound.
const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";
- const auto default_sound = appointment.is_ubuntu_alarm() ? ALARM_DEFAULT_SOUND : CALENDAR_DEFAULT_SOUND;
- const auto uri = get_alarm_uri(alarm, m_settings, default_sound);
+ const auto uri = get_alarm_uri(appointment, alarm, m_settings);
const auto volume = m_settings->alarm_volume.get();
const bool loop = interactive;
sound = std::make_shared<ain::Sound>(role, uri, volume, loop);
@@ -191,13 +190,16 @@ private:
&& (accounts_service_sound_get_other_vibrate(m_accounts_service_sound_proxy));
}
- std::string get_alarm_uri(const Alarm& alarm,
- const std::shared_ptr<const Settings>& settings,
- const std::string& default_sound ) const
+ std::string get_alarm_uri(const Appointment& appointment,
+ const Alarm& alarm,
+ const std::shared_ptr<const Settings>& settings) const
{
- const std::string candidates[] = { alarm.audio_url,
- settings->alarm_sound.get(),
- default_sound };
+ const auto is_alarm = appointment.is_ubuntu_alarm();
+ const std::string candidates[] = {
+ alarm.audio_url,
+ is_alarm ? settings->alarm_sound.get() : settings->calendar_sound.get(),
+ is_alarm ? ALARM_DEFAULT_SOUND : CALENDAR_DEFAULT_SOUND
+ };
std::string uri;