diff --git a/src/notification_popover.rs b/src/notification_popover.rs index 576fc4cd..8c53acf5 100644 --- a/src/notification_popover.rs +++ b/src/notification_popover.rs @@ -1,15 +1,18 @@ use cascade::cascade; use gtk4::{ glib::{self, clone}, + pango, prelude::*, subclass::prelude::*, }; use crate::deref_cell::DerefCell; +use crate::notifications::Notification; #[derive(Default)] pub struct NotificationPopoverInner { - label: DerefCell, + summary_label: DerefCell, + body_label: DerefCell, } #[glib::object_subclass] @@ -28,7 +31,15 @@ impl ObjectImpl for NotificationPopoverInner { })); }); - let label = cascade! { + let summary_label = cascade! { + gtk4::Label::new(None); + ..set_attributes(Some(&cascade! { + pango::AttrList::new(); + ..insert(pango::Attribute::new_weight(pango::Weight::Bold)); + })); + }; + + let body_label = cascade! { gtk4::Label::new(None); }; @@ -37,10 +48,15 @@ impl ObjectImpl for NotificationPopoverInner { ..set_autohide(false); ..set_has_arrow(false); ..set_offset(0, 12); - ..set_child(Some(&label)); + ..set_child(Some(&cascade! { + gtk4::Box::new(gtk4::Orientation::Vertical, 0); + ..append(&summary_label); + ..append(&body_label); + })); }; - self.label.set(label); + self.summary_label.set(summary_label); + self.body_label.set(body_label); } } @@ -62,7 +78,8 @@ impl NotificationPopover { NotificationPopoverInner::from_instance(self) } - pub fn set_body(&self, body: &str) { - self.inner().label.set_label(body); + pub fn set_notification(&self, notification: &Notification) { + self.inner().summary_label.set_label(¬ification.summary); + self.inner().body_label.set_label(¬ification.body); } } diff --git a/src/time_button.rs b/src/time_button.rs index 9474e7ff..0e33c182 100644 --- a/src/time_button.rs +++ b/src/time_button.rs @@ -135,8 +135,9 @@ impl TimeButton { fn handle_notification(&self, notification: &Notification) { println!("{:?}", notification); - let popover = &self.inner().notification_popover; - popover.set_body(¬ification.body); - popover.popup(); + self.inner() + .notification_popover + .set_notification(notification); + self.inner().notification_popover.popup(); } }