From efcb3c5aec9b63fb54231409e85184f79c28ab00 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 9 Sep 2021 08:27:04 -0700 Subject: [PATCH] Close notification on click --- src/notification_popover.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/notification_popover.rs b/src/notification_popover.rs index 0f28b3fb..576fc4cd 100644 --- a/src/notification_popover.rs +++ b/src/notification_popover.rs @@ -1,5 +1,9 @@ use cascade::cascade; -use gtk4::{glib, prelude::*, subclass::prelude::*}; +use gtk4::{ + glib::{self, clone}, + prelude::*, + subclass::prelude::*, +}; use crate::deref_cell::DerefCell; @@ -17,6 +21,13 @@ impl ObjectSubclass for NotificationPopoverInner { impl ObjectImpl for NotificationPopoverInner { fn constructed(&self, obj: &NotificationPopover) { + obj.add_controller(&cascade! { + gtk4::GestureClick::new(); + ..connect_pressed(clone!(@weak obj => move |_, _, _, _| { + obj.popdown(); + })); + }); + let label = cascade! { gtk4::Label::new(None); };