From 005db1dbf44dbd40e3e91046fc9ad53704332774 Mon Sep 17 00:00:00 2001 From: Albert Armea Date: Sun, 28 Dec 2025 15:39:43 -0500 Subject: [PATCH] Use type-aware fallback icons --- crates/shepherd-launcher-ui/src/tile.rs | 30 +++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/shepherd-launcher-ui/src/tile.rs b/crates/shepherd-launcher-ui/src/tile.rs index 4970e1b..e4b03f6 100644 --- a/crates/shepherd-launcher-ui/src/tile.rs +++ b/crates/shepherd-launcher-ui/src/tile.rs @@ -75,20 +75,26 @@ impl LauncherTile { // Set label imp.label.set_text(&entry.label); - // Set icon + // Determine fallback icon based on entry kind + let fallback_icon = match entry.kind_tag { + shepherd_api::EntryKindTag::Process => "application-x-executable", + shepherd_api::EntryKindTag::Snap => "application-x-executable", + shepherd_api::EntryKindTag::Vm => "computer", + shepherd_api::EntryKindTag::Media => "video-x-generic", + shepherd_api::EntryKindTag::Custom => "applications-other", + }; + + // Set icon, checking if the requested icon exists in the theme if let Some(ref icon_ref) = entry.icon_ref { - // Try to use the icon reference as an icon name - imp.icon.set_icon_name(Some(icon_ref)); + // Check if the icon exists in the default icon theme + let icon_theme = gtk4::IconTheme::for_display(&self.display()); + if icon_theme.has_icon(icon_ref) { + imp.icon.set_icon_name(Some(icon_ref)); + } else { + imp.icon.set_icon_name(Some(fallback_icon)); + } } else { - // Default icon based on entry kind - let icon_name = match entry.kind_tag { - shepherd_api::EntryKindTag::Process => "application-x-executable", - shepherd_api::EntryKindTag::Snap => "application-x-executable", - shepherd_api::EntryKindTag::Vm => "computer", - shepherd_api::EntryKindTag::Media => "video-x-generic", - shepherd_api::EntryKindTag::Custom => "applications-other", - }; - imp.icon.set_icon_name(Some(icon_name)); + imp.icon.set_icon_name(Some(fallback_icon)); } // Entry is available if enabled and has no blocking reasons