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: 5 additions & 15 deletions src/Widgets/AppEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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<NotificationEntry> app_notifications;

private static Gtk.CssProvider provider;
private static Settings settings;
Expand All @@ -34,8 +33,6 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
}

construct {
app_notifications = new List<NotificationEntry> ();

unowned string name;
if (app_info != null) {
app_id = app_info.get_id ();
Expand Down Expand Up @@ -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 ();
}
});
}
}
10 changes: 7 additions & 3 deletions src/Widgets/NotificationsList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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<NotificationEntry> ();

var settings = new Settings ("io.elementary.panel.notifications");
var headers = (HashTable<string, bool>) settings.get_value ("headers");
Expand All @@ -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;
Expand Down
Loading