aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-05-14 12:18:45 -0500
committerRobert Tari <robert@tari.in>2021-07-07 02:13:38 +0200
commit8c7997ad86cffd8fb0b1578e2bc632395744d0b8 (patch)
tree8761544970cf36dc41c6fc88aed91a79da49fd1e /src/main.cpp
parent85cb430bd147719fed43f4ccf04b9d22cad33bfc (diff)
downloadayatana-indicator-datetime-8c7997ad86cffd8fb0b1578e2bc632395744d0b8.tar.gz
ayatana-indicator-datetime-8c7997ad86cffd8fb0b1578e2bc632395744d0b8.tar.bz2
ayatana-indicator-datetime-8c7997ad86cffd8fb0b1578e2bc632395744d0b8.zip
add a new Snap::Response enum for more flexible handling of snap decisions
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 034a5ef..9defed0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -153,14 +153,21 @@ main(int /*argc*/, char** /*argv*/)
auto notification_engine = std::make_shared<ain::Engine>("ayatana-indicator-datetime-service");
std::unique_ptr<Snap> snap (new Snap(notification_engine, state->settings));
auto alarm_queue = create_simple_alarm_queue(state->clock, snooze_planner, engine, timezone_);
- auto on_snooze = [snooze_planner](const Appointment& appointment, const Alarm& alarm) {
- snooze_planner->add(appointment, alarm);
+ auto sound_builder = std::make_shared<uin::DefaultSoundBuilder>();
+ auto on_response = [snooze_planner, actions](const Appointment& appointment, const Alarm& alarm, const Snap::Response& response) {
+ switch(response) {
+ case Snap::Response::Snooze:
+ snooze_planner->add(appointment, alarm);
+ break;
+ case Snap::Response::ShowApp:
+ actions->open_appointment(appointment, appointment.begin);
+ break;
+ case Snap::Response::None:
+ break;
+ }
};
- auto on_ok = [actions](const Appointment& app, const Alarm&){
- actions->open_appointment(app, app.begin);
- };
- auto on_alarm_reached = [&engine, &snap, &on_snooze, &on_ok](const Appointment& appointment, const Alarm& alarm) {
- (*snap)(appointment, alarm, on_snooze, on_ok);
+ auto on_alarm_reached = [&engine, &snap, &on_response](const Appointment& appointment, const Alarm& alarm) {
+ (*snap)(appointment, alarm, on_response);
engine->disable_ubuntu_alarm(appointment);
};
alarm_queue->alarm_reached().connect(on_alarm_reached);