This commit is contained in:
yggverse 2024-10-31 17:48:12 +02:00
parent a0a6a5c206
commit 91e22f0035

View File

@ -1,5 +1,9 @@
use adw::StatusPage;
const DEFAULT_TITLE: &str = "Oops";
const DEFAULT_DESCRIPTION: Option<&str> = None;
const DEFAULT_ICON_NAME: &str = "dialog-error";
pub struct Widget {
gobject: StatusPage,
}
@ -11,11 +15,17 @@ impl Widget {
pub fn new(title: Option<&str>, description: Option<&str>) -> Self {
let gobject = StatusPage::new();
if let Some(value) = title {
gobject.set_title(value);
}
gobject.set_title(match title {
Some(value) => value,
None => DEFAULT_TITLE,
});
gobject.set_description(description);
gobject.set_description(match description {
Some(value) => Some(value),
None => DEFAULT_DESCRIPTION,
});
gobject.set_icon_name(Some(DEFAULT_ICON_NAME));
Self { gobject }
}