aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-02-05 16:26:34 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-02-05 16:26:34 -0600
commit613cbb1d468fe99767a5541956266191511ec9ef (patch)
tree8987586f56570779d12e0384acef39d96a68f046
parent131faf8f832c053343bbc0af694777a5e8f6cbe5 (diff)
downloadayatana-indicator-datetime-613cbb1d468fe99767a5541956266191511ec9ef.tar.gz
ayatana-indicator-datetime-613cbb1d468fe99767a5541956266191511ec9ef.tar.bz2
ayatana-indicator-datetime-613cbb1d468fe99767a5541956266191511ec9ef.zip
remove alarms from the menu once they've been shown in a snap decision.
-rw-r--r--include/datetime/planner-eds.h2
-rw-r--r--src/main.cpp8
-rw-r--r--src/planner-eds.cpp22
3 files changed, 26 insertions, 6 deletions
diff --git a/include/datetime/planner-eds.h b/include/datetime/planner-eds.h
index a99f611..4110ba5 100644
--- a/include/datetime/planner-eds.h
+++ b/include/datetime/planner-eds.h
@@ -20,6 +20,7 @@
#ifndef INDICATOR_DATETIME_PLANNER_EDS_H
#define INDICATOR_DATETIME_PLANNER_EDS_H
+#include <datetime/appointment.h>
#include <datetime/clock.h>
#include <datetime/planner.h>
@@ -37,6 +38,7 @@ class PlannerEds: public Planner
public:
PlannerEds(const std::shared_ptr<Clock>& clock);
virtual ~PlannerEds();
+ void block_appointment(const Appointment& appointment);
private:
class Impl;
diff --git a/src/main.cpp b/src/main.cpp
index daf2a22..5f5ee3c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -59,15 +59,17 @@ main(int /*argc*/, char** /*argv*/)
state->settings = live_settings;
state->clock = live_clock;
state->locations.reset(new SettingsLocations(live_settings, live_timezones));
- state->planner.reset(new PlannerEds(live_clock));
- state->planner->time = live_clock->localtime();
+ std::shared_ptr<PlannerEds> eds_planner(new PlannerEds(live_clock));
+ eds_planner->time = live_clock->localtime();
+ state->planner = eds_planner;
std::shared_ptr<Actions> actions(new LiveActions(state));
MenuFactory factory(actions, state);
// snap decisions
ClockWatcherImpl clock_watcher(state);
Snap snap;
- clock_watcher.alarm_reached().connect([&snap](const Appointment& appt){
+ clock_watcher.alarm_reached().connect([&snap,&eds_planner](const Appointment& appt){
+ eds_planner->block_appointment(appt); // when we show a snap decision, take it out of the menu
auto snap_show = [](const Appointment& a){url_dispatch_send(a.url.c_str(), nullptr, nullptr);};
auto snap_dismiss = [](const Appointment&){};
snap(appt, snap_show, snap_dismiss);
diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp
index 7d9416c..e9452f0 100644
--- a/src/planner-eds.cpp
+++ b/src/planner-eds.cpp
@@ -77,6 +77,12 @@ public:
g_clear_object(&m_source_registry);
}
+ void block_appointment(const Appointment& appointment)
+ {
+ m_blocked.insert(appointment.uid);
+ rebuild_soon(UPCOMING);
+ }
+
private:
static void on_source_registry_ready(GObject* /*source*/, GAsyncResult* res, gpointer gself)
@@ -348,9 +354,13 @@ private:
const auto begin = g_date_time_add_minutes(ref.get(),-10);
const auto end = g_date_time_add_months(begin,1);
- get_appointments(begin, end, [this](const std::vector<Appointment>& appointments) {
- g_debug("got %d upcoming appointments", (int)appointments.size());
- m_owner.upcoming.set(appointments);
+ get_appointments(begin, end, [this](const std::vector<Appointment>& all) {
+ std::vector<Appointment> unblocked;
+ for(const auto& a : all)
+ if (m_blocked.count(a.uid) == 0)
+ unblocked.push_back(a);
+ g_debug("got %d upcoming appointments, %d of which are unblocked", (int)all.size(), (int)unblocked.size());
+ m_owner.upcoming.set(unblocked);
});
g_date_time_unref(end);
@@ -520,6 +530,7 @@ private:
std::set<ESource*> m_sources;
std::map<ESource*,ECalClient*> m_clients;
std::map<ESource*,ECalClientView*> m_views;
+ std::set<std::string> m_blocked;
GCancellable* m_cancellable = nullptr;
ESourceRegistry* m_source_registry = nullptr;
guint m_rebuild_tag = 0;
@@ -531,6 +542,11 @@ PlannerEds::PlannerEds(const std::shared_ptr<Clock>& clock): p(new Impl(*this, c
PlannerEds::~PlannerEds() =default;
+void PlannerEds::block_appointment(const Appointment& appointment)
+{
+ p->block_appointment(appointment);
+}
+
} // namespace datetime
} // namespace indicator
} // namespace unity