aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/com.canonical.indicator.datetime.gschema.xml8
-rw-r--r--include/datetime/settings-live.h1
-rw-r--r--include/datetime/settings-shared.h1
-rw-r--r--include/datetime/settings.h1
-rw-r--r--src/settings-live.cpp12
-rw-r--r--tests/test-settings.cpp7
6 files changed, 28 insertions, 2 deletions
diff --git a/data/com.canonical.indicator.datetime.gschema.xml b/data/com.canonical.indicator.datetime.gschema.xml
index 7e74a63..3e0082d 100644
--- a/data/com.canonical.indicator.datetime.gschema.xml
+++ b/data/com.canonical.indicator.datetime.gschema.xml
@@ -144,5 +144,13 @@
The volume at which alarms will be played.
</description>
</key>
+ <key name="alarm-duration-minutes" type="i">
+ <range min="1" max="60"/>
+ <default>30</default>
+ <summary>The alarm's duration.</summary>
+ <description>
+ How long the alarm's sound will be looped if its snap decision is not dismissed by the user.
+ </description>
+ </key>
</schema>
</schemalist>
diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h
index a075a85..4db2d40 100644
--- a/include/datetime/settings-live.h
+++ b/include/datetime/settings-live.h
@@ -57,6 +57,7 @@ private:
void update_timezone_name();
void update_alarm_sound();
void update_alarm_volume();
+ void update_alarm_duration();
GSettings* m_settings;
diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h
index b8d7737..bfddd88 100644
--- a/include/datetime/settings-shared.h
+++ b/include/datetime/settings-shared.h
@@ -57,5 +57,6 @@ AlarmVolume;
#define SETTINGS_TIMEZONE_NAME_S "timezone-name"
#define SETTINGS_ALARM_SOUND_S "alarm-default-sound"
#define SETTINGS_ALARM_VOLUME_S "alarm-default-volume"
+#define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes"
#endif // INDICATOR_DATETIME_SETTINGS_SHARED
diff --git a/include/datetime/settings.h b/include/datetime/settings.h
index 5a0f1eb..a941f05 100644
--- a/include/datetime/settings.h
+++ b/include/datetime/settings.h
@@ -58,6 +58,7 @@ public:
core::Property<std::string> timezone_name;
core::Property<std::string> alarm_sound;
core::Property<AlarmVolume> alarm_volume;
+ core::Property<int> alarm_duration;
};
} // namespace datetime
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index ec78feb..e34ace1 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -54,6 +54,7 @@ LiveSettings::LiveSettings():
update_timezone_name();
update_alarm_sound();
update_alarm_volume();
+ update_alarm_duration();
// now listen for clients to change the properties s.t. we can sync update GSettings
@@ -125,6 +126,10 @@ LiveSettings::LiveSettings():
alarm_volume.changed().connect([this](AlarmVolume value){
g_settings_set_enum(m_settings, SETTINGS_ALARM_VOLUME_S, gint(value));
});
+
+ alarm_duration.changed().connect([this](int value){
+ g_settings_set_int(m_settings, SETTINGS_ALARM_DURATION_S, value);
+ });
}
/***
@@ -227,6 +232,11 @@ void LiveSettings::update_alarm_volume()
alarm_volume.set((AlarmVolume)g_settings_get_enum(m_settings, SETTINGS_ALARM_VOLUME_S));
}
+void LiveSettings::update_alarm_duration()
+{
+ alarm_duration.set(g_settings_get_int(m_settings, SETTINGS_ALARM_DURATION_S));
+}
+
/***
****
***/
@@ -272,6 +282,8 @@ void LiveSettings::update_key(const std::string& key)
update_alarm_sound();
else if (key == SETTINGS_ALARM_VOLUME_S)
update_alarm_volume();
+ else if (key == SETTINGS_ALARM_DURATION_S)
+ update_alarm_duration();
}
/***
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index 9af803f..2b500b2 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -101,7 +101,6 @@ protected:
g_clear_pointer(&tmp, g_free);
}
-#if 0
void TestIntProperty(core::Property<int>& property, const gchar* key)
{
EXPECT_EQ(g_settings_get_int(m_gsettings, key), property.get());
@@ -124,7 +123,6 @@ protected:
EXPECT_EQ(expected_value, g_settings_get_int(m_gsettings, key));
}
}
-#endif
};
/***
@@ -150,6 +148,11 @@ TEST_F(SettingsFixture, BoolProperties)
TestBoolProperty(m_settings->show_year, SETTINGS_SHOW_YEAR_S);
}
+TEST_F(SettingsFixture, IntProperties)
+{
+ TestIntProperty(m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S);
+}
+
TEST_F(SettingsFixture, StringProperties)
{
TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S);