[Bug/High] Printer properties dialog doesn't apply selected printer and settings from ICCery #186
Notifications
Due Date
No due date set.
Depends on
Reference: gronod/iccery-v2-mac#186
Reference in New Issue
Block a user
Summary
The printer properties button (gear icon) in Stage 2 opens the OS print dialog (
NSPrintPanel), but it doesn't apply the paper size, quality, media type, or orientation selected in ICCery.Related to
Issue #180 — Epson printer quality options limited to default only
Bug Details
Current Behavior
PrintPanelService.showProperties()is called with the selected queueNSPrintPanelopens but:Binding note: "falls back to system default" is not possible on the PM path —
PMSessionSetCurrentPMPrinterfailure throwssessionBindingFailed(PrintPanelService.swift:83-87), and theNSPrinter(name:)fallback throwsnoPrinterFoundwhen it can't resolve (:93-100). The realistic residual risk is the display-name fallback binding a different queue — hardware-verify, not a proven defect.Root Cause Analysis
In
PrintPanelService.runNativePanel()(Sources/ICCery/Print/PrintPanelService.swift:64-162):NSPrintInfo()with default valuesPMPrinterCreateFromPrinterID+PMSessionSetCurrentPMPrinterPMSessionDefaultPrintSettingsandPMSessionDefaultPageFormat— these load printer defaults, not user-selected valuespanel.runModal(with: printInfo)Missing:
PMPageFormatpaper size andPMPrintSettingsquality/media/orientation beforerunModalcupsOptions/mediaType(PrintPanelService.swift:142-161) — it must extend topaperSize/quality/orientationparsed from the capturedk=vstringExpected Behavior
pageSize(A4 default)Implementation Notes
pageSize,selectedQuality,selectedMediaType,printOrientationfromPrintSessionViewModeltoPrintPanelService.showProperties()— the initial-selections plumbing for paper size + quality is #183 scope; this issue adds media type + orientationrunNativePanel(), before showing panel:PageSizeinPMPrintSettings(drivers/capture read it) andPMPageFormatviaPMPaper— the panel's paper dropdown reflectsPMPageFormat;PMPrintSettingsSetValuewrites print settings only and cannot set the page format. Path:PMPrinterGetPaperList/PMPaperGetID+PMPageFormatCreateWithPMPaper+PMSessionValidatePageFormat;printInfo.paperSize/PMPaperCreateCustomfor custom sizes. Verify exact PM calls against PrintCore headers at implementation (deprecated-but-present APIs on macOS 12)PMPrintSettingsSetValuewith detected quality key (e.g.,EPIJ_Qual,cupsPrintQuality)PMPrintSettingsSetValuewith detected media keyPMPrintSettingsSetValuewithorientation-requestedPMSessionDefaultPrintSettings/PMSessionDefaultPageFormatbut before ColorSync suppression layers ②–⑤Spec References
PMPrinterCreateFromPrinterID→PMSessionSetCurrentPMPrinterPrintOptionsstructure carriespaper_size,media_type,orientation(spec naming; Swift fields arepaperSize/mediaType/orientation)Dependencies
showPropertiesinitial-selections for paper size + quality; this issue completes media type + orientation preselect, capture-return of all fields, and binding verificationAcceptance Criteria
PrintPropertiesResult— includingpaperSize/quality/orientation, not onlycupsOptions/mediaTypePlanning errata (verified on develop@736fd08):
PMPageFormatpaper size viaPMPrintSettingsSetValue" —PMPrintSettingsSetValuewrites print settings only; the panel's paper dropdown reflectsPMPageFormat. Both writes are required:PageSizeinPMPrintSettings(drivers/capture read it) andPMPageFormatviaPMPaper(PMPrinterGetPaperList/PMPaperGetID+PMPageFormatCreateWithPMPaper+PMSessionValidatePageFormat;printInfo.paperSize/PMPaperCreateCustomfor custom). Exact PM calls verified against PrintCore headers at implementation (deprecated-but-present APIs on macOS 12).NSPrinter(name:)fallback throwsnoPrinterFoundwhen nil (:95–99). The realistic failure is a display-name fallback binding a different queue — hardware-verify, not a proven defect.cupsOptions/mediaType(currently the only fields parsed, PrintPanelService.swift:142–157) topaperSize/quality/orientationparsed from the capturedk=vstring.Errata above incorporated into the issue body — the ticket itself is now the corrected contract.
Implementation landed in PR #196 at
6adbf99on milestone/m11-print-settings.Acceptance evidence:
PMPrinterCreateFromPrinterID+PMSessionSetCurrentPMPrinter— PrintPanelServicerunNativePanel;testPanelResultSwitchesToKnownQueue,testPanelResultGhostQueueIgnored(PrintSessionViewModelTests)pageSize— written to BOTHPMPrintSettingsPageSizeandPMPageFormat/PMPaperviaPMCreatePageFormatWithPMPaper+PMSessionValidatePageFormat(named-paper match, validation, copy, and customPMPaperCreateCustompath); PrintPanelStubTests coveragePMPrintSettingsSetValuewith the detected quality key (e.g.,EPIJ_Qual) — stub coverage in PrintPanelStubTests (testOkResultExtractsNewFields,testOkResultExtractsVendorMediaKey)PMPrintSettingsSetValuewith the detected media key, with vendor-roster extraction extended —testExtractMediaTypeRosterFallback(CupsParserTests)PMPrintSettingsSetValue(orientation-requested3/4, portrait default) —testExtractQualityAndOrientation(CupsParserTests)PMSessionDefaultPrintSettings/PMSessionDefaultPageFormatand before ColorSync suppression layers ②–⑤ — ordering preserved inrunNativePanel; preselection/fallback failures are warning-onlyPrintPropertiesResultincludingpaperSize/quality/orientation/mediaType/cupsOptions; VM applies all back (workflow.pageSizeuntouched) —testCapturedStringMapsAllFields,testOkResultExtractsNewFields,testPanelResultAppliesBackSelections,testPanelResultAppliesBackOrientationAndMedia,testPanelResultUnknownPaperLeavesSelection(core); UItestPanelResultAppliesBackToPickers,testPanelResultAppliesBackOrientationAndMedia(Milestone11PrintSettingsUITests)nil+ info notice;NSPrinterdisplay-name fallback unchanged (+ warn log) —testCancelIsNil(PrintPanelStubTests),testPanelCancelLeavesSelections(PrintSessionViewModelTests); UItestPreferencesCancelIsInfo(Milestone3UITests)Verification at milestone/m11-print-settings
6adbf99bd9:xcodebuild test -scheme ICCery -destination 'platform=macOS' -derivedDataPath build/DerivedData-m11-final ARCHS="$(uname -m)" CODE_SIGNING_ALLOWED=YES CODE_SIGN_IDENTITY='-'(x86_64): passedtestAboutDialogShowsVersionAndBuildDate, no assertion failure)Hardware item remains a milestone gate (not this issue's merge gate).
Closing manually only after code and tests are present on the milestone branch.
Follow-up filed: #217 — on real hardware (Epson XP-55) the dialog still opens on driver defaults. Root cause identified post-#201: the captured
PrintTicketis never restored into the panel'sNSPrintInfo(PMTicketBridge.restoreis wired toNativeTargetSpooleronly), and the four-key pre-select this issue added is never validated viaPMSessionValidatePrintSettingsbeforerunModal. Details + proposed restore-then-override fix in #217.