Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,11 @@ public class Notifications.Indicator : Wingpanel.Indicator {
}

private void on_notification_closed (uint32 id, Notification.CloseReason reason) {
SearchFunc<NotificationEntry, uint32> 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;
}
}
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Widgets/NotificationsList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class Notifications.NotificationsList : Granite.Bin {
public Gee.HashMap<string, AppEntry> app_entries { get; private set; }

private ListStore list_store;
public ListModel notification_items {
get {
return list_store;
}
}

construct {
app_entries = new Gee.HashMap<string, AppEntry> ();
Expand Down Expand Up @@ -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 ()) {
Expand Down
Loading