fix(print): bind selected printer and settings in NSPrintPanel (#186) #196

Merged
gronod merged 1 commits from feat/186-panel-binding into milestone/m11-print-settings 2026-09-15 20:41:14 +01:00
Owner

Refs #186

Summary

Binds the native NSPrintPanel to the selected CUPS queue with all Stage 2 selections pre-applied, and captures the user's dialog changes back into ICCery for subsequent lp spooling.

Preselect (locked write order: PMSessionDefault* → initial selections → ColorSync suppression → modal)

  • Paper — two writes (E1): PageSize in PMPrintSettings plus the PMPageFormat half the panel's paper dropdown reflects — PMPrinterGetPaperListPMPaperGetID match → PMCreatePageFormatWithPMPaperPMSessionValidatePageFormatPMCopyPageFormat into printInfo.pmPageFormat()updateFromPMPageFormat (TN2248). Custom.<pt>x<pt> tokens set printInfo.paperSize in points.
  • Media type: PMPrintSettingsSetValue on the queue's detected vendor key via detectMediaTypeKey.
  • Orientation: orientation-requested 3|4 (portrait/landscape).
  • All writes warn-only; NSPrinter display-name fallback logs a warning. PM objects released per Create/Get rules (page-format released; paper list borrowed from printer).

Capture-return + apply-back

  • Captured k=v string now maps PageSize / detected quality key / orientation-requested 3|4 → portrait|landscape / media (extended extractMediaType to the full vendor roster — CNIJMediaType, EPIJ_Medi, StpMediaType).
  • openPrinterPreferences passes all five selections and applies results back to selectedPaperSize / selectedQuality / selectedMediaType / printOrientation. workflow.pageSize is never mutated.
  • Known returned queue switches selectedPrinter + reloads caps; unknown queue is ignored; cancel returns nil with the info notice.
  • UITestHooks.printPanelResult derives the new fields from ICCERY_TEST_PANEL_OPTIONS through the same extraction helpers.

Notes: the contract's PMPrintSettingsSetValue(…, 1) shorthand was normalized to locked=false — PMCore.h explicitly recommends false. Deprecated-PM symbols verified against the installed 15.2 SDK (PMCreatePageFormatWithPMPaper, not PMPageFormatCreateWithPMPaper).

Verification

  • Targeted gate (build/DerivedData-feat-186-panel-binding, x86_64):
    • CupsParserTests 24, PrintPanelStubTests 5, PrintSessionViewModelTests 13 — 42/0
    • Milestone11PrintSettingsUITests 5, Milestone3UITests 6 — 11/0
  • Wider ICCeryCoreTests: 483 tests, 0 failures
  • git diff --check: clean

Hardware gate

Driver PDE acceptance of preselect writes (R12) is only verifiable via capture echo on physical hardware — warn-only by design.

Refs #186 ## Summary Binds the native `NSPrintPanel` to the selected CUPS queue with all Stage 2 selections pre-applied, and captures the user's dialog changes back into ICCery for subsequent `lp` spooling. ### Preselect (locked write order: `PMSessionDefault*` → initial selections → ColorSync suppression → modal) - **Paper — two writes (E1):** `PageSize` in `PMPrintSettings` **plus** the `PMPageFormat` half the panel's paper dropdown reflects — `PMPrinterGetPaperList` → `PMPaperGetID` match → `PMCreatePageFormatWithPMPaper` → `PMSessionValidatePageFormat` → `PMCopyPageFormat` into `printInfo.pmPageFormat()` → `updateFromPMPageFormat` (TN2248). `Custom.<pt>x<pt>` tokens set `printInfo.paperSize` in points. - **Media type:** `PMPrintSettingsSetValue` on the queue's detected vendor key via `detectMediaTypeKey`. - **Orientation:** `orientation-requested` 3|4 (portrait/landscape). - All writes warn-only; NSPrinter display-name fallback logs a warning. PM objects released per Create/Get rules (page-format released; paper list borrowed from printer). ### Capture-return + apply-back - Captured `k=v` string now maps `PageSize` / detected quality key / `orientation-requested` 3|4 → `portrait`|`landscape` / media (extended `extractMediaType` to the full vendor roster — `CNIJMediaType`, `EPIJ_Medi`, `StpMediaType`). - `openPrinterPreferences` passes all five selections and applies results back to `selectedPaperSize` / `selectedQuality` / `selectedMediaType` / `printOrientation`. `workflow.pageSize` is never mutated. - Known returned queue switches `selectedPrinter` + reloads caps; unknown queue is ignored; cancel returns `nil` with the info notice. - `UITestHooks.printPanelResult` derives the new fields from `ICCERY_TEST_PANEL_OPTIONS` through the same extraction helpers. Notes: the contract's `PMPrintSettingsSetValue(…, 1)` shorthand was normalized to `locked=false` — PMCore.h explicitly recommends false. Deprecated-PM symbols verified against the installed 15.2 SDK (`PMCreatePageFormatWithPMPaper`, not `PMPageFormatCreateWithPMPaper`). ## Verification - Targeted gate (`build/DerivedData-feat-186-panel-binding`, x86_64): - `CupsParserTests` 24, `PrintPanelStubTests` 5, `PrintSessionViewModelTests` 13 — 42/0 - `Milestone11PrintSettingsUITests` 5, `Milestone3UITests` 6 — 11/0 - Wider `ICCeryCoreTests`: **483 tests, 0 failures** - `git diff --check`: clean ## Hardware gate Driver PDE acceptance of preselect writes (R12) is only verifiable via capture echo on physical hardware — warn-only by design.
gronod added the Kind/Bug
Priority
High
2
Project/ICCery-v2Bug/UI
labels 2026-09-15 20:40:55 +01:00
gronod added 1 commit 2026-09-15 20:40:57 +01:00
Refs #186

Co-Authored-By: Devin <devin@cognition.ai>
gronod self-assigned this 2026-09-15 20:41:07 +01:00
gronod added this to the M11 — Printer settings completeness & dialog binding milestone 2026-09-15 20:41:08 +01:00
gronod merged commit 6adbf99bd9 into milestone/m11-print-settings 2026-09-15 20:41:14 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gronod/iccery-v2-mac#196