mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-08-26 14:32:26 +00:00
apply clippy optimizations
This commit is contained in:
parent
5d3d6d4c7f
commit
adadb149b8
@ -400,8 +400,9 @@ fn update_actions(
|
|||||||
index: &Rc<RefCell<HashMap<TabPage, Rc<Item>>>>,
|
index: &Rc<RefCell<HashMap<TabPage, Rc<Item>>>>,
|
||||||
window_action: &Rc<WindowAction>,
|
window_action: &Rc<WindowAction>,
|
||||||
) {
|
) {
|
||||||
if let Some(tab_page) = tab_page {
|
if let Some(tab_page) = tab_page
|
||||||
if let Some(item) = index.borrow().get(tab_page) {
|
&& let Some(item) = index.borrow().get(tab_page)
|
||||||
|
{
|
||||||
window_action
|
window_action
|
||||||
.home
|
.home
|
||||||
.simple_action
|
.simple_action
|
||||||
@ -426,7 +427,7 @@ fn update_actions(
|
|||||||
window_action.change_state(Some(tab_view.page_position(tab_page)));
|
window_action.change_state(Some(tab_view.page_position(tab_page)));
|
||||||
return;
|
return;
|
||||||
} // @TODO `connect_selected_page_notify` panics on unwrap
|
} // @TODO `connect_selected_page_notify` panics on unwrap
|
||||||
}
|
|
||||||
// Reset to defaults
|
// Reset to defaults
|
||||||
window_action.home.simple_action.set_enabled(false);
|
window_action.home.simple_action.set_enabled(false);
|
||||||
window_action.reload.simple_action.set_enabled(false);
|
window_action.reload.simple_action.set_enabled(false);
|
||||||
|
@ -12,8 +12,9 @@ pub fn format(source_code: &str) -> Vec<(TextTag, String)> {
|
|||||||
let mut tag = Tag::new();
|
let mut tag = Tag::new();
|
||||||
|
|
||||||
for ref entity in source_code.ansi_parse() {
|
for ref entity in source_code.ansi_parse() {
|
||||||
if let Output::Escape(AnsiSequence::SetGraphicsMode(color)) = entity {
|
if let Output::Escape(AnsiSequence::SetGraphicsMode(color)) = entity
|
||||||
if color.len() > 1 {
|
&& color.len() > 1
|
||||||
|
{
|
||||||
if color[0] == 38 {
|
if color[0] == 38 {
|
||||||
tag.text_tag
|
tag.text_tag
|
||||||
.set_foreground_rgba(rgba::default(*color.last().unwrap()).as_ref());
|
.set_foreground_rgba(rgba::default(*color.last().unwrap()).as_ref());
|
||||||
@ -22,7 +23,6 @@ pub fn format(source_code: &str) -> Vec<(TextTag, String)> {
|
|||||||
.set_background_rgba(rgba::default(*color.last().unwrap()).as_ref());
|
.set_background_rgba(rgba::default(*color.last().unwrap()).as_ref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if let Output::TextBlock(text) = entity {
|
if let Output::TextBlock(text) = entity {
|
||||||
buffer.push((tag.text_tag, text.to_string()));
|
buffer.push((tag.text_tag, text.to_string()));
|
||||||
tag = Tag::new();
|
tag = Tag::new();
|
||||||
|
@ -69,8 +69,9 @@ impl Nex for TextView {
|
|||||||
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
|
// it may be confusing: gemini://bbs.geminispace.org/s/nex/29641
|
||||||
if base.to_string().ends_with("/") {
|
if base.to_string().ends_with("/") {
|
||||||
// just borrow ggemtext parser as compatible API
|
// just borrow ggemtext parser as compatible API
|
||||||
if let Some(link) = ggemtext::line::Link::parse(line) {
|
if let Some(link) = ggemtext::line::Link::parse(line)
|
||||||
if let Some(uri) = link.uri(Some(base)) {
|
&& let Some(uri) = link.uri(Some(base))
|
||||||
|
{
|
||||||
let a = TextTag::builder()
|
let a = TextTag::builder()
|
||||||
.foreground_rgba(&link_color.0)
|
.foreground_rgba(&link_color.0)
|
||||||
// .foreground_rgba(&adw::StyleManager::default().accent_color_rgba()) @TODO adw 1.6 / ubuntu 24.10+
|
// .foreground_rgba(&adw::StyleManager::default().accent_color_rgba()) @TODO adw 1.6 / ubuntu 24.10+
|
||||||
@ -96,11 +97,7 @@ impl Nex for TextView {
|
|||||||
&[&a],
|
&[&a],
|
||||||
);
|
);
|
||||||
if let Some(alt) = link.alt {
|
if let Some(alt) = link.alt {
|
||||||
buffer.insert_with_tags(
|
buffer.insert_with_tags(&mut buffer.end_iter(), &format!(" {alt}"), &[&p]);
|
||||||
&mut buffer.end_iter(),
|
|
||||||
&format!(" {alt}"),
|
|
||||||
&[&p],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
buffer.insert(&mut buffer.end_iter(), NEW_LINE);
|
||||||
|
|
||||||
@ -109,7 +106,6 @@ impl Nex for TextView {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Nothing match custom tags above,
|
// Nothing match custom tags above,
|
||||||
// just append plain text covered in empty tag (to handle controller events properly)
|
// just append plain text covered in empty tag (to handle controller events properly)
|
||||||
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&p]);
|
buffer.insert_with_tags(&mut buffer.end_iter(), line, &[&p]);
|
||||||
|
@ -386,8 +386,9 @@ fn is_focused(entry: &Entry) -> bool {
|
|||||||
fn show_identity_dialog(entry: &Entry, profile: &Rc<Profile>) {
|
fn show_identity_dialog(entry: &Entry, profile: &Rc<Profile>) {
|
||||||
// connect identity traits
|
// connect identity traits
|
||||||
use identity::{Common, Unsupported};
|
use identity::{Common, Unsupported};
|
||||||
if let Some(uri) = uri(entry) {
|
if let Some(uri) = uri(entry)
|
||||||
if ["gemini", "titan"].contains(&uri.scheme().as_str()) {
|
&& ["gemini", "titan"].contains(&uri.scheme().as_str())
|
||||||
|
{
|
||||||
return AlertDialog::common(
|
return AlertDialog::common(
|
||||||
profile,
|
profile,
|
||||||
&uri,
|
&uri,
|
||||||
@ -404,7 +405,6 @@ fn show_identity_dialog(entry: &Entry, profile: &Rc<Profile>) {
|
|||||||
)
|
)
|
||||||
.present(Some(entry));
|
.present(Some(entry));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
AlertDialog::unsupported().present(Some(entry));
|
AlertDialog::unsupported().present(Some(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,19 +11,19 @@ pub fn new_for_profile_identity_id(certificate: &TlsCertificate, scope: &[String
|
|||||||
tooltip.push_str(&format!("\n<small><b>issuer</b>\n{issuer_name}</small>"));
|
tooltip.push_str(&format!("\n<small><b>issuer</b>\n{issuer_name}</small>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(not_valid_before) = certificate.not_valid_before() {
|
if let Some(not_valid_before) = certificate.not_valid_before()
|
||||||
if let Ok(timestamp) = not_valid_before.format_iso8601() {
|
&& let Ok(timestamp) = not_valid_before.format_iso8601()
|
||||||
|
{
|
||||||
tooltip.push_str(&format!("\n<small><b>valid after</b>\n{timestamp}</small>"));
|
tooltip.push_str(&format!("\n<small><b>valid after</b>\n{timestamp}</small>"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(not_valid_after) = certificate.not_valid_after() {
|
if let Some(not_valid_after) = certificate.not_valid_after()
|
||||||
if let Ok(timestamp) = not_valid_after.format_iso8601() {
|
&& let Ok(timestamp) = not_valid_after.format_iso8601()
|
||||||
|
{
|
||||||
tooltip.push_str(&format!(
|
tooltip.push_str(&format!(
|
||||||
"\n<small><b>valid before</b>\n{timestamp}</small>"
|
"\n<small><b>valid before</b>\n{timestamp}</small>"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !scope.is_empty() {
|
if !scope.is_empty() {
|
||||||
tooltip.push_str("\n\n<b>Scope</b>\n");
|
tooltip.push_str("\n\n<b>Scope</b>\n");
|
||||||
|
@ -148,11 +148,11 @@ impl Dialog for PreferencesDialog {
|
|||||||
if let Some(iso_code) = c.iso_code {
|
if let Some(iso_code) = c.iso_code {
|
||||||
b.push(iso_code)
|
b.push(iso_code)
|
||||||
}
|
}
|
||||||
if let Some(n) = c.names {
|
if let Some(n) = c.names
|
||||||
if let Some(s) = n.get("en") {
|
&& let Some(s) = n.get("en")
|
||||||
|
{
|
||||||
b.push(s)
|
b.push(s)
|
||||||
} // @TODO multi-lang
|
} // @TODO multi-lang
|
||||||
}
|
|
||||||
// @TODO city DB
|
// @TODO city DB
|
||||||
b.join(", ")
|
b.join(", ")
|
||||||
})
|
})
|
||||||
|
@ -29,7 +29,7 @@ pub enum PrimaryIcon<'a> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from(request: &str) -> PrimaryIcon {
|
pub fn from(request: &str) -> PrimaryIcon<'_> {
|
||||||
let prefix = request.to_lowercase();
|
let prefix = request.to_lowercase();
|
||||||
|
|
||||||
if prefix.starts_with("download:") {
|
if prefix.starts_with("download:") {
|
||||||
|
@ -51,8 +51,9 @@ impl Suggestion {
|
|||||||
let r = resolver.clone();
|
let r = resolver.clone();
|
||||||
let signal_handler_id = signal_handler_id.clone();
|
let signal_handler_id = signal_handler_id.clone();
|
||||||
move |this| {
|
move |this| {
|
||||||
if let Some(selected_item) = this.selected_item() {
|
if let Some(selected_item) = this.selected_item()
|
||||||
if let Some(signal_handler_id) = signal_handler_id.borrow().as_ref() {
|
&& let Some(signal_handler_id) = signal_handler_id.borrow().as_ref()
|
||||||
|
{
|
||||||
super::update_blocked(
|
super::update_blocked(
|
||||||
&p,
|
&p,
|
||||||
&e,
|
&e,
|
||||||
@ -60,7 +61,6 @@ impl Suggestion {
|
|||||||
&selected_item.downcast_ref::<Item>().unwrap().request(),
|
&selected_item.downcast_ref::<Item>().unwrap().request(),
|
||||||
&r,
|
&r,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} // @TODO find signal to handle selected item only
|
} // @TODO find signal to handle selected item only
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user