Add button to close notification
This commit is contained in:
parent
e0d1224173
commit
a82c0a5577
4 changed files with 67 additions and 15 deletions
|
|
@ -64,6 +64,9 @@ impl NotificationList {
|
|||
notifications.connect_notification_recieved(clone!(@weak obj => move |notification| {
|
||||
obj.handle_notification(¬ification);
|
||||
}));
|
||||
notifications.connect_notification_closed(clone!(@weak obj => move |id| {
|
||||
obj.remove_notification(id);
|
||||
}));
|
||||
|
||||
obj
|
||||
}
|
||||
|
|
@ -74,7 +77,7 @@ impl NotificationList {
|
|||
|
||||
fn handle_notification(&self, notification: &Notification) {
|
||||
let notification_widget = cascade! {
|
||||
NotificationWidget::new();
|
||||
NotificationWidget::new(&*self.inner().notifications);
|
||||
..set_notification(notification);
|
||||
};
|
||||
|
||||
|
|
@ -88,6 +91,12 @@ impl NotificationList {
|
|||
self.inner().rows.borrow_mut().insert(notification.id, row);
|
||||
}
|
||||
|
||||
fn remove_notification(&self, id: NotificationId) {
|
||||
if let Some(row) = self.inner().rows.borrow_mut().remove(&id) {
|
||||
self.inner().listbox.remove(&row);
|
||||
}
|
||||
}
|
||||
|
||||
fn id_for_row(&self, row: >k4::ListBoxRow) -> Option<NotificationId> {
|
||||
let rows = self.inner().rows.borrow();
|
||||
Some(*rows.iter().find(|(_, i)| i == &row)?.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue