fix(desktop_entries): respect NoDisplay precedence
Closes: pop-os/cosmic-epoch#905 `NoDisplay` allows applications or users to signal that an entry shouldn't be shown in menus. This is useful for entries that may launch an app in a certain way such as opening a specific menu or handling a MIME type. Some desktop environments use it to signal special cases. `NoDisplay` as well as `Hidden` allow user defined entries to hide apps. User defined desktop entries should override the system's applications, but the old logic continued parsing entries from all locations instead of stopping at a user override.
This commit is contained in:
parent
6a1b8b9ad0
commit
8cc0d28402
1 changed files with 14 additions and 6 deletions
|
|
@ -76,9 +76,15 @@ impl<W: AsyncWrite + Unpin> App<W> {
|
||||||
let desktop_entries = DesktopEntry::from_paths(paths, &locales)
|
let desktop_entries = DesktopEntry::from_paths(paths, &locales)
|
||||||
.filter_map(|de| {
|
.filter_map(|de| {
|
||||||
de.ok().and_then(|de| {
|
de.ok().and_then(|de| {
|
||||||
if deduplicator.contains(de.appid.as_ref()) {
|
// Treat Flatpak and system apps differently in the cache so they don't
|
||||||
|
// override each other
|
||||||
|
let appid = de.flatpak().unwrap_or_else(|| de.appid.as_ref());
|
||||||
|
if deduplicator.contains(appid) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
// Always cache already visited entries to allow overriding entries e.g. by
|
||||||
|
// placing a modified copy in ~/.local/share/applications/
|
||||||
|
deduplicator.insert(appid.to_owned());
|
||||||
|
|
||||||
if de.name(&self.locales).is_none() {
|
if de.name(&self.locales).is_none() {
|
||||||
return None;
|
return None;
|
||||||
|
|
@ -128,12 +134,14 @@ impl<W: AsyncWrite + Unpin> App<W> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if de.no_display() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
deduplicator.insert(de.appid.to_string());
|
// Treat `OnlyShowIn` as an override otherwise do not show if `NoDisplay` is true
|
||||||
|
// Some desktop environments set `OnlyShowIn` and `NoDisplay = true` to
|
||||||
|
// indicate special entries
|
||||||
|
else if de.no_display() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
Some(de)
|
Some(de)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue