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.
Created attachment 500694
don't use PS prefs in gtk
The attached patch fixes this problem for me.
In widget/ src/xpwidgets/ nsPrintOptionsI mpl.cpp the page size is read and written to the prefs of the form:
print.printer_ NAME.print_ paper_name NAME.print_ paper_size_ width NAME.print_ paper_size_ height NAME.print_ paper_size_ type NAME.print_ paper_size_ unit
print.printer_
print.printer_
print.printer_
print.printer_
where NAME is the printer name.
In widget/ src/gtk2/ nsDeviceContext SpecG.cpp the page size is read but not written from the following prefs:
print.postscrip t.printer_ NAME.paper_ size NAME.paper_ size t.paper_ size
print.printer_
print.postscrip
print.paper_size
The problem is the prefs read in nsDeviceContext SpecG.cpp are not the same as the prefs written in nsPrintOptionsI mpl.cpp. If these prefs do not exist there is no problem as the prefs read in nsPrintOptionsI mpl.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 nsDeviceContext SpecG.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.