Comment 123 for bug 10910

Revision history for this message
In , Adrian Johnson (ajohnson-redneon) wrote :

Created attachment 500694
don't use PS prefs in gtk

The attached patch fixes this problem for me.

In widget/src/xpwidgets/nsPrintOptionsImpl.cpp the page size is read and written to the prefs of the form:

print.printer_NAME.print_paper_name
print.printer_NAME.print_paper_size_width
print.printer_NAME.print_paper_size_height
print.printer_NAME.print_paper_size_type
print.printer_NAME.print_paper_size_unit

where NAME is the printer name.

In widget/src/gtk2/nsDeviceContextSpecG.cpp the page size is read but not written from the following prefs:

print.postscript.printer_NAME.paper_size
print.printer_NAME.paper_size
print.postscript.paper_size
print.paper_size

The problem is the prefs read in nsDeviceContextSpecG.cpp are not the same as the prefs written in nsPrintOptionsImpl.cpp. If these prefs do not exist there is no problem as the prefs read in nsPrintOptionsImpl.cpp are used. However I have found that in a newly created profile the pref "print.postscript.paper_size = letter" always exists. This will always be read and override the saved paper size. As it is not written, the "letter" default will not go away.

The attached patch changes the module name used when reading prefs in nsDeviceContextSpecG.cpp from "postscript" to null so the "print.postscript.paper_size" pref is never read. I am assuming the "postscript" module name is leftover from before gtkprint was used.

With the patch applied and using a newly created profile the default paper size will be the gtk_paper_size_get_default() paper size which is based on the current locale. After printing for the first time the selected page size is correctly saved and restored the next time the print dialog is opened.