Skip to content

Commit

Permalink
cargo update, icons changes, etc.
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 24, 2024
1 parent fa083bf commit ee59f8d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 40 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 35 additions & 16 deletions src/freedesktop/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,49 @@ impl Default for IconTheme {
}
}

impl IconTheme {
fn to_string(&self) -> String {
match self {
IconTheme::Breeze => "breeze".to_string(),
IconTheme::Cosmic => "Cosmic".to_string(),
IconTheme::None => "hicolor".to_string(),
}
}

fn lookup(&self, icon: &str) -> Option<PathBuf> {
freedesktop_icons::lookup(icon)
.with_theme(&self.to_string())
.with_cache()
.find()
}
}

pub fn default_icon_path(theme: &IconTheme) -> Option<PathBuf> {
match theme {
IconTheme::Breeze => freedesktop_icons::lookup("wayland")
.with_theme("breeze")
.with_cache()
.find(),
IconTheme::Cosmic => freedesktop_icons::lookup("application-default")
.with_theme("Cosmic")
.with_cache()
.find(),
IconTheme::Breeze => theme.lookup("wayland"),
IconTheme::Cosmic => theme.lookup("application-default"),
IconTheme::None => None,
}
}

pub fn start_menu_icon(theme: &IconTheme) -> Option<PathBuf> {
match theme {
IconTheme::Breeze => freedesktop_icons::lookup("applications-all")
.with_theme("breeze")
.with_cache()
.find(),
IconTheme::Cosmic => freedesktop_icons::lookup("applications-office")
.with_theme("Cosmic")
.with_cache()
.find(),
IconTheme::Breeze => theme.lookup("applications-all"),
IconTheme::Cosmic => theme.lookup("applications-office"),
IconTheme::None => None,
}
}

pub fn network_icon(theme: &IconTheme, strength: f32) -> Option<PathBuf> {
match theme {
IconTheme::Breeze => {
if strength > 0.9 {
theme.lookup("network-wireless-100")
} else {
theme.lookup("network-wireless-40")
}
}
IconTheme::Cosmic => todo!(),
IconTheme::None => todo!(),
}
}
8 changes: 2 additions & 6 deletions src/settings_tray/status_icons.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
design::components::app_icon,
freedesktop::icons::{default_icon_path, IconTheme, ImageHandle},
freedesktop::icons::{default_icon_path, network_icon, IconTheme, ImageHandle},
};

use super::SettingsTrayMessage;
Expand All @@ -14,11 +14,7 @@ impl StatusIcons {
}

pub fn view(&self, icon_theme: &IconTheme) -> iced::Element<'static, SettingsTrayMessage> {
let icon_path = freedesktop_icons::lookup("network-wireless")
.with_theme("AdwaitaLegacy")
.with_cache()
.find()
.or_else(|| default_icon_path(icon_theme));
let icon_path = network_icon(icon_theme, 1.0);
iced::widget::row![app_icon(ImageHandle::from_path(&icon_path.unwrap()))].into()
}
}

0 comments on commit ee59f8d

Please sign in to comment.