Close notification popover on "notification-closed"

This commit is contained in:
Ian Douglas Scott 2021-09-14 12:34:45 -07:00
parent e9055e74d9
commit ec6a0ff366
2 changed files with 10 additions and 1 deletions

View file

@ -63,6 +63,11 @@ impl NotificationPopover {
notifications.connect_notification_recieved(clone!(@weak obj => move |notification| {
obj.handle_notification(&notification);
}));
notifications.connect_notification_closed(clone!(@weak obj => move |id| {
if obj.inner().notification_widget.id() == Some(id) {
obj.popdown();
}
}));
obj
}

View file

@ -65,7 +65,7 @@ impl ObjectImpl for NotificationWidgetInner {
..set_pixel_size(8);
}));
..connect_clicked(clone!(@weak obj => move |_| {
if let Some(id) = obj.inner().id.get() {
if let Some(id) = obj.id() {
obj.inner().notifications.dismiss(id);
}
}));
@ -106,4 +106,8 @@ impl NotificationWidget {
self.inner().body_label.set_label(&notification.body);
self.inner().id.set(Some(notification.id));
}
pub fn id(&self) -> Option<NotificationId> {
self.inner().id.get()
}
}