diff --git a/src/Indicator.vala b/src/Indicator.vala index ee58e59f..7f6e4724 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -163,15 +163,11 @@ public class Notifications.Indicator : Wingpanel.Indicator { } private void on_notification_closed (uint32 id, Notification.CloseReason reason) { - SearchFunc find_entry = (e, i) => { - return i == e.notification.server_id ? 0 : i > e.notification.server_id ? 1 : -1; - }; - - foreach (var app_entry in nlist.app_entries.values) { - unowned var node = app_entry.app_notifications.search (id, find_entry); - if (node != null) { - node.data.notification.server_id = 0; // Notification is now outdated - node.data.clear (); + for (int i = 0; i < nlist.notification_items.get_n_items (); i++) { + var entry = (NotificationEntry) nlist.notification_items.get_item (i); + if (id == entry.notification.server_id) { + entry.notification.server_id = 0; // Notification is now outdated + entry.clear (); return; } } @@ -199,8 +195,7 @@ public class Notifications.Indicator : Wingpanel.Indicator { } private void update_tooltip () { - uint number_of_apps = 0; - uint number_of_notifications = nlist.count_notifications (out number_of_apps); + var number_of_notifications = nlist.notification_items.get_n_items (); string description; string accel_label; @@ -220,11 +215,12 @@ public class Notifications.Indicator : Wingpanel.Indicator { description = _("1 notification"); break; default: + var number_of_apps = nlist.app_entries.size; /// TRANSLATORS: A tooltip text for the indicator representing the number of notifications. /// e.g. "2 notifications from 1 app" or "5 notifications from 3 apps" description = _("%s from %s").printf ( dngettext (GETTEXT_PACKAGE, "%u notification", "%u notifications", number_of_notifications).printf (number_of_notifications), - dngettext (GETTEXT_PACKAGE, "%u app", "%u apps", number_of_apps).printf (number_of_apps) + dngettext (GETTEXT_PACKAGE, "%i app", "%i apps", number_of_apps).printf (number_of_apps) ); break; } diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index 44dd611b..18815551 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -26,6 +26,11 @@ public class Notifications.NotificationsList : Granite.Bin { public Gee.HashMap app_entries { get; private set; } private ListStore list_store; + public ListModel notification_items { + get { + return list_store; + } + } construct { app_entries = new Gee.HashMap (); @@ -125,11 +130,6 @@ public class Notifications.NotificationsList : Granite.Bin { yield; } - public uint count_notifications (out int number_of_apps) { - number_of_apps = app_entries.size; - return list_store.n_items; - } - public void clear_all () { var iter = app_entries.map_iterator (); while (iter.next ()) {