feat(gui): the window carries the package icon (P15 C1)

The taskbar on Windows and X11 shows the same icon the packages carry;
macOS takes it from the bundle and Wayland from the desktop entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 15:55:10 -07:00
1 parent 27f9607434
commit 2b946405cf
2 files changed
+36 -9

No files matched your search

+33 -7
View File
@@ -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<egui::IconData> {
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);
}
}
+3 -2
View File
@@ -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 <id>`.
**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