Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide volume setting for Calendar reminder alert #132

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/org.ayatana.indicator.datetime.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
If a calendar or reminder event doesn't specify its own sound file, this file will be used as the fallback sound.
</description>
</key>
<key name="calendar-default-volume" type="u">
<range min="1" max="100"/>
<default>50</default>
<summary>The calendar's reminder alert default volume level.</summary>
<description>
The volume at which calendar reminder alert will be played.
</description>
</key>
<key name="alarm-default-sound" type="s">
<default>'@ALARM_DEFAULT_SOUND@'</default>
<summary>The alarm's default sound file.</summary>
Expand Down
1 change: 1 addition & 0 deletions include/datetime/settings-live.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class LiveSettings: public Settings
void update_time_format_mode();
void update_timezone_name();
void update_calendar_sound();
void update_calendar_volume();
void update_alarm_sound();
void update_alarm_volume();
void update_alarm_duration();
Expand Down
1 change: 1 addition & 0 deletions include/datetime/settings-shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ TimeFormatMode;
#define SETTINGS_LOCATIONS_S "locations"
#define SETTINGS_TIMEZONE_NAME_S "timezone-name"
#define SETTINGS_CALENDAR_SOUND_S "calendar-default-sound"
#define SETTINGS_CALENDAR_VOLUME_S "calendar-default-volume"
#define SETTINGS_ALARM_SOUND_S "alarm-default-sound"
#define SETTINGS_ALARM_VOLUME_S "alarm-default-volume"
#define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes"
Expand Down
1 change: 1 addition & 0 deletions include/datetime/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Settings
core::Property<TimeFormatMode> time_format_mode;
core::Property<std::string> timezone_name;
core::Property<std::string> calendar_sound;
core::Property<unsigned int> calendar_volume;
core::Property<std::string> alarm_sound;
core::Property<std::string> alarm_haptic;
core::Property<unsigned int> alarm_volume;
Expand Down
12 changes: 12 additions & 0 deletions src/settings-live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ LiveSettings::LiveSettings():
update_time_format_mode();
update_timezone_name();
update_calendar_sound();
update_calendar_volume();
update_alarm_sound();
update_alarm_volume();
update_alarm_duration();
Expand Down Expand Up @@ -150,6 +151,10 @@ LiveSettings::LiveSettings():
g_settings_set_string(m_settings, SETTINGS_CALENDAR_SOUND_S, value.c_str());
});

calendar_volume.changed().connect([this](unsigned int value){
g_settings_set_uint(m_settings, SETTINGS_CALENDAR_VOLUME_S, value);
});

alarm_sound.changed().connect([this](const std::string& value){
g_settings_set_string(m_settings, SETTINGS_ALARM_SOUND_S, value.c_str());
});
Expand Down Expand Up @@ -291,6 +296,11 @@ void LiveSettings::update_calendar_sound()
g_free(val);
}

void LiveSettings::update_calendar_volume()
{
calendar_volume.set(g_settings_get_uint(m_settings, SETTINGS_CALENDAR_VOLUME_S));
}

void LiveSettings::update_alarm_sound()
{
auto val = g_settings_get_string(m_settings, SETTINGS_ALARM_SOUND_S);
Expand Down Expand Up @@ -436,6 +446,8 @@ void LiveSettings::update_key_ccid(const std::string& key)
update_timezone_name();
else if (key == SETTINGS_CALENDAR_SOUND_S)
update_calendar_sound();
else if (key == SETTINGS_CALENDAR_VOLUME_S)
update_calendar_volume();
else if (key == SETTINGS_ALARM_SOUND_S)
update_alarm_sound();
else if (key == SETTINGS_ALARM_VOLUME_S)
Expand Down
2 changes: 1 addition & 1 deletion src/snap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Snap::Impl
// create the sound.
const auto role = appointment.is_alarm() ? "alarm" : "alert";
const auto uri = get_alarm_uri(appointment, alarm, m_settings);
const auto volume = m_settings->alarm_volume.get();
const auto volume = appointment.is_alarm() ? m_settings->alarm_volume.get() : m_settings->calendar_volume.get();
const bool loop = interactive;
sound = m_sound_builder->create(role, uri, volume, loop);
}
Expand Down
1 change: 1 addition & 0 deletions tests/test-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ TEST_F(SettingsFixture, StringProperties)
TestStringProperty(m_gsettings, m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S);
TestStringProperty(m_gsettings, m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S);
TestStringProperty(m_gsettings, m_settings->calendar_sound, SETTINGS_CALENDAR_SOUND_S);
TestStringProperty(m_gsettings, m_settings->calendar_volume, SETTINGS_CALENDAR_VOLUME_S);
TestStringProperty(m_gsettings, m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S);
}

Expand Down