Removed duplicate code for removing temp notification
This commit is contained in:
@@ -64,19 +64,15 @@ namespace SwayNotificatonCenter {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeWidget (Gtk.Widget widget) {
|
||||
uint len = box.get_children ().length () - 1;
|
||||
box.remove (widget);
|
||||
if (len <= 0) this.hide ();
|
||||
private void remove_noti (Notification noti) {
|
||||
if (box.get_children ().index (noti) >= 0) {
|
||||
box.remove (noti);
|
||||
}
|
||||
if (box.get_children ().length () == 0) this.hide ();
|
||||
}
|
||||
|
||||
public void add_notification (NotifyParams param, NotiDaemon notiDaemon) {
|
||||
var noti = new Notification.timed (param, notiDaemon, (v_noti) => {
|
||||
if (box.get_children ().index (v_noti) >= 0) {
|
||||
box.remove (v_noti);
|
||||
}
|
||||
if (box.get_children ().length () == 0) this.hide ();
|
||||
});
|
||||
var noti = new Notification.timed (param, notiDaemon, remove_noti);
|
||||
|
||||
if (list_reverse) {
|
||||
box.pack_start (noti);
|
||||
@@ -92,7 +88,7 @@ namespace SwayNotificatonCenter {
|
||||
foreach (var w in box.get_children ()) {
|
||||
var noti = (Notification) w;
|
||||
if (noti != null && noti.param.applied_id == id) {
|
||||
removeWidget (w);
|
||||
remove_noti (noti);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user