mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-10 10:24:13 +00:00
implement loading widget
This commit is contained in:
parent
ced0113d0c
commit
385586ca3d
@ -48,6 +48,14 @@ impl Content {
|
||||
self.gobject.append(status_default.gobject());
|
||||
}
|
||||
|
||||
pub fn set_status_loading(&self, title: Option<&str>, description: Option<&str>) {
|
||||
self.clean();
|
||||
|
||||
let status_default = Status::new_loading(title, description);
|
||||
|
||||
self.gobject.append(status_default.gobject());
|
||||
}
|
||||
|
||||
pub fn set_text_gemini(&self, base: &Uri, data: &str) -> Option<GString> {
|
||||
self.clean();
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
mod widget;
|
||||
use widget::Widget;
|
||||
|
||||
use adw::StatusPage;
|
||||
|
||||
pub struct Loading {
|
||||
widget: Widget,
|
||||
}
|
||||
|
||||
impl Loading {
|
||||
pub fn new(title: Option<&str>, description: Option<&str>) -> Self {
|
||||
Self {
|
||||
widget: Widget::new(title, description),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gobject(&self) -> &StatusPage {
|
||||
&self.widget.gobject()
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
use adw::{Spinner, StatusPage};
|
||||
|
||||
/// 16-64 (px)
|
||||
const SPINNER_SIZE: i32 = 64;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: StatusPage,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
pub fn new(title: Option<&str>, description: Option<&str>) -> Self {
|
||||
let gobject = StatusPage::builder()
|
||||
.child(
|
||||
&Spinner::builder()
|
||||
.width_request(SPINNER_SIZE)
|
||||
.height_request(SPINNER_SIZE)
|
||||
.build(),
|
||||
)
|
||||
.build();
|
||||
|
||||
if let Some(value) = title {
|
||||
gobject.set_title(value);
|
||||
}
|
||||
|
||||
gobject.set_description(description);
|
||||
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
pub fn gobject(&self) -> &StatusPage {
|
||||
&self.gobject
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user