From 594149e2d4894f971392044a42fc940bffbdc4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Sun, 25 Sep 2022 16:57:30 +0200 Subject: [PATCH] Deduplicate and simplify app icon handling --- lapce-ui/src/app.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/lapce-ui/src/app.rs b/lapce-ui/src/app.rs index 507af42f..0048afde 100644 --- a/lapce-ui/src/app.rs +++ b/lapce-ui/src/app.rs @@ -22,11 +22,6 @@ use crate::{logging::override_log_levels, tab::LAPCE_TAB_META}; use crate::{tab::LapceTabHeader, window::LapceWindow}; -#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] -const LOGO_PNG: &[u8] = include_bytes!("../../extra/images/logo.png"); -#[cfg(target_os = "windows")] -const LOGO_ICO: &[u8] = include_bytes!("../../extra/windows/lapce.ico"); - #[derive(Parser)] #[clap(name = "Lapce")] #[clap(version=*VERSION)] @@ -179,19 +174,15 @@ fn window_icon() -> Option { None } -#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] +#[cfg(not(target_os = "macos"))] fn window_icon() -> Option { - let image = image::load_from_memory(LOGO_PNG) - .expect("Invalid Icon") - .into_rgba8(); - let (width, height) = image.dimensions(); - let rgba = image.into_raw(); - Some(druid::Icon::from_rgba(rgba, width, height).expect("Failed to open icon")) -} + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] + const LOGO: &[u8] = include_bytes!("../../extra/images/logo.png"); -#[cfg(target_os = "windows")] -fn window_icon() -> Option { - let image = image::load_from_memory(LOGO_ICO) + #[cfg(target_os = "windows")] + const LOGO: &[u8] = include_bytes!("../../extra/windows/lapce.ico"); + + let image = image::load_from_memory(LOGO) .expect("Invalid Icon") .into_rgba8(); let (width, height) = image.dimensions();