From c16f761bc0e00bb4145ea99dfeb36a282af09978 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 21 Sep 2023 13:16:13 +0200 Subject: [PATCH 1/3] app-list: chore: update freedesktop-icons --- cosmic-app-list/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cosmic-app-list/Cargo.toml b/cosmic-app-list/Cargo.toml index 566abbf9..13ce17e2 100644 --- a/cosmic-app-list/Cargo.toml +++ b/cosmic-app-list/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4" tokio = { version = "1.17.0", features = ["sync", "rt", "rt-multi-thread", "macros", "process"] } itertools = "*" freedesktop-desktop-entry = "0.5.0" -freedesktop-icons = "0.2.2" +freedesktop-icons = "0.2.4" i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } i18n-embed-fl = "0.6" rust-embed = "6.3" From 353985170c93f4892b5c259fc1ff32fd8b3aead4 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 21 Sep 2023 13:20:56 +0200 Subject: [PATCH 2/3] app-list: Don't skip DesktopEntry if icon is missing --- cosmic-app-list/src/app.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index 890ad0b4..5499a265 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -264,17 +264,18 @@ fn desktop_info_for_app_ids(mut app_ids: Vec) -> Vec { .iter() .position(|s| s == de.appid || s.eq(&de.name(None).unwrap_or_default())) { - freedesktop_icons::lookup(de.icon().unwrap_or(de.appid)) + let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid)) .with_size(128) .with_cache() - .find() - .map(|buf| DesktopInfo { - id: app_ids.remove(i), - icon: buf, - exec: de.exec().unwrap_or_default().to_string(), - name: de.name(None).unwrap_or_default().to_string(), - path: path.clone(), - }) + .find(); + + Some(DesktopInfo { + id: app_ids.remove(i), + icon: icon.unwrap_or_default(), + exec: de.exec().unwrap_or_default().to_string(), + name: de.name(None).unwrap_or_default().to_string(), + path: path.clone(), + }) } else { None } From d93282c084f5428b7da90f59461ad45dff81ad88 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 21 Sep 2023 13:26:53 +0200 Subject: [PATCH 3/3] app-list: Try to use generic application icon, if icon is missing --- cosmic-app-list/src/app.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index 5499a265..91aa1e36 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -254,6 +254,14 @@ struct DesktopInfo { 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) -> Vec { let app_ids_clone = app_ids.clone(); 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) -> Vec { let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid)) .with_size(128) .with_cache() - .find(); + .find() + .unwrap_or_else(default_app_icon); Some(DesktopInfo { id: app_ids.remove(i), - icon: icon.unwrap_or_default(), + icon, exec: de.exec().unwrap_or_default().to_string(), name: de.name(None).unwrap_or_default().to_string(), path: path.clone(), @@ -288,6 +297,7 @@ fn desktop_info_for_app_ids(mut app_ids: Vec) -> Vec { .into_iter() .map(|id| DesktopInfo { id, + icon: default_app_icon(), ..Default::default() }) .collect_vec(), @@ -604,17 +614,18 @@ impl cosmic::Application for CosmicAppList { DesktopEntry::decode(&file_path, &input) .ok() .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_cache() .find() - .map(|buf| DesktopInfo { - id: de.id().to_string(), - icon: buf, - exec: de.exec().unwrap_or_default().to_string(), - name: de.name(None).unwrap_or_default().to_string(), - path: file_path.clone(), - }) + .unwrap_or_else(default_app_icon); + Some(DesktopInfo { + id: de.id().to_string(), + icon, + exec: de.exec().unwrap_or_default().to_string(), + name: de.name(None).unwrap_or_default().to_string(), + path: file_path.clone(), + }) }) }) { self.item_ctr += 1;