diff --git a/src/Widgets/AppEntry.vala b/src/Widgets/AppEntry.vala index eb772ed7..f562724a 100644 --- a/src/Widgets/AppEntry.vala +++ b/src/Widgets/AppEntry.vala @@ -8,7 +8,6 @@ public class Notifications.AppEntry : Gtk.ListBoxRow { public string app_id { get; private set; } public AppInfo? app_info { get; construct; default = null; } - public List app_notifications; private static Gtk.CssProvider provider; private static Settings settings; @@ -34,8 +33,6 @@ public class Notifications.AppEntry : Gtk.ListBoxRow { } construct { - app_notifications = new List (); - unowned string name; if (app_info != null) { app_id = app_info.get_id (); @@ -105,24 +102,17 @@ public class Notifications.AppEntry : Gtk.ListBoxRow { targetval = (bool) srcval ? _("Show less") : _("Show more"); return true; }); - } - - public void add_notification_entry (NotificationEntry entry) { - app_notifications.prepend (entry); - entry.clear.connect (remove_notification_entry); - } - public void remove_notification_entry (NotificationEntry entry) { - app_notifications.remove (entry); - entry.dismiss (); + notify["parent"].connect (() => { + if (parent != null) { + return; + } - Session.get_instance ().remove_notification (entry.notification); - if (app_notifications.length () == 0) { if (headers.remove (app_id)) { settings.set_value ("headers", headers); } clear (); - } + }); } } diff --git a/src/Widgets/NotificationsList.vala b/src/Widgets/NotificationsList.vala index f1bbc530..15a30012 100644 --- a/src/Widgets/NotificationsList.vala +++ b/src/Widgets/NotificationsList.vala @@ -100,13 +100,13 @@ public class Notifications.NotificationsList : Granite.Bin { app_entries[row_app_id] = app_entry; } - app_entry.add_notification_entry (row_entry); - row.set_header (app_entries[row_app_id]); } public async void add_entry (Notification notification) { var entry = new NotificationEntry (notification); + entry.clear.connect (clear_notification_entry); + list_store.insert_sorted (entry, sort_func); unowned GLib.DateTime? time = app_datetime[notification.desktop_id]; @@ -133,7 +133,6 @@ public class Notifications.NotificationsList : Granite.Bin { private void clear_app_entry (AppEntry app_entry) { app_entry.clear.disconnect (clear_app_entry); app_entries.unset (app_entry.app_id); - app_entry.app_notifications = new List (); var settings = new Settings ("io.elementary.panel.notifications"); var headers = (HashTable) settings.get_value ("headers"); @@ -157,6 +156,11 @@ public class Notifications.NotificationsList : Granite.Bin { } } + private void clear_notification_entry (NotificationEntry entry) { + entry.dismiss (); + Session.get_instance ().remove_notification (entry.notification); + } + private void on_row_activated (Gtk.ListBoxRow row) { if (row is NotificationEntry) { unowned var notification_entry = (NotificationEntry) row;