Use type-aware fallback icons

This commit is contained in:
Albert Armea 2025-12-28 15:39:43 -05:00
parent fb7503eeb4
commit 005db1dbf4

View file

@ -75,20 +75,26 @@ impl LauncherTile {
// Set label // Set label
imp.label.set_text(&entry.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 { if let Some(ref icon_ref) = entry.icon_ref {
// Try to use the icon reference as an icon name // Check if the icon exists in the default icon theme
imp.icon.set_icon_name(Some(icon_ref)); 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 { } else {
// Default icon based on entry kind imp.icon.set_icon_name(Some(fallback_icon));
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));
} }
// Entry is available if enabled and has no blocking reasons // Entry is available if enabled and has no blocking reasons