mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
refactor(image): do not try to read desktop files where definitely not necessary
This commit is contained in:
parent
2367faab04
commit
36f3db7411
1 changed files with 8 additions and 2 deletions
|
@ -50,12 +50,12 @@ impl<'a> ImageProvider<'a> {
|
||||||
/// Returns true if the input starts with a prefix
|
/// Returns true if the input starts with a prefix
|
||||||
/// that is supported by the parser
|
/// that is supported by the parser
|
||||||
/// (ie the parser would not fallback to checking the input).
|
/// (ie the parser would not fallback to checking the input).
|
||||||
#[cfg(any(feature = "music", feature = "workspaces"))]
|
|
||||||
pub fn is_definitely_image_input(input: &str) -> bool {
|
pub fn is_definitely_image_input(input: &str) -> bool {
|
||||||
input.starts_with("icon:")
|
input.starts_with("icon:")
|
||||||
|| input.starts_with("file://")
|
|| input.starts_with("file://")
|
||||||
|| input.starts_with("http://")
|
|| input.starts_with("http://")
|
||||||
|| input.starts_with("https://")
|
|| input.starts_with("https://")
|
||||||
|
|| input.starts_with('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_location(
|
fn get_location(
|
||||||
|
@ -77,6 +77,8 @@ impl<'a> ImageProvider<'a> {
|
||||||
|
|
||||||
const MAX_RECURSE_DEPTH: usize = 2;
|
const MAX_RECURSE_DEPTH: usize = 2;
|
||||||
|
|
||||||
|
let should_parse_desktop_file = !Self::is_definitely_image_input(input);
|
||||||
|
|
||||||
let (input_type, input_name) = input
|
let (input_type, input_name) = input
|
||||||
.split_once(':')
|
.split_once(':')
|
||||||
.map_or((None, input), |(t, n)| (Some(t), n));
|
.map_or((None, input), |(t, n)| (Some(t), n));
|
||||||
|
@ -117,7 +119,7 @@ impl<'a> ImageProvider<'a> {
|
||||||
Some(ImageLocation::Local(PathBuf::from(input_name)))
|
Some(ImageLocation::Local(PathBuf::from(input_name)))
|
||||||
}
|
}
|
||||||
None if recurse_depth == MAX_RECURSE_DEPTH => fallback!(),
|
None if recurse_depth == MAX_RECURSE_DEPTH => fallback!(),
|
||||||
None => {
|
None if should_parse_desktop_file => {
|
||||||
if let Some(location) = get_desktop_icon_name(input_name).map(|input| {
|
if let Some(location) = get_desktop_icon_name(input_name).map(|input| {
|
||||||
Self::get_location(&input, theme, size, use_fallback, recurse_depth + 1)
|
Self::get_location(&input, theme, size, use_fallback, recurse_depth + 1)
|
||||||
}) {
|
}) {
|
||||||
|
@ -127,6 +129,10 @@ impl<'a> ImageProvider<'a> {
|
||||||
fallback!()
|
fallback!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
None => {
|
||||||
|
warn!("Failed to find image: {input}");
|
||||||
|
fallback!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue