mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
handle undefined mime type errors with download status page, optional rename constructors from new to build
This commit is contained in:
parent
fe5eeb04f9
commit
14159d54e1
7 changed files with 49 additions and 15 deletions
|
|
@ -13,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(action: Rc<Action>) -> StatusPage {
|
||||
pub fn build(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(show_with_delay: Option<Duration>) -> StatusPage {
|
||||
pub fn build(show_with_delay: Option<Duration>) -> StatusPage {
|
||||
// Init spinner component
|
||||
let spinner = Spinner::builder()
|
||||
.width_request(SPINNER_SIZE)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use super::TabAction;
|
||||
use adw::StatusPage;
|
||||
use gtk::{glib::GString, prelude::ButtonExt, Align, Button};
|
||||
use gtk::{glib::Uri, prelude::ButtonExt, Align, Button};
|
||||
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(mime: &str, download: Option<(Rc<TabAction>, GString)>) -> StatusPage {
|
||||
pub fn build(mime: &str, download: Option<(&Rc<TabAction>, &Uri)>) -> StatusPage {
|
||||
let status_page = StatusPage::builder()
|
||||
.description(format!("Content type `{mime}` not supported!"))
|
||||
.icon_name("dialog-question-symbolic")
|
||||
|
|
@ -20,8 +20,14 @@ pub fn new(mime: &str, download: Option<(Rc<TabAction>, GString)>) -> StatusPage
|
|||
.tooltip_text("Download as file to open with external application")
|
||||
.build();
|
||||
|
||||
button.connect_clicked(move |_| {
|
||||
action.load.activate(Some(request.as_str()), true);
|
||||
button.connect_clicked({
|
||||
let action = action.clone();
|
||||
let request = request.clone();
|
||||
move |_| {
|
||||
action
|
||||
.load
|
||||
.activate(Some(&format!("download:{}", request.to_string())), true);
|
||||
}
|
||||
});
|
||||
|
||||
status_page.set_child(Some(&button));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue