feat(gui): wire adw::ToastOverlay for error surfacing
This commit is contained in:
@@ -12,14 +12,16 @@ pub(crate) struct KeysPage {
|
||||
pub root: adw::Bin,
|
||||
daemon: Rc<RefCell<Option<Daemon>>>,
|
||||
parent_window: gtk::Window,
|
||||
toast_overlay: adw::ToastOverlay,
|
||||
}
|
||||
|
||||
impl KeysPage {
|
||||
pub fn new(parent_window: gtk::Window) -> Rc<Self> {
|
||||
pub fn new(parent_window: gtk::Window, toast_overlay: adw::ToastOverlay) -> Rc<Self> {
|
||||
let page = Rc::new(Self {
|
||||
root: adw::Bin::new(),
|
||||
daemon: Rc::new(RefCell::new(None)),
|
||||
parent_window,
|
||||
toast_overlay,
|
||||
});
|
||||
let p = page.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
@@ -165,9 +167,8 @@ impl KeysPage {
|
||||
}
|
||||
|
||||
fn show_toast(self: &Rc<Self>, msg: &str) {
|
||||
// ToastOverlay wiring lands in Task 7. Until then write to stderr so
|
||||
// manual smoke can observe what would be shown.
|
||||
eprintln!("[gui toast] {msg}");
|
||||
let toast = adw::Toast::builder().title(msg).timeout(5).build();
|
||||
self.toast_overlay.add_toast(toast);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user