fix: icon fallback
This commit is contained in:
parent
6d8bb88087
commit
5cb818a5f9
1 changed files with 5 additions and 7 deletions
|
|
@ -54,12 +54,12 @@ impl Named {
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn path(self) -> Option<PathBuf> {
|
pub fn path(self) -> Option<PathBuf> {
|
||||||
let mut name = &*self.name;
|
let name = &*self.name;
|
||||||
let fallback = &self.fallback;
|
let fallback = &self.fallback;
|
||||||
crate::icon_theme::DEFAULT.with(|theme| {
|
crate::icon_theme::DEFAULT.with(|theme| {
|
||||||
let theme = theme.borrow();
|
let theme = theme.borrow();
|
||||||
|
|
||||||
let locate = || {
|
let locate = |name| {
|
||||||
let mut lookup = freedesktop_icons::lookup(name)
|
let mut lookup = freedesktop_icons::lookup(name)
|
||||||
.with_theme(theme.as_ref())
|
.with_theme(theme.as_ref())
|
||||||
.with_cache();
|
.with_cache();
|
||||||
|
|
@ -79,22 +79,20 @@ impl Named {
|
||||||
lookup.find()
|
lookup.find()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result = locate();
|
let mut result = locate(name);
|
||||||
|
|
||||||
// On failure, attempt to locate fallback icon.
|
// On failure, attempt to locate fallback icon.
|
||||||
if result.is_none() {
|
if result.is_none() {
|
||||||
if matches!(fallback, Some(IconFallback::Default)) {
|
if matches!(fallback, Some(IconFallback::Default)) {
|
||||||
for new_name in name.rmatch_indices('-').map(|(pos, _)| &name[..pos]) {
|
for new_name in name.rmatch_indices('-').map(|(pos, _)| &name[..pos]) {
|
||||||
name = new_name;
|
result = locate(new_name);
|
||||||
result = locate();
|
|
||||||
if result.is_some() {
|
if result.is_some() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(IconFallback::Names(fallbacks)) = fallback {
|
} else if let Some(IconFallback::Names(fallbacks)) = fallback {
|
||||||
for fallback in fallbacks {
|
for fallback in fallbacks {
|
||||||
name = fallback;
|
result = locate(fallback);
|
||||||
result = locate();
|
|
||||||
if result.is_some() {
|
if result.is_some() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue