From 4148750ea93e67e5d9aaa15ebc8e3c7a5a5554f1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 31 Jul 2014 16:48:00 -0500 Subject: configurable haptic mode, part 1 of 3: add haptic feedback mode to the GSettings schema and to our Settings object --- data/com.canonical.indicator.datetime.gschema.xml.in | 8 ++++++++ include/datetime/settings-live.h | 1 + include/datetime/settings-shared.h | 1 + include/datetime/settings.h | 1 + src/settings-live.cpp | 14 ++++++++++++++ tests/test-settings.cpp | 1 + 6 files changed, 26 insertions(+) diff --git a/data/com.canonical.indicator.datetime.gschema.xml.in b/data/com.canonical.indicator.datetime.gschema.xml.in index 62b42c1..4e4acd8 100644 --- a/data/com.canonical.indicator.datetime.gschema.xml.in +++ b/data/com.canonical.indicator.datetime.gschema.xml.in @@ -123,6 +123,14 @@ Some timezones can be known by many different cities or names. This setting describes how the current zone prefers to be named. Format is "TIMEZONE NAME" (e.g. "America/New_York Boston" to name the New_York zone Boston). + + 'pulse' + <_summary>What kind of haptic feedback, if any, to trigger with an alarm. + <_description> + What kind of haptic feedback, if any, to trigger with an alarm. + Two modes are currently supported: 'pulse', 'none'. + + '/usr/share/sounds/ubuntu/ringtones/Suru arpeggio.ogg' <_summary>The alarm's default sound file. diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h index 4db2d40..4850e69 100644 --- a/include/datetime/settings-live.h +++ b/include/datetime/settings-live.h @@ -58,6 +58,7 @@ private: void update_alarm_sound(); void update_alarm_volume(); void update_alarm_duration(); + void update_alarm_haptic(); GSettings* m_settings; diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h index 23d2e1c..a211821 100644 --- a/include/datetime/settings-shared.h +++ b/include/datetime/settings-shared.h @@ -48,5 +48,6 @@ TimeFormatMode; #define SETTINGS_ALARM_SOUND_S "alarm-default-sound" #define SETTINGS_ALARM_VOLUME_S "alarm-default-volume" #define SETTINGS_ALARM_DURATION_S "alarm-duration-minutes" +#define SETTINGS_ALARM_HAPTIC_S "alarm-haptic-feedback" #endif // INDICATOR_DATETIME_SETTINGS_SHARED diff --git a/include/datetime/settings.h b/include/datetime/settings.h index e5f885e..c6fe13b 100644 --- a/include/datetime/settings.h +++ b/include/datetime/settings.h @@ -57,6 +57,7 @@ public: core::Property time_format_mode; core::Property timezone_name; core::Property alarm_sound; + core::Property alarm_haptic; core::Property alarm_volume; core::Property alarm_duration; }; diff --git a/src/settings-live.cpp b/src/settings-live.cpp index 71bbd96..a8338ed 100644 --- a/src/settings-live.cpp +++ b/src/settings-live.cpp @@ -55,6 +55,7 @@ LiveSettings::LiveSettings(): update_alarm_sound(); update_alarm_volume(); update_alarm_duration(); + update_alarm_haptic(); // now listen for clients to change the properties s.t. we can sync update GSettings @@ -130,6 +131,10 @@ LiveSettings::LiveSettings(): alarm_duration.changed().connect([this](unsigned int value){ g_settings_set_uint(m_settings, SETTINGS_ALARM_DURATION_S, value); }); + + alarm_haptic.changed().connect([this](const std::string& value){ + g_settings_set_string(m_settings, SETTINGS_ALARM_HAPTIC_S, value.c_str()); + }); } /*** @@ -237,6 +242,13 @@ void LiveSettings::update_alarm_duration() alarm_duration.set(g_settings_get_uint(m_settings, SETTINGS_ALARM_DURATION_S)); } +void LiveSettings::update_alarm_haptic() +{ + auto val = g_settings_get_string(m_settings, SETTINGS_ALARM_HAPTIC_S); + alarm_haptic.set(val); + g_free(val); +} + /*** **** ***/ @@ -284,6 +296,8 @@ void LiveSettings::update_key(const std::string& key) update_alarm_volume(); else if (key == SETTINGS_ALARM_DURATION_S) update_alarm_duration(); + else if (key == SETTINGS_ALARM_HAPTIC_S) + update_alarm_haptic(); } /*** diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp index 44a0252..4fb0a08 100644 --- a/tests/test-settings.cpp +++ b/tests/test-settings.cpp @@ -159,6 +159,7 @@ TEST_F(SettingsFixture, StringProperties) TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S); TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S); TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S); + TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S); } TEST_F(SettingsFixture, TimeFormatMode) -- cgit v1.2.3