diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-02-05 16:57:10 -0600 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2014-02-05 16:57:10 -0600 |
commit | a75d4006a59c6e58e14d21fa6820a86f52d113cd (patch) | |
tree | a1334e5eab79d4d4b88bc0300fce8b043f01cedd /src/menu.cpp | |
parent | 4f27e42b0a517fac386042c67efc721463115bb9 (diff) | |
download | ayatana-indicator-datetime-a75d4006a59c6e58e14d21fa6820a86f52d113cd.tar.gz ayatana-indicator-datetime-a75d4006a59c6e58e14d21fa6820a86f52d113cd.tar.bz2 ayatana-indicator-datetime-a75d4006a59c6e58e14d21fa6820a86f52d113cd.zip |
remove upcoming events from the menu once they're no longer upcoming.
Diffstat (limited to 'src/menu.cpp')
-rw-r--r-- | src/menu.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/menu.cpp b/src/menu.cpp index 7f41b22..50a0087 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -239,16 +239,23 @@ private: { int n = 0; const int MAX_APPTS = 5; + const auto now = m_state->clock->localtime(); std::set<std::string> added; for (const auto& appt : m_state->planner->upcoming.get()) { + // don't show too many if (n++ >= MAX_APPTS) break; + // don't show duplicates if (added.count(appt.uid)) continue; + // don't show appointments that have already started + if ((appt.begin<now) || DateTime::is_same_minute(now,appt.begin)) + continue; + added.insert(appt.uid); GDateTime* begin = appt.begin(); |