mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
delegate status info to widget implementation
This commit is contained in:
parent
d752fe18fb
commit
549c3fd946
@ -678,20 +678,12 @@ impl Page {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
mime => {
|
mime => {
|
||||||
// Define common data
|
// Init children widget
|
||||||
let status = Status::Failure;
|
let status = content.to_status_mime(mime);
|
||||||
let title = "Oops";
|
|
||||||
let description = gformat!("Content type `{mime}` yet not supported!");
|
|
||||||
|
|
||||||
// Update widget
|
// Update page meta
|
||||||
content
|
meta.set_status(Status::Failure)
|
||||||
.to_status_mime()
|
.set_title(status.gobject.title().as_str());
|
||||||
.set_title(title)
|
|
||||||
.set_description(Some(&description));
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
meta.set_status(status)
|
|
||||||
.set_title(title);
|
|
||||||
|
|
||||||
// Update window
|
// Update window
|
||||||
update.activate(Some(&id));
|
update.activate(Some(&id));
|
||||||
|
@ -74,9 +74,9 @@ impl Content {
|
|||||||
/// Set new `content::Status` component for `Self` with new `status::Mime` issue preset
|
/// Set new `content::Status` component for `Self` with new `status::Mime` issue preset
|
||||||
///
|
///
|
||||||
/// * action removes previous children component from `Self`
|
/// * action removes previous children component from `Self`
|
||||||
pub fn to_status_mime(&self) -> Status {
|
pub fn to_status_mime(&self, mime: &str) -> Status {
|
||||||
self.clean();
|
self.clean();
|
||||||
let status = Status::new_mime();
|
let status = Status::new_mime(mime);
|
||||||
self.gobject.append(status.gobject());
|
self.gobject.append(status.gobject());
|
||||||
status
|
status
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use gtk::gio::{Cancellable, File};
|
|||||||
use std::{rc::Rc, time::Duration};
|
use std::{rc::Rc, time::Duration};
|
||||||
|
|
||||||
pub struct Status {
|
pub struct Status {
|
||||||
gobject: StatusPage,
|
pub gobject: StatusPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Status {
|
impl Status {
|
||||||
@ -38,9 +38,9 @@ impl Status {
|
|||||||
/// Create new mime issue preset
|
/// Create new mime issue preset
|
||||||
///
|
///
|
||||||
/// Useful as placeholder widget for mime issue handlers
|
/// Useful as placeholder widget for mime issue handlers
|
||||||
pub fn new_mime() -> Self {
|
pub fn new_mime(mime: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
gobject: mime::new_gobject(),
|
gobject: mime::new_gobject(mime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
use adw::StatusPage;
|
use adw::StatusPage;
|
||||||
|
|
||||||
const DEFAULT_TITLE: &str = "Oops";
|
|
||||||
const DEFAULT_ICON_NAME: &str = "dialog-question-symbolic";
|
|
||||||
|
|
||||||
/// Create new default `GObject` preset for mime issue
|
/// Create new default `GObject` preset for mime issue
|
||||||
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||||
pub fn new_gobject() -> StatusPage {
|
pub fn new_gobject(mime: &str) -> StatusPage {
|
||||||
StatusPage::builder()
|
StatusPage::builder()
|
||||||
.title(DEFAULT_TITLE)
|
.title("Oops")
|
||||||
.icon_name(DEFAULT_ICON_NAME)
|
.description(format!("Content type `{mime}` not supported!"))
|
||||||
|
.icon_name("dialog-question-symbolic")
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user