feat(core): add macOS icon extraction
This commit is contained in:
parent
5a66594532
commit
ca6d04cd0e
|
@ -28,7 +28,13 @@ const WINDOWS_ICO_BINARY: &[u8] = include_bytes!("../../../res/windows/espanso.i
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const WINDOWS_RED_ICO_BINARY: &[u8] = include_bytes!("../../../res/windows/espansored.ico");
|
const WINDOWS_RED_ICO_BINARY: &[u8] = include_bytes!("../../../res/windows/espansored.ico");
|
||||||
|
|
||||||
// TODO: macos
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
const MAC_BINARY: &[u8] = include_bytes!("../../../res/macos/icon.png");
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
const MAC_DISABLED_BINARY: &[u8] = include_bytes!("../../../res/macos/icondisabled.png");
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
const MAC_SYSTEM_DISABLED_BINARY: &[u8] = include_bytes!("../../../res/macos/iconsystemdisabled.png");
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct IconPaths {
|
pub struct IconPaths {
|
||||||
|
@ -54,6 +60,18 @@ pub fn load_icon_paths(runtime_dir: &Path) -> Result<IconPaths> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
pub fn load_icon_paths(runtime_dir: &Path) -> Result<IconPaths> {
|
||||||
|
Ok(IconPaths {
|
||||||
|
search_icon: Some(extract_icon(ICON_BINARY, &runtime_dir.join("search.png"))?),
|
||||||
|
tray_icon_normal: Some(extract_icon(MAC_BINARY, &runtime_dir.join("normal.png"))?),
|
||||||
|
tray_icon_disabled: Some(extract_icon(MAC_DISABLED_BINARY, &runtime_dir.join("disabled.png"))?),
|
||||||
|
tray_icon_system_disabled: Some(extract_icon(MAC_SYSTEM_DISABLED_BINARY, &runtime_dir.join("systemdisabled.png"))?),
|
||||||
|
logo: Some(extract_icon(ICON_BINARY, &runtime_dir.join("icon.png"))?),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn load_icon_paths(runtime_dir: &Path) -> Result<IconPaths> {
|
pub fn load_icon_paths(runtime_dir: &Path) -> Result<IconPaths> {
|
||||||
Ok(IconPaths {
|
Ok(IconPaths {
|
||||||
|
@ -63,8 +81,6 @@ pub fn load_icon_paths(runtime_dir: &Path) -> Result<IconPaths> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: macos
|
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
fn extract_icon(data: &[u8], target_file: &Path) -> Result<PathBuf> {
|
fn extract_icon(data: &[u8], target_file: &Path) -> Result<PathBuf> {
|
||||||
if target_file.exists() {
|
if target_file.exists() {
|
||||||
|
|
BIN
espanso/src/res/macos/iconsystemdisabled.png
Normal file
BIN
espanso/src/res/macos/iconsystemdisabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
Reference in New Issue
Block a user