diff --git a/crates/ledger-gui/src/lib.rs b/crates/ledger-gui/src/lib.rs index d02612d2..b9c1eec9 100644 --- a/crates/ledger-gui/src/lib.rs +++ b/crates/ledger-gui/src/lib.rs @@ -138,14 +138,21 @@ pub fn run( }, }, }; + let mut viewport = egui::ViewportBuilder::default() + .with_title("Wanderbooks") + .with_app_id("wanderbooks") + .with_inner_size([1440.0, 920.0]) + // Small on purpose: tiling window managers hand out small slots + // regardless, and every screen lays itself out to fit. + .with_min_inner_size([360.0, 400.0]); + // The window's own icon (the taskbar on Windows, X11): the packages' + // icon. macOS takes its icon from the app bundle, Wayland from the + // desktop entry; a failure to decode leaves the system's default. + if let Some(icon) = window_icon() { + viewport = viewport.with_icon(std::sync::Arc::new(icon)); + } let options = eframe::NativeOptions { - viewport: egui::ViewportBuilder::default() - .with_title("Wanderbooks") - .with_app_id("wanderbooks") - .with_inner_size([1440.0, 920.0]) - // Small on purpose: tiling window managers hand out small slots - // regardless, and every screen lays itself out to fit. - .with_min_inner_size([360.0, 400.0]), + viewport, // The platform's place for app settings, never the books' folder // (prefs.rs). persistence_path: prefs::prepare(), @@ -201,3 +208,22 @@ mod exit_tests { assert_eq!(Exit(1).to_string(), "exit code 1"); } } + +/// The icon every package carries (`deploy/packaging/icons`), as the window's +/// own (WB-pkg-6). +fn window_icon() -> Option { + eframe::icon_data::from_png_bytes(include_bytes!( + "../../../deploy/packaging/icons/512x512.png" + )) + .ok() +} + +#[cfg(test)] +mod window_icon_tests { + #[test] + fn the_windows_icon_is_the_packages_icon() { + let icon = super::window_icon().expect("the icon decodes"); + assert_eq!((icon.width, icon.height), (512, 512)); + assert_eq!(icon.rgba.len(), 512 * 512 * 4); + } +} diff --git a/docs/packaging.md b/docs/packaging.md index 730c9a6f..3cfb437c 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -314,8 +314,9 @@ unsigned (macOS: ad hoc, so it runs, but Gatekeeper refuses a download). Connect page's button; it runs the installed program as `mcp --book `. **Left out, on purpose:** an auto-installer; a Windows executable icon resource -(the shortcut and the uninstaller entry carry the icon; the running window uses -the system's default) and the window's own icon on Windows and Linux X11; +(the shortcut and the uninstaller entry carry the icon, and the running window +sets its own from the 512 px PNG; Explorer shows the `.exe` with the default +icon); `wanderbooks.cmd`/PATH setup so a terminal waits for a command on Windows (a GUI-subsystem program returns the prompt at once); a macOS refusal for a program run from a mounted disk image (a path under `/Volumes` may be a real install on