implement separated mod with options for failure component

This commit is contained in:
yggverse 2024-10-29 01:24:10 +02:00
parent 1d4a3cbd42
commit 931dc1cfc2
5 changed files with 92 additions and 26 deletions

View file

@ -1,6 +1,8 @@
mod failure;
mod loading;
use failure::Failure;
use loading::Loading;
use adw::StatusPage;
@ -9,14 +11,26 @@ pub struct Status {
}
impl Status {
// Construct
pub fn new_error(title: &str, description: &str) -> Self {
// Constructors
/// Create new default failure component
pub fn new_failure(title: Option<&str>, description: Option<&str>) -> Self {
Self {
gobject: Failure::new(title, description),
gobject: Failure::new(title, description).gobject().clone(),
}
}
/// Create new default loading component
///
/// Useful as the placeholder widget for async operations
pub fn new_loading(title: Option<&str>, description: Option<&str>) -> Self {
Self {
gobject: Loading::new(title, description).gobject().clone(),
}
}
// Getters
pub fn gobject(&self) -> &StatusPage {
&self.gobject
}