Skip to content

Commit 99d1cc6

Browse files
committed
libcupsfilters: Let PPD generator take default ColorModel from printer
Instead of selecting the "best" available color mode as default for the PPD file generated from the response to the get-printer-attributes IPP request we use the printer default according to the IPP attributes (print-color-mode-default). This way on can simply change the default on a network printer's web interface or on a remote CUPS printer and clients using cups-browsed or the "driverless" utility respect the change. This solves OpenPrinting/cups#277, together with the changes done on CUPS for this issue.
1 parent 7ff1090 commit 99d1cc6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

cupsfilters/ppdgenerator.c

+23-2
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,10 @@ cfCreatePPDFromIPP2(char *buffer, /* I - Filename buffer */
25262526
/*
25272527
* ColorModel...
25282528
*/
2529+
if ((defattr = ippFindAttribute(response, "print-color-mode-default",
2530+
IPP_TAG_KEYWORD)) == NULL)
2531+
defattr = ippFindAttribute(response, "output-mode-default",
2532+
IPP_TAG_KEYWORD);
25292533

25302534
if ((attr = ippFindAttribute(response, "print-color-mode-supported",
25312535
IPP_TAG_KEYWORD)) == NULL)
@@ -2538,6 +2542,22 @@ cfCreatePPDFromIPP2(char *buffer, /* I - Filename buffer */
25382542
const char *default_color = NULL; /* Default */
25392543
int first_choice = 1;
25402544

2545+
if ((keyword = ippGetString(defattr, 0, NULL)) != NULL)
2546+
{
2547+
if (!strcmp(keyword, "bi-level"))
2548+
default_color = "FastGray";
2549+
else if (!strcmp(keyword, "process-bi-level"))
2550+
default_color = "ProcessFastGray";
2551+
else if (!strcmp(keyword, "auto-monochrome"))
2552+
default_color = "AutoGray";
2553+
else if (!strcmp(keyword, "monochrome"))
2554+
default_color = "Gray";
2555+
else if (!strcmp(keyword, "process-monochrome"))
2556+
default_color = "ProcessGray";
2557+
else
2558+
default_color = "RGB";
2559+
}
2560+
25412561
cupsFilePrintf(fp, "*%% ColorModel from %s\n", ippGetName(attr));
25422562

25432563
for (i = 0, count = ippGetCount(attr); i < count; i ++) {
@@ -2599,7 +2619,7 @@ cfCreatePPDFromIPP2(char *buffer, /* I - Filename buffer */
25992619
cupsFilePrintf(fp, "*ColorModel Gray/%s: \"\"\n",
26002620
(human_readable2 ? human_readable2 : "Monochrome"));
26012621

2602-
if (!default_color || !strcmp(default_color, "FastGray"))
2622+
if (!default_color || (!defattr && !strcmp(default_color, "FastGray")))
26032623
default_color = "Gray";
26042624
} else if (!strcmp(keyword, "process-monochrome")) {
26052625
if (first_choice) {
@@ -2630,7 +2650,8 @@ cfCreatePPDFromIPP2(char *buffer, /* I - Filename buffer */
26302650
cupsFilePrintf(fp, "*ColorModel RGB/%s: \"\"\n",
26312651
(human_readable2 ? human_readable2 : "Color"));
26322652

2633-
default_color = "RGB";
2653+
if (!default_color)
2654+
default_color = "RGB";
26342655

26352656
/* Apparently some printers only advertise color support, so make sure
26362657
we also do grayscale for these printers... */

0 commit comments

Comments
 (0)