app-list: Try to use generic application icon, if icon is missing
This commit is contained in:
parent
353985170c
commit
d93282c084
1 changed files with 21 additions and 10 deletions
|
|
@ -254,6 +254,14 @@ struct DesktopInfo {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_app_icon() -> PathBuf {
|
||||||
|
freedesktop_icons::lookup("application-default")
|
||||||
|
.with_size(128)
|
||||||
|
.with_cache()
|
||||||
|
.find()
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
fn desktop_info_for_app_ids(mut app_ids: Vec<String>) -> Vec<DesktopInfo> {
|
fn desktop_info_for_app_ids(mut app_ids: Vec<String>) -> Vec<DesktopInfo> {
|
||||||
let app_ids_clone = app_ids.clone();
|
let app_ids_clone = app_ids.clone();
|
||||||
let mut ret = freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
|
let mut ret = freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
|
||||||
|
|
@ -267,11 +275,12 @@ fn desktop_info_for_app_ids(mut app_ids: Vec<String>) -> Vec<DesktopInfo> {
|
||||||
let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
|
let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
|
||||||
.with_size(128)
|
.with_size(128)
|
||||||
.with_cache()
|
.with_cache()
|
||||||
.find();
|
.find()
|
||||||
|
.unwrap_or_else(default_app_icon);
|
||||||
|
|
||||||
Some(DesktopInfo {
|
Some(DesktopInfo {
|
||||||
id: app_ids.remove(i),
|
id: app_ids.remove(i),
|
||||||
icon: icon.unwrap_or_default(),
|
icon,
|
||||||
exec: de.exec().unwrap_or_default().to_string(),
|
exec: de.exec().unwrap_or_default().to_string(),
|
||||||
name: de.name(None).unwrap_or_default().to_string(),
|
name: de.name(None).unwrap_or_default().to_string(),
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
|
|
@ -288,6 +297,7 @@ fn desktop_info_for_app_ids(mut app_ids: Vec<String>) -> Vec<DesktopInfo> {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|id| DesktopInfo {
|
.map(|id| DesktopInfo {
|
||||||
id,
|
id,
|
||||||
|
icon: default_app_icon(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.collect_vec(),
|
.collect_vec(),
|
||||||
|
|
@ -604,17 +614,18 @@ impl cosmic::Application for CosmicAppList {
|
||||||
DesktopEntry::decode(&file_path, &input)
|
DesktopEntry::decode(&file_path, &input)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|de| {
|
.and_then(|de| {
|
||||||
freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
|
let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
|
||||||
.with_size(128)
|
.with_size(128)
|
||||||
.with_cache()
|
.with_cache()
|
||||||
.find()
|
.find()
|
||||||
.map(|buf| DesktopInfo {
|
.unwrap_or_else(default_app_icon);
|
||||||
id: de.id().to_string(),
|
Some(DesktopInfo {
|
||||||
icon: buf,
|
id: de.id().to_string(),
|
||||||
exec: de.exec().unwrap_or_default().to_string(),
|
icon,
|
||||||
name: de.name(None).unwrap_or_default().to_string(),
|
exec: de.exec().unwrap_or_default().to_string(),
|
||||||
path: file_path.clone(),
|
name: de.name(None).unwrap_or_default().to_string(),
|
||||||
})
|
path: file_path.clone(),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}) {
|
}) {
|
||||||
self.item_ctr += 1;
|
self.item_ctr += 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue