mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
init profile TOFU features
This commit is contained in:
parent
5aa6b1464c
commit
f831212d40
11 changed files with 403 additions and 44 deletions
|
|
@ -51,9 +51,9 @@ impl Content {
|
|||
/// * action removes previous children component from `Self`
|
||||
pub fn to_image(&self, paintable: &impl IsA<Paintable>) -> Image {
|
||||
self.clean();
|
||||
let image = Image::new_from_paintable(paintable);
|
||||
self.g_box.append(&image.picture);
|
||||
image
|
||||
let i = Image::new_from_paintable(paintable);
|
||||
self.g_box.append(&i.picture);
|
||||
i
|
||||
}
|
||||
|
||||
/// Set new `content::Status` component for `Self` with new `status::Download` preset
|
||||
|
|
@ -66,9 +66,9 @@ impl Content {
|
|||
on_choose: impl Fn(File, Rc<status::download::Action>) + 'static,
|
||||
) -> StatusPage {
|
||||
self.clean();
|
||||
let status = status::download::build(initial_filename, cancellable, on_choose);
|
||||
self.g_box.append(&status);
|
||||
status
|
||||
let s = status::download::build(initial_filename, cancellable, on_choose);
|
||||
self.g_box.append(&s);
|
||||
s
|
||||
}
|
||||
|
||||
/// Set new `content::Status` component for `Self` with new `status::Failure` preset
|
||||
|
|
@ -76,9 +76,19 @@ impl Content {
|
|||
/// * action removes previous children component from `Self`
|
||||
pub fn to_status_failure(&self) -> StatusPage {
|
||||
self.clean();
|
||||
let status = status::failure::new();
|
||||
self.g_box.append(&status);
|
||||
status
|
||||
let s = status::failure::new();
|
||||
self.g_box.append(&s);
|
||||
s
|
||||
}
|
||||
|
||||
/// Set new `content::Status` component for `Self` with new `status::Tofu` preset
|
||||
///
|
||||
/// * action removes previous children component from `Self`
|
||||
pub fn to_status_tofu(&self, on_accept: impl Fn() + 'static) -> StatusPage {
|
||||
self.clean();
|
||||
let s = status::tofu::build(on_accept);
|
||||
self.g_box.append(&s);
|
||||
s
|
||||
}
|
||||
|
||||
/// Set new `content::Status` component for `Self` with new `status::Mime` issue preset
|
||||
|
|
@ -90,9 +100,9 @@ impl Content {
|
|||
download: Option<(&Rc<ItemAction>, &Uri)>,
|
||||
) -> StatusPage {
|
||||
self.clean();
|
||||
let status = status::mime::build(mime, download);
|
||||
self.g_box.append(&status);
|
||||
status
|
||||
let s = status::mime::build(mime, download);
|
||||
self.g_box.append(&s);
|
||||
s
|
||||
}
|
||||
|
||||
/// Set new `content::Status` component for `Self` with new `status::Identity` preset
|
||||
|
|
@ -100,9 +110,9 @@ impl Content {
|
|||
/// * action removes previous children component from `Self`
|
||||
pub fn to_status_identity(&self) -> StatusPage {
|
||||
self.clean();
|
||||
let status = status::identity::build((&self.tab_action, &self.item_action));
|
||||
self.g_box.append(&status);
|
||||
status
|
||||
let s = status::identity::build((&self.tab_action, &self.item_action));
|
||||
self.g_box.append(&s);
|
||||
s
|
||||
}
|
||||
|
||||
/// Set new `content::Status` component for `Self` with new `status::Loading` preset
|
||||
|
|
@ -110,9 +120,9 @@ impl Content {
|
|||
/// * action removes previous children component from `Self`
|
||||
pub fn to_status_loading(&self, show_with_delay: Option<Duration>) -> StatusPage {
|
||||
self.clean();
|
||||
let status = status::loading::build(show_with_delay);
|
||||
self.g_box.append(&status);
|
||||
status
|
||||
let s = status::loading::build(show_with_delay);
|
||||
self.g_box.append(&s);
|
||||
s
|
||||
}
|
||||
|
||||
/// `text/gemini`
|
||||
|
|
@ -147,17 +157,17 @@ impl Content {
|
|||
/// `text/plain`
|
||||
pub fn to_text_plain(&self, data: &str) -> Text {
|
||||
self.clean();
|
||||
let text = Text::plain(data);
|
||||
self.g_box.append(&text.scrolled_window);
|
||||
text
|
||||
let t = Text::plain(data);
|
||||
self.g_box.append(&t.scrolled_window);
|
||||
t
|
||||
}
|
||||
|
||||
/// [text/nex](https://nightfall.city/nex/info/specification.txt)
|
||||
pub fn to_text_nex(&self, base: &Uri, data: &str) -> Text {
|
||||
self.clean();
|
||||
let text = Text::nex((&self.window_action, &self.item_action), base, data);
|
||||
self.g_box.append(&text.scrolled_window);
|
||||
text
|
||||
let t = Text::nex((&self.window_action, &self.item_action), base, data);
|
||||
self.g_box.append(&t.scrolled_window);
|
||||
t
|
||||
}
|
||||
|
||||
pub fn to_directory(
|
||||
|
|
@ -172,9 +182,9 @@ impl Content {
|
|||
/// * system `source:`
|
||||
pub fn to_text_source(&self, data: &str) -> Text {
|
||||
self.clean();
|
||||
let text = Text::source(data);
|
||||
self.g_box.append(&text.scrolled_window);
|
||||
text
|
||||
let t = Text::source(data);
|
||||
self.g_box.append(&t.scrolled_window);
|
||||
t
|
||||
}
|
||||
|
||||
/// Remove all children components from `Self`
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@ pub mod failure;
|
|||
pub mod identity;
|
||||
pub mod loading;
|
||||
pub mod mime;
|
||||
pub mod tofu;
|
||||
|
||||
use super::{ItemAction, TabAction};
|
||||
|
|
|
|||
40
src/app/browser/window/tab/item/page/content/status/tofu.rs
Normal file
40
src/app/browser/window/tab/item/page/content/status/tofu.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use adw::StatusPage;
|
||||
use gtk::{
|
||||
Align, Button,
|
||||
prelude::{BoxExt, ButtonExt, WidgetExt},
|
||||
};
|
||||
|
||||
pub fn build(on_accept: impl Fn() + 'static) -> StatusPage {
|
||||
let b = gtk::Box::builder()
|
||||
.halign(Align::Center)
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.spacing(16)
|
||||
.build();
|
||||
|
||||
b.append(>k::Label::builder().selectable(true).use_markup(true).label(
|
||||
"<a href=\"https://geminiprotocol.net/docs/protocol-specification.gmi#tls-server-certificate-validation\" title=\"Gemini protocol specification (HTTP link)\">Read more...</a>"
|
||||
).build());
|
||||
|
||||
b.append(&{
|
||||
let b = Button::builder()
|
||||
.css_classes(["warning"])
|
||||
.label("Accept")
|
||||
.tooltip_text("Add an exception")
|
||||
.halign(Align::Center)
|
||||
.build();
|
||||
|
||||
b.connect_clicked(move |this| {
|
||||
this.set_sensitive(false);
|
||||
on_accept()
|
||||
});
|
||||
|
||||
b
|
||||
});
|
||||
|
||||
StatusPage::builder()
|
||||
.child(&b)
|
||||
.icon_name("security-medium-symbolic")
|
||||
.title("Server certificate has been changed")
|
||||
.description("it could be a man-in-the-middle attack")
|
||||
.build()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue