aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2016-04-20 17:59:25 -0300
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:39 +0200
commit6a6cca286f8dca9a41fb13d51f991dd88eec5791 (patch)
tree8de504e6aeffd92de1751d16fd7216789e8ddbc1
parent605ece31c05b571e8855bcec57550cd067c2f7bb (diff)
downloadayatana-indicator-datetime-6a6cca286f8dca9a41fb13d51f991dd88eec5791.tar.gz
ayatana-indicator-datetime-6a6cca286f8dca9a41fb13d51f991dd88eec5791.tar.bz2
ayatana-indicator-datetime-6a6cca286f8dca9a41fb13d51f991dd88eec5791.zip
Vibrate only once when notification about calendar events.
-rw-r--r--include/notifications/haptic.h2
-rw-r--r--src/haptic.cpp20
-rw-r--r--src/snap.cpp2
3 files changed, 15 insertions, 9 deletions
diff --git a/include/notifications/haptic.h b/include/notifications/haptic.h
index 535074d..2f4008a 100644
--- a/include/notifications/haptic.h
+++ b/include/notifications/haptic.h
@@ -41,7 +41,7 @@ public:
MODE_PULSE
};
- explicit Haptic(const Mode& mode = MODE_PULSE);
+ explicit Haptic(const Mode& mode = MODE_PULSE, bool repeat = false);
~Haptic();
private:
diff --git a/src/haptic.cpp b/src/haptic.cpp
index 7430c04..dc2cb82 100644
--- a/src/haptic.cpp
+++ b/src/haptic.cpp
@@ -37,9 +37,10 @@ class Haptic::Impl
{
public:
- Impl(const Mode& mode):
+ Impl(const Mode& mode, bool repeat):
m_mode(mode),
- m_cancellable(g_cancellable_new())
+ m_cancellable(g_cancellable_new()),
+ m_repeat(repeat)
{
g_bus_get (G_BUS_TYPE_SESSION, m_cancellable, on_bus_ready, this);
}
@@ -93,11 +94,15 @@ private:
// one second on, one second off.
m_pattern = std::vector<uint32_t>({1000u, 1000u});
break;
+
}
- // Set up a loop to keep repeating the pattern
- auto msec = std::accumulate(m_pattern.begin(), m_pattern.end(), 0u);
- m_tag = g_timeout_add(msec, call_vibrate_pattern_static, this);
+ if (m_repeat)
+ {
+ // Set up a loop to keep repeating the pattern
+ auto msec = std::accumulate(m_pattern.begin(), m_pattern.end(), 0u);
+ m_tag = g_timeout_add(msec, call_vibrate_pattern_static, this);
+ }
call_vibrate_pattern();
}
@@ -146,14 +151,15 @@ private:
GDBusConnection * m_bus = nullptr;
std::vector<uint32_t> m_pattern;
guint m_tag = 0;
+ bool m_repeat = false;
};
/***
****
***/
-Haptic::Haptic(const Mode& mode):
- impl(new Impl (mode))
+Haptic::Haptic(const Mode& mode, bool repeat):
+ impl(new Impl (mode, repeat))
{
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 4736498..217b6df 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -117,7 +117,7 @@ public:
if (should_vibrate()) {
const auto haptic_mode = m_settings->alarm_haptic.get();
if (haptic_mode == "pulse")
- haptic = std::make_shared<ain::Haptic>(ain::Haptic::MODE_PULSE);
+ haptic = std::make_shared<ain::Haptic>(ain::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm());
}
// show a notification...