Issue #1: Media type selection box displays numeric PPD choice codes instead of human-readable driver names
Issue #2: Tray selection picklist is empty due to empty-array coalescing bug and missing vendor PPD keywords (Epson/Canon)
Changes
Core Models & PPD Parsing (CUPSManager.swift):
Added struct PPDChoice: Equatable, Hashable storing both internal name (e.g. "13") and human-readable title (e.g. "Epson Premium Glossy").
Implemented decodePPDString(_:) for PPD hex character escape decoding (CD<2F>DVD -> CD/DVD, <2E> -> ., etc.).
Added optionDetails(in:keyword:) to parse choice names and localized display titles, stripping quotes and decoding escapes.
Added dynamic keyword & choice discovery:
Media types: checks MediaType, CNIJMediaType (Canon), and scans *OpenUI for /Media Type.
Paper sources: checks InputSlot, EPIJ_FdSo (Epson), CNIJMediaSupply (Canon), and scans *OpenUI for /Paper Source, /Media Source, etc.
Updated PrinterQueue and PPDOptions to expose structured choices and discovered keywords.
Inspector UI (InspectorView.swift):
Fixed the Swift nil-coalescing empty array bug: (q?.trayChoices.isEmpty == false) ? q!.trayChoices : [PPDChoice(name: "Auto", title: "Auto")] and (q?.mediaTypeChoices.isEmpty == false) ? q!.mediaTypeChoices : [PPDChoice(name: "Plain", title: "Plain")].
Added refillChoices and selectChoice to populate dropdowns with display titles while setting NSMenuItem.representedObject to the computer-readable choice code.
Updated push(into engine:) to retrieve representedObject so underlying choice codes are passed into PrintEngine.
Print Engine (PrintEngine.swift):
Updated applyOptionalPPDKeys(to:queue:) to use the queue's discovered vendor keywords (mediaTypeKeyword and trayKeyword).
Added dual-identity resolution so jobs specifying either display titles or internal choice codes correctly resolve to the expected PPD choice code.
- Parse PPD translation strings and decode hex escapes (e.g. CD<2F>DVD -> CD/DVD)
- Populate InspectorView media type and tray dropdowns with human-readable titles while preserving computer-readable choice codes
- Fix empty-array nil coalescing bug in InspectorView preventing empty tray and media type popups
- Support OEM vendor PPD keywords (Canon CNIJMediaType/CNIJMediaSupply, Epson EPIJ_FdSo)
- Add dual-identity lookup in PrintEngine and InspectorView for robust choice code vs title resolution
- Add comprehensive PPDOptionsTests and CLI test runner
Closes#1, Closes#2
gronod
merged commit 8eb4bd408d into development2026-09-07 22:48:18 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
This PR resolves both open issues:
Changes
Core Models & PPD Parsing (
CUPSManager.swift):struct PPDChoice: Equatable, Hashablestoring both internalname(e.g."13") and human-readabletitle(e.g."Epson Premium Glossy").decodePPDString(_:)for PPD hex character escape decoding (CD<2F>DVD->CD/DVD,<2E>->., etc.).optionDetails(in:keyword:)to parse choice names and localized display titles, stripping quotes and decoding escapes.MediaType,CNIJMediaType(Canon), and scans*OpenUIfor/Media Type.InputSlot,EPIJ_FdSo(Epson),CNIJMediaSupply(Canon), and scans*OpenUIfor/Paper Source,/Media Source, etc.PrinterQueueandPPDOptionsto expose structured choices and discovered keywords.Inspector UI (
InspectorView.swift):(q?.trayChoices.isEmpty == false) ? q!.trayChoices : [PPDChoice(name: "Auto", title: "Auto")]and(q?.mediaTypeChoices.isEmpty == false) ? q!.mediaTypeChoices : [PPDChoice(name: "Plain", title: "Plain")].refillChoicesandselectChoiceto populate dropdowns with display titles while settingNSMenuItem.representedObjectto the computer-readable choice code.push(into engine:)to retrieverepresentedObjectso underlying choice codes are passed intoPrintEngine.Print Engine (
PrintEngine.swift):applyOptionalPPDKeys(to:queue:)to use the queue's discovered vendor keywords (mediaTypeKeywordandtrayKeyword).Testing (
Tests/,TargetPrint.xcodeproj):Tests/PPDOptionsTests.swiftcovering hex decoding, Epson/Canon/Standard PPD parsing, fallback behaviors, andPrintEngineresolution.Tests/TestRunnerMain.swiftandScripts/test_runner.shfor complete automated testing under Command Line Tools.PPDOptionsTests.swiftinTargetPrint.xcodeproj/project.pbxproj.Closes #1
Closes #2