diff --git a/src/components.rs b/src/components.rs index d40ff48..eb301b0 100644 --- a/src/components.rs +++ b/src/components.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; use iced::{ widget::{column, Container}, @@ -64,24 +64,3 @@ pub fn app_icon<'a, T>(icon_path: &Path) -> iced::Element<'a, T> { ) } } - -pub fn default_icon_path() -> PathBuf { - freedesktop_icons::lookup("wayland") - .with_theme("breeze") - .with_cache() - .find() - .unwrap() -} - -pub fn start_menu_icon() -> Option { - freedesktop_icons::lookup("applications-all") - .with_theme("breeze") - .with_cache() - .find() - .or_else(|| { - freedesktop_icons::lookup("applications-office") - .with_theme("Cosmic") - .with_cache() - .find() - }) -} diff --git a/src/desktop_entry.rs b/src/desktop_entry.rs index 593e4dd..e1d04d4 100644 --- a/src/desktop_entry.rs +++ b/src/desktop_entry.rs @@ -26,46 +26,10 @@ impl<'a> EntryInfo<'a> { } else { desktop_entry.icon().and_then(|icon| { freedesktop_icons::lookup(icon) - .force_svg() + .with_theme("hicolor") .with_cache() .find() - .or_else(|| { - freedesktop_icons::lookup(icon) - .with_size(512) - .with_cache() - .find() - }) - .or_else(|| { - freedesktop_icons::lookup(icon) - .with_size(256) - .with_cache() - .find() - }) - .or_else(|| { - freedesktop_icons::lookup(icon) - .with_size(128) - .with_cache() - .find() - }) - .or_else(|| { - freedesktop_icons::lookup(icon) - .with_size(96) - .with_cache() - .find() - }) - .or_else(|| { - freedesktop_icons::lookup(icon) - .with_size(64) - .with_cache() - .find() - }) - .or_else(|| { - freedesktop_icons::lookup(icon) - .with_size(48) - .with_cache() - .find() - }) - .or_else(|| freedesktop_icons::lookup(icon).with_cache().find()) + .or_else(default_icon_path) }) }; Self { @@ -125,3 +89,23 @@ impl<'a> DesktopEntryCache<'a> { .cloned() // TODO: Can I make this more efficient? } } + +pub fn default_icon_path() -> Option { + freedesktop_icons::lookup("wayland") + .with_theme("breeze") + .with_cache() + .find() +} + +pub fn start_menu_icon() -> Option { + freedesktop_icons::lookup("applications-all") + .with_theme("breeze") + .with_cache() + .find() + .or_else(|| { + freedesktop_icons::lookup("applications-office") + .with_theme("Cosmic") + .with_cache() + .find() + }) +} diff --git a/src/panel.rs b/src/panel.rs index feb86b1..8cab9db 100644 --- a/src/panel.rs +++ b/src/panel.rs @@ -38,7 +38,7 @@ pub enum PopupType { StartMenu, } -const USE_WINIT: bool = false; // For testing. {true=winit, false=layer_shell} +const USE_WINIT: bool = true; // For testing. {true=winit, false=layer_shell} impl<'a> Panel<'a> { pub fn new(config: PanelConfig) -> (Self, Task) { diff --git a/src/settings_tray/status_icons.rs b/src/settings_tray/status_icons.rs index 5348584..47b86a6 100644 --- a/src/settings_tray/status_icons.rs +++ b/src/settings_tray/status_icons.rs @@ -1,4 +1,4 @@ -use crate::components::{app_icon, default_icon_path}; +use crate::{components::app_icon, desktop_entry::default_icon_path}; use super::SettingsTrayMessage; @@ -15,7 +15,7 @@ impl StatusIcons { .with_theme("AdwaitaLegacy") .with_cache() .find() - .unwrap_or(default_icon_path()); - iced::widget::row![app_icon(&icon_path)].into() + .or_else(default_icon_path); + iced::widget::row![app_icon(&icon_path.unwrap())].into() } } diff --git a/src/start_menu/mod.rs b/src/start_menu/mod.rs index 934bebe..636b208 100644 --- a/src/start_menu/mod.rs +++ b/src/start_menu/mod.rs @@ -12,8 +12,8 @@ use iced::{ use crate::{ component_theme::{button_style, PANEL_SIZE}, - components::{app_icon, app_tray_button, start_menu_icon}, - desktop_entry::{DesktopEntryCache, EntryInfo}, + components::{app_icon, app_tray_button}, + desktop_entry::{start_menu_icon, DesktopEntryCache, EntryInfo}, }; #[derive(Clone, Debug)]