Skip to content
Merged
6 changes: 4 additions & 2 deletions src/Services/Notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public class Notifications.Notification : Object {
timestamp = new GLib.DateTime.now_local ();

desktop_id = lookup_string (hints, DESKTOP_ENTRY_KEY);
if (desktop_id != "" && !desktop_id.has_suffix (DESKTOP_ID_EXT)) {
desktop_id += DESKTOP_ID_EXT;
if (desktop_id != null && desktop_id != "") {
if (!desktop_id.has_suffix (DESKTOP_ID_EXT)) {
desktop_id += DESKTOP_ID_EXT;
}

app_info = new DesktopAppInfo (desktop_id);
}
Expand Down
45 changes: 20 additions & 25 deletions src/Widgets/NotificationsList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,31 @@ public class Notifications.NotificationsList : Gtk.ListBox {
}

public void add_entry (Notification notification) {
if (notification.app_info != null && notification.app_info.get_id () != null) {
AppEntry? app_entry = null;

if (app_entries[notification.desktop_id] != null) {
app_entry = app_entries[notification.desktop_id];
}

var entry = new NotificationEntry (notification);
if (app_entry == null) {
app_entry = new AppEntry (notification.app_info);
app_entry.add_notification_entry (entry);
app_entries[notification.desktop_id] = app_entry;

prepend (app_entry);
insert (entry, 1);
table.insert (app_entry.app_id, 0);
} else {
resort_app_entry (app_entry);
app_entry.add_notification_entry (entry);

int insert_pos = table.get (app_entry.app_id);
insert (entry, insert_pos + 1);
}
var entry = new NotificationEntry (notification);

if (app_entries[notification.desktop_id] != null) {
var app_entry = app_entries[notification.desktop_id];

resort_app_entry (app_entry);
app_entry.add_notification_entry (entry);

int insert_pos = table.get (app_entry.app_id);
insert (entry, insert_pos + 1);
} else {
var app_entry = new AppEntry (notification.app_info);
app_entry.add_notification_entry (entry);
app_entry.clear.connect (clear_app_entry);

show_all ();
app_entries[notification.desktop_id] = app_entry;

Session.get_instance ().add_notification (notification);
prepend (app_entry);
insert (entry, 1);
table.insert (app_entry.app_id, 0);
}

show_all ();

Session.get_instance ().add_notification (notification);
}

public void clear_all () {
Expand Down