Repository navigation
web: print straight to the system print dialog, not just export - #66
Dejan-Port wants to merge 3 commits into
Conversation
DeckCraft has no file.print command and no Print entry anywhere in the UI — only Export…, which always writes a file. This adds a print path that goes straight to the browser's native print dialog: - Services::print (web-only hook, PDF bytes in -> system print dialog) - SlideApp::print_now(), building the PDF via the engine's cmd::file::pdf_bytes (the same lowest-level function export already uses) and handing the bytes to the hook - Ctrl/Cmd+P wired in ui_shortcut (doesn't collide with the existing Ctrl+Shift+P command palette shortcut) - a Print… entry in the File menu, after Export… - the web runner's print service: PDF bytes -> Blob -> object URL -> hidden iframe -> iframe.contentWindow().print() once it has loaded Mirrors the same feature already added to WordCraft (storytold/wordcraft#209) and GridCraft (storytold/gridcraft#143). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DeckCraft had no File-tab equivalent at all — only a hamburger-style File menu entry (used for the native macOS menu bar) and a separate Home/start screen, with no single place mirroring Word's or Excel's backstage view. This adds a File tab (first in the ribbon, like real PowerPoint) that opens a full-screen backstage panel: - New (blank presentation + recents) - Open (browse… + recents) - Save / Save As (run immediately, same as the title bar's Save button) - Print (the system print dialog added earlier on this branch) - Export (opens the existing Export dialog, same formats as before) - About The panel is filled with PowerPoint's red (0xB7272C), fixed regardless of light/dark mode — the same treatment WordCraft's backstage gives its blue and the matching addition gives GridCraft's green. Builds on this branch's existing print commit; no behavior changes to anything outside the new File tab and backstage module. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Pushed a second commit here: a File tab + full backstage panel (New/Open/Save/Print/Export/About), filled with PowerPoint's red, mirroring WordCraft's blue backstage (storytold/wordcraft#209) and the matching one just added to GridCraft (storytold/gridcraft#143). DeckCraft had no File-tab equivalent at all before this, so it seemed natural to land alongside the print feature rather than as a separate PR, since Print is one of its pages. 🤖 Generated with Claude Code |
Same shape as storytold/wordcraft#250 and storytold/gridcraft#143's most recent commit: DeckCraft had no localization at all, so this adds a catalog-based i18n system (crates/ui-egui/src/i18n — generic, ported with only the env var and a doc-comment product name changed) plus Serbian in both scripts. - lib.rs: a `tl!` macro, an `i18n` module, a persisted `language` setting (default: follow the OS), `i18n::set_current` once per frame. - Translation at a few high-leverage points rather than per call site: `big_button`/`big_button_ex`/`small_button`/`small_button_ex`/ `icon_toggle`/`color_split`/`color_grid`/`section`/`drop_button` in widgets.rs translate their own label/tip, so every ribbon caller picks it up for free. `dialogs.rs`'s `title()` (every dialog window title goes through one match statement), `buttons()` (OK/Cancel), `field()` and `check()` (the generic field renderers used by most of the simple dialogs) do the same. The 19 remaining hardcoded `.on_hover_text("...")` call sites in ribbon.rs/credits.rs (DeckCraft attaches tooltips to the Response after the widget call, unlike GridCraft's widgets which take a `tip` param directly, so these couldn't be swept up the same way) are wrapped individually. Title bar, ribbon tab names and the File backstage are translated directly where they're drawn. The backstage gets a new Options page with the language picker. - 216 strings, clean-room translated into Serbian Latin (sr-latn.tsv), then mechanically transliterated into Cyrillic (sr.tsv). - 11 tests: locale matching, catalog well-formedness (including that a translation's leading/trailing whitespace matches its English source's — DeckCraft has a couple of intentionally-indented field labels, unlike WordCraft/GridCraft, so the stricter blanket check those two use doesn't fit here), full key-set parity between scripts, and font glyph coverage checked against the actual bytes of egui's bundled default font (Ubuntu-Light) for both Cyrillic and Serbian Latin's š č ć ž đ — DeckCraft's own fonts (deckcraft-fonts) only embed real files with CRAFT_FONTS_DIR set at build time, which wasn't available building this. Scope: ribbon, dialog titles/fields/buttons, File backstage. Several dialog bodies (table/chart data editors, SmartArt picker, equation editor) draw bespoke UI outside the shared helpers and aren't covered yet. Missing entries just show in English, so this is safe to land incrementally. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Pushed one more commit: an interface-language system with Serbian, both scripts ( DeckCraft had zero localization before this. Translation happens at a few high-leverage points rather than at each of the hundreds of call sites: the shared ribbon widgets ( 216 strings, clean-room translated, then mechanically transliterated into Cyrillic. 11 tests, including one that checks actual font bytes — DeckCraft's own fonts only embed real files with Scope, stated plainly: ribbon, dialog titles/fields/buttons, File backstage. A few dialog bodies (table/chart data editors, the SmartArt picker, the equation editor) draw bespoke UI outside the shared helpers and aren't covered yet — a string without a translation just shows in English, so more coverage can land incrementally. 🤖 Generated with Claude Code |
Windows on ARM64: release builds, tested on ARM64 hardware (storytold#61)
It was only for finding the WARP crash (fixed in the previous commit) and was merged with storytold#66 by accident; it ran a 60-iteration crash-dump loop and edited the runner's registry on every push. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR conflicts with main ( The branch has three commits, and the title and description cover only the first:
What I found against current main:
On the web print code itself: it builds a Blob and object URL, appends a hidden Suggestion: split commit 1 into its own PR rebased on main, wired into |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: the web build prints straight to the system print dialog and does not only export. The lock gains sys-locale 0.3.2 and ttf-parser, the first for the interface language mechanism that six other deckcraft PRs also add (deckcraft#555, #543, #548, #575, #579, #538) and the second for reading fonts. A print path in the browser normally goes through an iframe or a hidden document and window.print(), which needs the page to be laid out at the paper size and fonts to be loaded; the PR should say how fonts are made available to the print layout. A language-selection dependency in a printing PR is unrelated and should be its own PR. ttf-parser parses untrusted fonts and needs bounds. I read the lock hunks. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
aiongg
left a comment
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
Significant problems found:
The branch adds a web print path through a hidden iframe, a File backstage and an interface-language system with Serbian catalogs. The default branch already has File › Print, Ctrl+P and a print path, so most of this overlaps existing code.
- The default branch already has a File tab with a Print page (crates/ui-egui/src/backstage.rs,
mod print), Ctrl+P (crates/ui-egui/src/menus.rs:45) andSlideApp::print_pdf(crates/ui-egui/src/app/files.rs:262). The new backstage.rs would replace that richer page with a smaller one. - The description covers only printing, but the branch also adds a File backstage and a full interface-language system with Serbian catalogs plus the
sys-localeandttf-parserdependencies. Each of these is its own topic. print_now(crates/ui-egui/src/lib.rs) does nothing whenservices.printis None, which is the case on desktop. Ctrl+P and File › Print… build the PDF and then drop it with no status message.print_pdfin apps/deckcraft-web/src/web.rs appends a new hidden iframe and object URL on every print and never removes them, so repeated prints keep accumulating blobs.- The hidden-iframe print could be a useful small change on its own: today the default branch's web branch of
print_pdf(crates/ui-egui/src/app/files.rs:265-268) downloads the PDF instead of opening the print dialog.
Claims checked:
- contradicted: DeckCraft has no way to print and no Print entry anywhere in the UI (The default branch has crates/ui-egui/src/app/files.rs:262
print_pdf, crates/ui-egui/src/menus.rs:45 Ctrl+P and crates/ui-egui/src/backstage.rs:23mod print) - unverified: Ctrl/Cmd+P prints and does not collide with the Ctrl+Shift+P command palette (crates/ui-egui/src/menus.rs:
(P, true, false, false)calls print_now; the separate(P, true, true, false)arm still maps to app.palette) - contradicted: print_now builds the PDF with cmd::file::pdf_bytes and hands the bytes to the print hook, and File › Print… uses it (crates/ui-egui/src/lib.rs print_now only calls
services.printwhen it is Some. On desktop it is None, so the menu entry and shortcut do nothing and show no status) - unverified: The web runner prints via a Blob, an object URL and a hidden iframe, calling print() on load (apps/deckcraft-web/src/web.rs print_pdf sets onload before src and calls content_window().print(); the iframe and URL are never removed)
- contradicted: The PR is about printing only (It also adds crates/ui-egui/src/backstage.rs, crates/ui-egui/src/i18n/mod.rs, the Serbian catalogs, and sys-locale and ttf-parser in crates/ui-egui/Cargo.toml)
- unverified: The same direct-print feature already exists in the sibling word-processor and spreadsheet apps, and this change copies it (Not checked in the sibling repositories; the closest code is apps/deckcraft-web/src/web.rs print_pdf)
Recommendation: wait for maintainer feedback.
Reviewed at 56196ca.
What
DeckCraft currently has no way to print at all — no
file.printcommand (onlyfile.export, which always writes to a path), and no Print entry anywhere in the UI, not even behind a shortcut.This adds a print path that goes straight to the browser's native print dialog instead of forcing a download first:
Services::print, a web-only hook (PDF bytes in, system print dialog out), alongside the existingdownloadhookSlideApp::print_now(), which builds the PDF via the engine'scmd::file::pdf_bytes(the same lowest-level functionfile.exportalready uses under the hood) and hands the bytes to the hookCtrl/Cmd+Pwired up inui_shortcut— doesn't collide with the existingCtrl+Shift+Pcommand palette shortcutprintservice implementation: PDF bytes →Blob→ object URL → hidden<iframe>→iframe.contentWindow().print()once the iframe has finished loadingWhy
Export-only means every print is a round trip through the OS's file picker and PDF viewer just to get to a print dialog. This skips straight to it, the same way Word/Excel/PowerPoint's own Ctrl+P does.
Mirrors the same feature already added to WordCraft (storytold/wordcraft#209) and GridCraft (storytold/gridcraft#143).
Testing
Built with
trunk build --release, deployed, and smoke-tested in Firefox: Ctrl+P and File → Print… both open the system print dialog on the current presentation's PDF.🤖 Generated with Claude Code