Repository navigation
Conversation
printing::network is a new submodule beside the existing queue controls; State, Settings, Labels and the other existing items are unchanged, so WordCraft and GridCraft are unaffected. - Draft is the pure model: the typed address, the query result, copies, sides, orientation and quality limited to what the printer lists, a per-job confirmation that is cleared when the address changes, the printer is queried again, a job starts or the dialog opens, the job view, and the reasons that block Print. Answers for an older query or another address are dropped. - It has its own light types and depends on no print client; the host maps its client's results into them. - State adds host-supplied QueryPrinter and SendJob workers returning mpsc receivers (a job also carries a cancel closure), poll, start_query, start_job (which re-checks every block and spends the confirmation), cancel_job (the host is told once) and show. - show draws the address field with the host validator's inline error, the Query button, the printer name, state and reasons, the options the printer lists, the confirmation checkbox, a spinner with Cancel while a job runs and the result text. All wording comes from Labels. - The Print button, document generation, the attestation flow and translations stay in the app. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…he network printer destination A SendJob worker can now report that the printer accepted the document and what the printer says afterwards, without blocking the UI thread: JobHandle gains an optional updates receiver that State::poll drains each frame before the result. JobView gets an Accepted state with a Stage (accepted, waiting, held, printing, stopped), optional sheet counters and the printer's notes; Outcome gets AcceptedUnknown for a printer that cannot report (sent, outcome unknown), and a worker that stops after the acceptance is shown that way instead of as a failure. A Failure can say the request may have reached the printer, and the UI then asks the person to check the printer before sending again. Cancel works in both phases and the host is told once. Workers that send no updates behave as before. JobHandle is built with JobHandle::new, and Labels has new fields for the accepted phase. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A printer that reports sheets done and no total now shows the count without a bar, and the app's page count (Draft::expected_pages) becomes an estimated sheet total that makes the bar determinate; a total the printer reports wins. Request carries the page count to the host, Progress gains fraction and with_expected_total, and JobHandle, JobUpdate, State::start_job and Labels are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…etwork printer destination Photo was already a quality choice of the destination; it is now covered end to end (token round trip, label, offered and requested only for a printer that lists it, dropped on a printer that does not) and Quality gains from_token for hosts that map printer tokens. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Folded into #112: the network-printer destination (printing::network, the three-state capability work included) is now part of the single craft-ui pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
craft-ui: a network-printer destination with a two-phase job
Based on storytold/craft-libs
main(457a078).This is slice 3 of 3 (print backend, WS-Print, then this). A reviewer sees four commits that describe one
change:
f0c516badds the destination,1043040reworks its job model so that "sent", "accepted" and "finished"are different states,
93e71b1makes the sheet total optional end to end (the owner's request after the pdfcraftadoption), and
cd1ee76covers the Photo quality choice and addsQuality::from_token. Review the branch at its head.What
A new submodule
craft_ui::printing::networkbeside the existing queue controls:Draft, the pure model: the typed address, the query result, copies, sides, orientation and quality limited towhat the printer lists, a per-job confirmation, the job view, and
Block, the reasons Print is disabled.PrinterSummary,Caps,Request,Report,Failure,Outcome,Stage,Progress,JobUpdate,JobView.Statewith host-suppliedQueryPrinterandSendJobworkers (they returnmpscreceivers; a job also carries acancel closure),
poll,start_query,start_job,cancel_jobandshow, andHost { validate, query, sheets_ok, formats }.JobView::Running), sendsJobUpdate::Acceptedwhen the printerhas it (
JobView::Accepted, with aStageof Accepted, Waiting, Held, Printing or Stopped, optional sheet countersand the printer's notes), sends
JobUpdate::Statusas it learns more, and finishes on the result receiver.Outcome::AcceptedUnknownis "sent, outcome unknown" for a printer that cannot report; it is neither a failure nor aclaim that the job printed. A worker that stops after
Acceptedis shown the same way.Progress::sheets_totalis anOption, as printers often report sheets done and no total.While it is unknown the accepted phase shows the count ("N sheets", the existing
Labels::sheets) and no bar thatcould never fill; once known it shows the determinate bar. The app can supply one:
Draft::expected_pages(thedocument's page count, set before
start_job) goes to the host in the newRequest::expected_pages(acraft-printworker passes it as
JobOptions::expected_pages) and, as an estimated sheet total (Draft::expected_sheets: halvedand rounded up for a two-sided job, times the copies, fixed when the job starts), fills a missing or zero total of every
Accepted/Statusupdate. A total the printer reports always wins.Progressgainedfraction()andwith_expected_total(). I chose "N sheets" over a custom indeterminate bar because egui 0.36'sProgressBarhas noindeterminate mode and the count says what is known.
Quality(Draft,Normal,High,Photo;ALL,token()) already hadPhotoand aLabels::photolabel from the first commit, so nothing was missing in this crate for pdfcraft's
--quality phototo reach the dialog:what refused it was
craft-print'sQuality, fixed in slice 1.cd1ee76addsQuality::from_token(for a host thatmaps a printer's token, ASCII case ignored) and tests: the token round trip, the label,
Photooffered and requestedonly for a printer that lists it (a vendor value is not a choice), and the choice dropped when the next printer does not
list it.
Failurecan say the request may have reached the printer (outcome_unknown); the UI then asks the person tocheck the printer before sending again.
Why
Apps that print to a network printer by address need the same dialog behaviour: validate the address, ask the printer
what it supports, offer only that, require a confirmation for this job, and show a job that takes time without
blocking the UI thread. The model and rules are UI logic with no print client in them, so they belong here once rather
than in each app.
How
State,Settings,Labelsand the other existing items inprintingare unchanged; WordCraft andGridCraft are untouched. The module is new.
into the light types; the README describes how a worker built on
craft-printmapsSubmittedtoAccepted, eachJobStatustoStatusand itsWatchOutcometo theReport.default and is cleared when the address changes, the printer is queried again, a job starts and the dialog opens.
Answers for an older query or another address are dropped. Print is blocked until the typed address was queried, the
printer takes one of the host's formats, there is something to print and the box is ticked.
poll(called insideshow). Dropping a result receiver cancels nothing; cancel works in both phases and the host is told once.worker closures. The Print button, document generation and the attestation flow stay in the app.
How verified
As run at
cd1ee76(aftercargo clean -p craft-ui), on Windows:cargo fmt --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(285 passed, 4ignored),
RUSTDOCFLAGS=-D warnings cargo doc -p craft-ui --no-depsandcargo check -p craft-ui --target wasm32-unknown-unknownpass.cargo test -p craft-ui: 115 tests pass (109 lib tests of which 31 are inprinting::network; the two Photo tests ofcd1ee76are the last of them). At93e71b1it was 107 lib tests, 29 inprinting::network(24 before that commit; the 5 newones cover the model: indeterminate fraction, estimated sheets from pages, duplex and copies, the page count in
Request, a reported total winning over the estimate; and the egui accesskit rendering: "Blatt: 3" without a bar for anunknown total, no text for zero sheets, "1 von 4" from the expected total, "1 von 8" when the printer reports 8). The
integration suites
docking_workflows(1) andvisual_regression(5) pass unchanged.Not verified:
Breaking changes (new module only)
JobHandleis#[non_exhaustive](build it withJobHandle::new), andLabelsgained 8 fields for the acceptedphase. This breaks only a host that builds them literally. The module is new and unmerged, so no released API is
affected. The optional-totals commit is additive on top of that:
Requestgainedexpected_pages(use..Default::default()if you construct aRequest),Draftgainedexpected_pagesandexpected_sheets(), andProgressgained two methods;Labels,JobHandle,JobUpdateandState::start_jobare unchanged.cd1ee76isadditive (
Quality::from_token).The pdfcraft-facing rule for quality: map
craft_ui::printing::network::Qualitytocraft_print::Qualityone to one(
Draft,Normal,High,Photo) once slice 1 is in; a printer that does not listPhotonever gets it offered or sent.Boundaries
unsafeare not involved.Consumers
pdfcraft adopts slices 1-3: CLI
print --wsd, aprint_wsdtool, a destination in the Print dialog, a parity entryand i18n, behind the app feature
network-print(default on).Review order
This slice has no code dependency on slices 1 and 2 and can be reviewed independently. The mapping described in the
README assumes the
craft-printtypes from slice 1 (#116), includingJobIdandJobOptions.🤖 Generated with Claude Code