diff options
-rw-r--r-- | data/com.canonical.indicator.datetime.AlarmProperties.xml | 8 | ||||
-rw-r--r-- | data/com.canonical.indicator.datetime.gschema.xml.in | 8 | ||||
-rw-r--r-- | include/datetime/settings-live.h | 1 | ||||
-rw-r--r-- | include/datetime/settings-shared.h | 1 | ||||
-rw-r--r-- | include/datetime/settings.h | 1 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/exporter.cpp | 1 | ||||
-rw-r--r-- | src/settings-live.cpp | 12 | ||||
-rw-r--r-- | tests/test-exporter.cpp | 11 | ||||
-rw-r--r-- | tests/test-settings.cpp | 1 |
10 files changed, 45 insertions, 1 deletions
diff --git a/data/com.canonical.indicator.datetime.AlarmProperties.xml b/data/com.canonical.indicator.datetime.AlarmProperties.xml index 9b38af9..7ba0e5e 100644 --- a/data/com.canonical.indicator.datetime.AlarmProperties.xml +++ b/data/com.canonical.indicator.datetime.AlarmProperties.xml @@ -36,5 +36,13 @@ </doc:doc> </property> + <property name="SnoozeDuration" type="i" access="readwrite"> + <doc:doc> + <doc:description> + <doc:para>How many minutes to wait when the Snooze button is pressed. [Range: 1-15]</doc:para> + </doc:description> + </doc:doc> + </property> + </interface> </node> diff --git a/data/com.canonical.indicator.datetime.gschema.xml.in b/data/com.canonical.indicator.datetime.gschema.xml.in index 4e4acd8..edcede2 100644 --- a/data/com.canonical.indicator.datetime.gschema.xml.in +++ b/data/com.canonical.indicator.datetime.gschema.xml.in @@ -154,5 +154,13 @@ How long the alarm's sound will be looped if its snap decision is not dismissed by the user. </_description> </key> + <key name="snooze-duration-minutes" type="u"> + <range min="1" max="20"/> + <default>5</default> + <_summary>The snooze duration.</_summary> + <_description> + How long to wait when the user hits the Snooze button. + </_description> + </key> </schema> </schemalist> diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h index 4850e69..bb4cd8d 100644 --- a/include/datetime/settings-live.h +++ b/include/datetime/settings-live.h @@ -59,6 +59,7 @@ private: void update_alarm_volume(); void update_alarm_duration(); void update_alarm_haptic(); + void update_snooze_duration(); GSettings* m_settings; diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h index a211821..c18cfaf 100644 --- a/include/datetime/settings-shared.h +++ b/include/datetime/settings-shared.h @@ -49,5 +49,6 @@ TimeFormatMode; #define SETTINGS_ALARM_VOLUME_S "alarm-default-volume" #define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes" #define SETTINGS_ALARM_HAPTIC_S "alarm-haptic-feedback" +#define SETTINGS_SNOOZE_DURATION_S "snooze-duration-minutes" #endif // INDICATOR_DATETIME_SETTINGS_SHARED diff --git a/include/datetime/settings.h b/include/datetime/settings.h index c6fe13b..0294f60 100644 --- a/include/datetime/settings.h +++ b/include/datetime/settings.h @@ -60,6 +60,7 @@ public: core::Property<std::string> alarm_haptic; core::Property<unsigned int> alarm_volume; core::Property<unsigned int> alarm_duration; + core::Property<unsigned int> snooze_duration; }; } // namespace datetime diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e583334..2852a75 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,8 @@ set (SERVICE_CXX_SOURCES locations-settings.cpp menu.cpp notifications.cpp + planner-aggregate.cpp + planner-snooze.cpp planner-month.cpp planner-range.cpp planner-upcoming.cpp diff --git a/src/exporter.cpp b/src/exporter.cpp index 1d45705..05b21eb 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -145,6 +145,7 @@ private: bind_uint_property(m_alarm_props, "default-volume", m_settings->alarm_volume); bind_string_property(m_alarm_props, "default-sound", m_settings->alarm_sound); bind_string_property(m_alarm_props, "haptic-feedback", m_settings->alarm_haptic); + bind_uint_property(m_alarm_props, "snooze-duration", m_settings->snooze_duration); } /*** diff --git a/src/settings-live.cpp b/src/settings-live.cpp index a8338ed..8ea06a4 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -56,6 +56,7 @@ LiveSettings::LiveSettings(): update_alarm_volume(); update_alarm_duration(); update_alarm_haptic(); + update_snooze_duration(); // now listen for clients to change the properties s.t. we can sync update GSettings @@ -135,6 +136,10 @@ LiveSettings::LiveSettings(): alarm_haptic.changed().connect([this](const std::string& value){ g_settings_set_string(m_settings, SETTINGS_ALARM_HAPTIC_S, value.c_str()); }); + + snooze_duration.changed().connect([this](unsigned int value){ + g_settings_set_uint(m_settings, SETTINGS_SNOOZE_DURATION_S, value); + }); } /*** @@ -249,6 +254,11 @@ void LiveSettings::update_alarm_haptic() g_free(val); } +void LiveSettings::update_snooze_duration() +{ + snooze_duration.set(g_settings_get_uint(m_settings, SETTINGS_SNOOZE_DURATION_S)); +} + /*** **** ***/ @@ -298,6 +308,8 @@ void LiveSettings::update_key(const std::string& key) update_alarm_duration(); else if (key == SETTINGS_ALARM_HAPTIC_S) update_alarm_haptic(); + else if (key == SETTINGS_SNOOZE_DURATION_S) + update_snooze_duration(); } /*** diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index 96665cf..ec19ef4 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -184,11 +184,13 @@ TEST_F(ExporterFixture, AlarmProperties) ***/ auto expected_volume = 1; - int expected_duration = 60; + int expected_duration = 4; + int expected_snooze_duration = 5; const char * expected_sound = "/tmp/foo.wav"; const char * expected_haptic = "pulse"; settings->alarm_volume.set(expected_volume); settings->alarm_duration.set(expected_duration); + settings->snooze_duration.set(expected_snooze_duration); settings->alarm_sound.set(expected_sound); settings->alarm_haptic.set(expected_haptic); wait_msec(); @@ -197,20 +199,24 @@ TEST_F(ExporterFixture, AlarmProperties) static constexpr const char* const VOLUME_PROP {"default-volume"}; static constexpr const char* const DURATION_PROP {"duration"}; static constexpr const char* const HAPTIC_PROP {"haptic-feedback"}; + static constexpr const char* const SNOOZE_PROP {"snooze-duration"}; char* sound = nullptr; char* haptic = nullptr; int volume = -1; int duration = -1; + int snooze = -1; g_object_get(proxy, SOUND_PROP, &sound, HAPTIC_PROP, &haptic, VOLUME_PROP, &volume, DURATION_PROP, &duration, + SNOOZE_PROP, &snooze, nullptr); EXPECT_STREQ(expected_sound, sound); EXPECT_STREQ(expected_haptic, haptic); EXPECT_EQ(expected_volume, volume); EXPECT_EQ(expected_duration, duration); + EXPECT_EQ(expected_snooze_duration, snooze); g_clear_pointer (&sound, g_free); g_clear_pointer (&haptic, g_free); @@ -223,10 +229,12 @@ TEST_F(ExporterFixture, AlarmProperties) expected_duration = 30; expected_sound = "/tmp/bar.wav"; expected_haptic = "none"; + expected_snooze_duration = 5; g_object_set(proxy, SOUND_PROP, expected_sound, HAPTIC_PROP, expected_haptic, VOLUME_PROP, expected_volume, DURATION_PROP, expected_duration, + SNOOZE_PROP, expected_snooze_duration, nullptr); wait_msec(); @@ -234,6 +242,7 @@ TEST_F(ExporterFixture, AlarmProperties) EXPECT_STREQ(expected_haptic, settings->alarm_haptic.get().c_str()); EXPECT_EQ(expected_volume, settings->alarm_volume.get()); EXPECT_EQ(expected_duration, settings->alarm_duration.get()); + EXPECT_EQ(expected_snooze_duration, settings->snooze_duration.get()); // cleanup g_clear_object(&proxy); diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp index 4fb0a08..5dfb5ae 100644 --- a/tests/test-settings.cpp +++ b/tests/test-settings.cpp @@ -152,6 +152,7 @@ TEST_F(SettingsFixture, UIntProperties) { TestUIntProperty(m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S); TestUIntProperty(m_settings->alarm_volume, SETTINGS_ALARM_VOLUME_S); + TestUIntProperty(m_settings->snooze_duration, SETTINGS_SNOOZE_DURATION_S); } TEST_F(SettingsFixture, StringProperties) |