From ce576453c6e8dbc38918600480c7cb4b68e37688 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 23 Feb 2014 22:14:51 -0600 Subject: don't let each iteration of a recurring event/alarm spam out other upcoming event/alarms in the menu. --- src/menu.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/menu.cpp b/src/menu.cpp index b2562db..a1cd18c 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -267,14 +267,14 @@ private: for (const auto& appt : m_upcoming) { - // don't show too many - if (n++ >= MAX_APPTS) - break; - // don't show duplicates if (added.count(appt.uid)) continue; + // don't show too many + if (n++ >= MAX_APPTS) + break; + added.insert(appt.uid); GDateTime* begin = appt.begin(); -- cgit v1.2.3 From 5bae051d727588fec82f337c26629be48c6c47e1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 23 Feb 2014 22:48:57 -0600 Subject: actually, why keep the local variable at all. Use g_menu_model_get_n_items() to see if we've reached MAX_APPTS yet. --- src/menu.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/menu.cpp b/src/menu.cpp index a1cd18c..12ec3ef 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -261,7 +261,6 @@ private: void add_appointments(GMenu* menu, Profile profile) { - int n = 0; const int MAX_APPTS = 5; std::set added; @@ -272,7 +271,7 @@ private: continue; // don't show too many - if (n++ >= MAX_APPTS) + if (g_menu_model_get_n_items (G_MENU_MODEL(menu) >= MAX_APPTS)) break; added.insert(appt.uid); -- cgit v1.2.3 From 936cd1a7c4d3bee2e53f8aa15f585b9446816c26 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 24 Feb 2014 10:17:44 -0600 Subject: fix typo in previous commit --- src/menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/menu.cpp b/src/menu.cpp index 12ec3ef..797757f 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -271,7 +271,7 @@ private: continue; // don't show too many - if (g_menu_model_get_n_items (G_MENU_MODEL(menu) >= MAX_APPTS)) + if (g_menu_model_get_n_items (G_MENU_MODEL(menu)) >= MAX_APPTS) break; added.insert(appt.uid); -- cgit v1.2.3