mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-11 10:54:14 +00:00
remove extra structs, keep gobject constructors only
This commit is contained in:
parent
ae1d3531bf
commit
70e0320067
@ -1,9 +1,6 @@
|
|||||||
mod failure;
|
mod failure;
|
||||||
mod loading;
|
mod loading;
|
||||||
|
|
||||||
use failure::Failure;
|
|
||||||
use loading::Loading;
|
|
||||||
|
|
||||||
use adw::StatusPage;
|
use adw::StatusPage;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@ -23,9 +20,7 @@ impl Status {
|
|||||||
icon_name: Option<&str>,
|
icon_name: Option<&str>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
gobject: Failure::new(title, description, icon_name)
|
gobject: failure::new_gobject_from(title, description, icon_name),
|
||||||
.gobject()
|
|
||||||
.clone(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,9 +33,7 @@ impl Status {
|
|||||||
show_with_delay: Option<Duration>,
|
show_with_delay: Option<Duration>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
gobject: Loading::new(title, description, show_with_delay)
|
gobject: loading::new_gobject_from(title, description, show_with_delay),
|
||||||
.gobject()
|
|
||||||
.clone(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use adw::StatusPage;
|
use adw::StatusPage;
|
||||||
|
|
||||||
|
const DEFAULT_ICON_NAME: Option<&str> = Some("dialog-error");
|
||||||
const DEFAULT_TITLE: &str = "Oops";
|
const DEFAULT_TITLE: &str = "Oops";
|
||||||
const DEFAULT_DESCRIPTION: Option<&str> = None;
|
const DEFAULT_DESCRIPTION: Option<&str> = None;
|
||||||
const DEFAULT_ICON_NAME: Option<&str> = Some("dialog-error");
|
|
||||||
|
|
||||||
pub struct Failure {
|
/// Create new `GObject` preset for failure [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||||
gobject: StatusPage,
|
pub fn new_gobject_from(
|
||||||
}
|
title: Option<&str>,
|
||||||
|
description: Option<&str>,
|
||||||
impl Failure {
|
icon_name: Option<&str>,
|
||||||
pub fn new(title: Option<&str>, description: Option<&str>, icon_name: Option<&str>) -> Self {
|
) -> StatusPage {
|
||||||
let gobject = StatusPage::new();
|
let gobject = StatusPage::new();
|
||||||
|
|
||||||
gobject.set_title(match title {
|
gobject.set_title(match title {
|
||||||
@ -27,10 +27,5 @@ impl Failure {
|
|||||||
None => DEFAULT_ICON_NAME,
|
None => DEFAULT_ICON_NAME,
|
||||||
});
|
});
|
||||||
|
|
||||||
Self { gobject }
|
gobject
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gobject(&self) -> &StatusPage {
|
|
||||||
&self.gobject
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,12 @@ use std::time::Duration;
|
|||||||
/// 16-64 (px)
|
/// 16-64 (px)
|
||||||
const SPINNER_SIZE: i32 = 64;
|
const SPINNER_SIZE: i32 = 64;
|
||||||
|
|
||||||
pub struct Loading {
|
/// Create new `GObject` preset for loading [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||||
gobject: StatusPage,
|
pub fn new_gobject_from(
|
||||||
}
|
|
||||||
|
|
||||||
impl Loading {
|
|
||||||
pub fn new(
|
|
||||||
title: Option<&str>,
|
title: Option<&str>,
|
||||||
description: Option<&str>,
|
description: Option<&str>,
|
||||||
show_with_delay: Option<Duration>,
|
show_with_delay: Option<Duration>,
|
||||||
) -> Self {
|
) -> StatusPage {
|
||||||
let gobject = StatusPage::builder()
|
let gobject = StatusPage::builder()
|
||||||
.child(
|
.child(
|
||||||
&Spinner::builder()
|
&Spinner::builder()
|
||||||
@ -44,10 +40,5 @@ impl Loading {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { gobject }
|
gobject
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gobject(&self) -> &StatusPage {
|
|
||||||
&self.gobject
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user