mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
add optional download button for unknown mime types
This commit is contained in:
parent
549c3fd946
commit
f2dadee082
4 changed files with 39 additions and 12 deletions
|
|
@ -1,11 +1,31 @@
|
|||
use super::TabAction;
|
||||
use adw::StatusPage;
|
||||
use gtk::{glib::GString, 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_gobject(mime: &str) -> StatusPage {
|
||||
StatusPage::builder()
|
||||
.title("Oops")
|
||||
pub fn new_gobject(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")
|
||||
.build()
|
||||
.title("Oops")
|
||||
.build();
|
||||
|
||||
if let Some((action, request)) = download {
|
||||
let button = Button::builder()
|
||||
.css_classes(["accent"])
|
||||
.halign(Align::Center)
|
||||
.label("Download")
|
||||
.tooltip_text("Download as file to open with other application")
|
||||
.build();
|
||||
|
||||
button.connect_clicked(move |_| {
|
||||
action.load.activate(Some(request.as_str()), true);
|
||||
});
|
||||
|
||||
status_page.set_child(Some(&button));
|
||||
}
|
||||
|
||||
status_page
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue