Skip to content

Commit

Permalink
Fallback wayland icon on KDE, more various improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
  • Loading branch information
ryanabx committed Sep 22, 2024
1 parent ab0b843 commit 0057c70
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 66 deletions.
23 changes: 1 addition & 22 deletions src/components.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::{Path, PathBuf};
use std::path::Path;

use iced::{
widget::{column, Container},
Expand Down Expand Up @@ -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<PathBuf> {
freedesktop_icons::lookup("applications-all")
.with_theme("breeze")
.with_cache()
.find()
.or_else(|| {
freedesktop_icons::lookup("applications-office")
.with_theme("Cosmic")
.with_cache()
.find()
})
}
60 changes: 22 additions & 38 deletions src/desktop_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -125,3 +89,23 @@ impl<'a> DesktopEntryCache<'a> {
.cloned() // TODO: Can I make this more efficient?
}
}

pub fn default_icon_path() -> Option<PathBuf> {
freedesktop_icons::lookup("wayland")
.with_theme("breeze")
.with_cache()
.find()
}

pub fn start_menu_icon() -> Option<PathBuf> {
freedesktop_icons::lookup("applications-all")
.with_theme("breeze")
.with_cache()
.find()
.or_else(|| {
freedesktop_icons::lookup("applications-office")
.with_theme("Cosmic")
.with_cache()
.find()
})
}
2 changes: 1 addition & 1 deletion src/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Message>) {
Expand Down
6 changes: 3 additions & 3 deletions src/settings_tray/status_icons.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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()
}
}
4 changes: 2 additions & 2 deletions src/start_menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 0057c70

Please sign in to comment.