Bug 1755974 - Fix Linux system print dialog to take the pages-per-sheet from print preview. r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D164621
This commit is contained in:
Jonathan Watt 2022-12-14 00:04:21 +00:00
Родитель 2825275ca6
Коммит 1d98de863a
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -376,6 +376,8 @@ nsresult nsPrintDialogWidgetGTK::ImportSettings(nsIPrintSettings* aNSSettings) {
GtkPrintSettings* settings = aNSSettingsGTK->GetGtkPrintSettings();
GtkPageSetup* setup = aNSSettingsGTK->GetGtkPageSetup();
// Set our custom fields:
bool geckoBool;
aNSSettings->GetShrinkToFit(&geckoBool);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shrink_to_fit_toggle),
@ -387,6 +389,11 @@ nsresult nsPrintDialogWidgetGTK::ImportSettings(nsIPrintSettings* aNSSettings) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(print_bg_images_toggle),
aNSSettings->GetPrintBGImages());
// Temporarily set the pages-per-sheet on the GtkPrintSettings:
int32_t pagesPerSide;
aNSSettings->GetNumPagesPerSheet(&pagesPerSide);
gtk_print_settings_set_number_up(settings, pagesPerSide);
gtk_print_unix_dialog_set_settings(GTK_PRINT_UNIX_DIALOG(dialog), settings);
gtk_print_unix_dialog_set_page_setup(GTK_PRINT_UNIX_DIALOG(dialog), setup);
@ -423,6 +430,13 @@ nsresult nsPrintDialogWidgetGTK::ExportSettings(nsIPrintSettings* aNSSettings) {
aNSSettings->SetPrintBGImages(gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(print_bg_images_toggle)));
// Move any pages-per-sheet value from the GtkPrintSettings to our
// nsIPrintSettings. (We handle pages-per-sheet internally and don't want
// the native Linux printing code to doubly apply that value!)
int32_t pagesPerSide = gtk_print_settings_get_number_up(settings);
gtk_print_settings_set_number_up(settings, 1);
aNSSettings->SetNumPagesPerSheet(pagesPerSide);
// Try to save native settings in the session object
nsCOMPtr<nsPrintSettingsGTK> aNSSettingsGTK(do_QueryInterface(aNSSettings));
if (aNSSettingsGTK) {