notifications: initial logic for sending action signal

This commit is contained in:
Ian Douglas Scott 2021-09-23 14:42:24 -07:00
parent 94def67e85
commit 13aa62cef8
3 changed files with 31 additions and 4 deletions

View file

@ -7,7 +7,7 @@ use gtk4::{
use crate::deref_cell::DerefCell;
use crate::notification_widget::NotificationWidget;
use crate::notifications::{Notification, Notifications};
use crate::notifications::{Notification, NotificationId, Notifications};
#[derive(Default)]
pub struct NotificationPopoverInner {
@ -27,6 +27,9 @@ impl ObjectImpl for NotificationPopoverInner {
obj.add_controller(&cascade! {
gtk4::GestureClick::new();
..connect_pressed(clone!(@weak obj => move |_, _, _, _| {
if let Some(id) = obj.id() {
obj.inner().notifications.invoke_action(id, "default");
}
obj.popdown();
}));
});
@ -64,7 +67,7 @@ impl NotificationPopover {
obj.handle_notification(&notification);
}));
notifications.connect_notification_closed(clone!(@weak obj => move |id| {
if obj.inner().notification_widget.id() == Some(id) {
if obj.id() == Some(id) {
obj.popdown();
}
}));
@ -76,6 +79,10 @@ impl NotificationPopover {
NotificationPopoverInner::from_instance(self)
}
fn id(&self) -> Option<NotificationId> {
self.inner().notification_widget.id()
}
fn handle_notification(&self, notification: &Notification) {
self.inner()
.notification_widget