mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-29 20:47:32 -06:00
app icon: lion (owner's ArtCraft drawing), Dock/taskbar/launcher wiring, palette docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
03fca33d10
commit
1f2e267f32
@@ -13,3 +13,7 @@ printcraft-ui-egui = { workspace = true }
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "wayland", "x11", "persistence", "links"] }
|
||||
egui = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
# Icon + VERSIONINFO for printcraft.exe; build.rs only uses it when targeting Windows.
|
||||
winresource = "0.1"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//! Windows only: embed the app icon and version info (VERSIONINFO) into `printcraft.exe`, so it
|
||||
//! shows in Explorer, the taskbar, the Start menu and Alt-Tab.
|
||||
//!
|
||||
//! On every other target this does nothing. A missing resource compiler is a warning, so a
|
||||
//! cross-compile from macOS or Linux still links, unless `PRINTCRAFT_REQUIRE_WINRES=1` turns it
|
||||
//! into an error (for release builds).
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=../../assets/app-icon/printcraft.ico");
|
||||
println!("cargo:rerun-if-env-changed=PRINTCRAFT_REQUIRE_WINRES");
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
|
||||
return;
|
||||
}
|
||||
let mut res = winresource::WindowsResource::new();
|
||||
res.set_icon("../../assets/app-icon/printcraft.ico")
|
||||
.set("ProductName", "PrintCraft")
|
||||
.set("FileDescription", "PrintCraft PDF workbench")
|
||||
.set("LegalCopyright", "Copyright (c) the PrintCraft contributors. MIT OR Apache-2.0.")
|
||||
.set("OriginalFilename", "printcraft.exe")
|
||||
.set("InternalName", "printcraft");
|
||||
if let Err(e) = res.compile() {
|
||||
if std::env::var_os("PRINTCRAFT_REQUIRE_WINRES").is_some() {
|
||||
panic!("embedding Windows resources failed: {e}");
|
||||
}
|
||||
println!("cargo:warning=printcraft.exe built without icon/version resources: {e}");
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,16 @@
|
||||
|
||||
use printcraft_ui_egui::PrintCraftApp;
|
||||
|
||||
/// Freedesktop app id: the `.desktop` file name and the hicolor icon name.
|
||||
const APP_ID: &str = "ai.storyteller.printcraft";
|
||||
|
||||
/// The app icon (assets/app-icon/README.md). macOS gets the version on Apple's icon grid, with a
|
||||
/// transparent margin; Windows and Linux get the full-bleed tile.
|
||||
#[cfg(target_os = "macos")]
|
||||
const APP_ICON_PNG: &[u8] = include_bytes!("../../../assets/app-icon/printcraft-1024.png");
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
const APP_ICON_PNG: &[u8] = include_bytes!("../../../assets/app-icon/hicolor/256x256/apps/ai.storyteller.printcraft.png");
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
let mut files = Vec::new();
|
||||
let mut options: Vec<(String, String)> = Vec::new();
|
||||
@@ -37,11 +47,20 @@ fn main() -> eframe::Result {
|
||||
.with_title("PrintCraft")
|
||||
.with_inner_size([1440.0, 920.0])
|
||||
.with_min_inner_size([820.0, 520.0])
|
||||
.with_drag_and_drop(true);
|
||||
.with_drag_and_drop(true)
|
||||
// Wayland app id: matches packaging/linux/ai.storyteller.printcraft.desktop.
|
||||
.with_app_id(APP_ID);
|
||||
// Dock, taskbar, Alt-Tab and launcher icon when running unbundled.
|
||||
match eframe::icon_data::from_png_bytes(APP_ICON_PNG) {
|
||||
Ok(icon) => viewport = viewport.with_icon(icon),
|
||||
Err(e) => eprintln!("printcraft: app icon: {e}"),
|
||||
}
|
||||
if integrated {
|
||||
viewport = viewport.with_fullsize_content_view(true).with_titlebar_shown(false).with_title_shown(false);
|
||||
}
|
||||
let native = eframe::NativeOptions { viewport, ..Default::default() };
|
||||
// eframe would otherwise derive the settings folder from the app id: keep it under "PrintCraft".
|
||||
let persistence_path = eframe::storage_dir("PrintCraft").map(|d| d.join("app.ron"));
|
||||
let native = eframe::NativeOptions { viewport, persistence_path, ..Default::default() };
|
||||
eframe::run_native(
|
||||
"PrintCraft",
|
||||
native,
|
||||
|
||||
Reference in New Issue
Block a user