mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
remove extra members
This commit is contained in:
parent
1497896f6d
commit
6911559915
7 changed files with 104 additions and 233 deletions
|
|
@ -1,89 +1,7 @@
|
|||
pub mod download;
|
||||
mod failure;
|
||||
mod identity;
|
||||
mod loading;
|
||||
mod mime;
|
||||
pub mod failure;
|
||||
pub mod identity;
|
||||
pub mod loading;
|
||||
pub mod mime;
|
||||
|
||||
use super::TabAction;
|
||||
use adw::StatusPage;
|
||||
use gtk::{
|
||||
gio::{Cancellable, File},
|
||||
glib::GString,
|
||||
};
|
||||
use std::{rc::Rc, time::Duration};
|
||||
|
||||
pub struct Status {
|
||||
pub gobject: StatusPage,
|
||||
}
|
||||
|
||||
impl Status {
|
||||
// Constructors
|
||||
|
||||
/// Create new download preset
|
||||
pub fn new_download(
|
||||
initial_filename: &str,
|
||||
cancellable: &Cancellable,
|
||||
on_choose: impl Fn(File, Rc<download::Action>) + 'static,
|
||||
) -> Self {
|
||||
Self {
|
||||
gobject: download::new(initial_filename, cancellable, on_choose),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create new failure preset
|
||||
///
|
||||
/// Useful as placeholder widget for error handlers
|
||||
pub fn new_failure() -> Self {
|
||||
Self {
|
||||
gobject: failure::new_gobject(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create new mime issue preset
|
||||
///
|
||||
/// Useful as placeholder widget for mime issue handlers
|
||||
pub fn new_mime(mime: &str, download: Option<(Rc<TabAction>, GString)>) -> Self {
|
||||
Self {
|
||||
gobject: mime::new_gobject(mime, download),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create new identity preset
|
||||
///
|
||||
/// Useful as placeholder for 60 status code
|
||||
/// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
||||
pub fn new_identity(action: Rc<crate::app::browser::window::tab::item::Action>) -> Self {
|
||||
Self {
|
||||
gobject: identity::new_gobject(action),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create new loading preset
|
||||
///
|
||||
/// Useful as placeholder widget for async operations
|
||||
pub fn new_loading(show_with_delay: Option<Duration>) -> Self {
|
||||
Self {
|
||||
gobject: loading::new_gobject(show_with_delay),
|
||||
}
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
/// Set new title for `Self`
|
||||
///
|
||||
/// Return `Self` reference to apply another functions in chain
|
||||
pub fn set_title(&self, value: &str) -> &Self {
|
||||
self.gobject.set_title(value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set new description for `Self`
|
||||
///
|
||||
/// Useful for loading widgets to update byte totals and other dynamically changed information
|
||||
///
|
||||
/// Return `Self` reference to apply another functions in chain
|
||||
pub fn set_description(&self, value: Option<&str>) -> &Self {
|
||||
self.gobject.set_description(value);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const DEFAULT_ICON_NAME: &str = "dialog-error";
|
|||
|
||||
/// Create new default `GObject` preset for failure
|
||||
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||
pub fn new_gobject() -> StatusPage {
|
||||
pub fn new() -> StatusPage {
|
||||
StatusPage::builder()
|
||||
.title(DEFAULT_TITLE)
|
||||
.icon_name(DEFAULT_ICON_NAME)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::app::browser::window::tab::item::Action;
|
||||
use adw::StatusPage;
|
||||
use gtk::{prelude::ButtonExt, Align, Button};
|
||||
use std::rc::Rc;
|
||||
|
||||
// Defaults
|
||||
const DEFAULT_ICON_NAME: &str = "avatar-default-symbolic";
|
||||
|
|
@ -14,7 +13,7 @@ const DEFAULT_BUTTON_CLASS: &str = "suggested-action";
|
|||
|
||||
/// Create new default preset for `Identity`
|
||||
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||
pub fn new_gobject(action: Rc<Action>) -> StatusPage {
|
||||
pub fn new(action: Rc<Action>) -> StatusPage {
|
||||
// Init certificate selection
|
||||
let button = &Button::builder()
|
||||
.css_classes([DEFAULT_BUTTON_CLASS])
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const DEFAULT_TITLE: &str = "Loading..";
|
|||
|
||||
/// Create new default preset for loading
|
||||
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||
pub fn new_gobject(show_with_delay: Option<Duration>) -> StatusPage {
|
||||
pub fn new(show_with_delay: Option<Duration>) -> StatusPage {
|
||||
// Init spinner component
|
||||
let spinner = Spinner::builder()
|
||||
.width_request(SPINNER_SIZE)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::rc::Rc;
|
|||
|
||||
/// Create new default `GObject` preset for mime issue
|
||||
/// [StatusPage](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html)
|
||||
pub fn new_gobject(mime: &str, download: Option<(Rc<TabAction>, GString)>) -> StatusPage {
|
||||
pub fn new(mime: &str, download: Option<(Rc<TabAction>, GString)>) -> StatusPage {
|
||||
let status_page = StatusPage::builder()
|
||||
.description(format!("Content type `{mime}` not supported!"))
|
||||
.icon_name("dialog-question-symbolic")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue