util/root: Add window_show_error() to avoid unwrap

Fixes #553
This commit is contained in:
Sophie Herold 2025-12-09 22:04:58 +01:00
parent cfd33fa2dd
commit 83b2c7cae1
4 changed files with 18 additions and 16 deletions

View file

@ -52,16 +52,12 @@ pub trait ParentWindow: WidgetExt {
#[track_caller]
fn window_show_toast(&self, text: &str, priority: adw::ToastPriority) {
if let Some(window) = self.try_window() {
window.show_toast(text, priority);
}
self.window_inspect(|w| w.show_toast(text, priority));
}
#[track_caller]
fn window_add_toast(&self, toast: adw::Toast) {
if let Some(window) = self.try_window() {
window.add_toast(toast);
}
self.window_inspect(|w| w.add_toast(toast));
}
#[track_caller]
@ -69,6 +65,11 @@ pub trait ParentWindow: WidgetExt {
self.try_window().inspect(f);
}
#[track_caller]
fn window_show_error(&self, stub: &str, details: &str, error_type: super::ErrorType) {
self.window_inspect(|w| w.show_error(stub, details, error_type));
}
fn edit_window(&self) -> LpEditWindow {
let parent = self.parent().unwrap();