diff --git a/Cargo.lock b/Cargo.lock index 793c38b..2550644 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,7 +1071,7 @@ dependencies = [ [[package]] name = "cosmic-text" version = "0.12.1" -source = "git+https://github.com/pop-os/cosmic-text.git#e8f567cf5b456dfab749a575c257acaa36f622d9" +source = "git+https://github.com/pop-os/cosmic-text.git#4fe90bb6126c22f589b46768d7754d65ae300c5e" dependencies = [ "bitflags 2.6.0", "fontdb 0.16.2", @@ -2087,7 +2087,7 @@ dependencies = [ [[package]] name = "iced" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "dnd", "iced_accessibility", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "accesskit", "accesskit_winit", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "bitflags 2.6.0", "bytes", @@ -2138,7 +2138,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "async-std", "futures", @@ -2152,7 +2152,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2185,7 +2185,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "bytes", "dnd", @@ -2200,7 +2200,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "bytemuck", "cosmic-text", @@ -2216,7 +2216,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -2246,7 +2246,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "dnd", "iced_renderer", @@ -2263,7 +2263,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.13.0" -source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#f9a9f38ec526ea61b5cd9b1dc424d8874d3dab5d" +source = "git+https://github.com/pop-os/iced?branch=ashley-rebase-0.13#8f3b61e635e325cf013e3f112ed41b4cbc654fb0" dependencies = [ "dnd", "iced_futures", @@ -3298,9 +3298,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "png" @@ -4102,18 +4102,18 @@ checksum = "7f1835c76a9d443834c04539860f3ce46b9d93ef8c260057f939e967ca81180a" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", diff --git a/src/freedesktop/icons.rs b/src/freedesktop/icons.rs index ad194dd..69e0392 100644 --- a/src/freedesktop/icons.rs +++ b/src/freedesktop/icons.rs @@ -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 { + freedesktop_icons::lookup(icon) + .with_theme(&self.to_string()) + .with_cache() + .find() + } +} + pub fn default_icon_path(theme: &IconTheme) -> Option { 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 { 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 { + 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!(), + } +} diff --git a/src/settings_tray/status_icons.rs b/src/settings_tray/status_icons.rs index 562246a..91a05ba 100644 --- a/src/settings_tray/status_icons.rs +++ b/src/settings_tray/status_icons.rs @@ -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; @@ -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() } }