Implemented "CloseNotification" function

This commit is contained in:
Erik Reider
2021-07-27 22:29:53 +02:00
parent 0e8f158e3c
commit d855e2958e
2 changed files with 17 additions and 2 deletions

View File

@@ -122,7 +122,7 @@ namespace SwayNotificatonCenter {
}
public void CloseNotification (uint32 id) throws DBusError, IOError {
print ("yeet");
notiWin.close_notification (id);
}
public void GetServerInformation (out string name,

View File

@@ -12,10 +12,16 @@ namespace SwayNotificatonCenter {
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true);
}
private void removeWidget (Gtk.Widget widget) {
uint len = box.get_children ().length () - 1;
box.remove (widget);
if (len <= 0) box.set_visible (false);
}
public void replace_notification (NotifyParams param) {
foreach (var w in box.get_children ()) {
if (((Notification) w).param.applied_id == param.replaces_id) {
box.remove (w);
removeWidget (w);
break;
}
}
@@ -31,5 +37,14 @@ namespace SwayNotificatonCenter {
});
this.show_all ();
}
public void close_notification (uint32 id) {
foreach (var w in box.get_children ()) {
if (((Notification) w).param.applied_id == id) {
removeWidget (w);
break;
}
}
}
}
}