print: Do everything in request-page-setup

Otherwise we are too late to layout the page and the orientation will
not be honored by the actual printing.
We also have to use the per-page PageSetup because they are already
specualized at this point.

Closes #348
This commit is contained in:
Sophie Herold 2024-04-06 18:43:01 +02:00
parent 37ac3de2b8
commit 46a17367bd
2 changed files with 27 additions and 10 deletions

1
NEWS
View file

@ -3,6 +3,7 @@
- Fix fractional scaling beeing blury by setting GDK_DEBUG=gl-no-fractional as default - Fix fractional scaling beeing blury by setting GDK_DEBUG=gl-no-fractional as default
- Fix exposure times above 0.5 seconds not being displayed correctly in properties - Fix exposure times above 0.5 seconds not being displayed correctly in properties
- Fix page orientation from print preview dialog is not honored for actual print
46.1 46.1
==== ====

View file

@ -358,8 +358,17 @@ mod imp {
op.set_n_pages(1); op.set_n_pages(1);
}); });
self.print_operation.connect_draw_page(glib::clone!(@weak obj => self.print_operation.connect_request_page_setup(
move |operation, context, _page_nr| { glib::clone!(@weak obj =>move |operation, _context, nr, setup| {
if nr != 0 {
log::error!("Unexpected page number {nr}");
return;
}
// Since we already have explicit per page setups here, we have to use this to
// set values. The modules uses the default page setup everywhere.
obj.print_operation().set_default_page_setup(Some(setup));
let imp = obj.imp(); let imp = obj.imp();
let basename = obj let basename = obj
@ -394,8 +403,7 @@ mod imp {
let size_unit = obj.size_unit(); let size_unit = obj.size_unit();
imp.width.set_value( imp.width.set_value(
size_unit size_unit.round(obj.original_size().0 as f64 * obj.width_unit_factor()),
.round(obj.original_size().0 as f64 * obj.width_unit_factor()),
); );
// Default to inch for USA and Liberia // Default to inch for USA and Liberia
@ -429,8 +437,9 @@ mod imp {
} }
Status::Print => { Status::Print => {
log::debug!("Layout dialog confirmed"); log::debug!("Layout dialog confirmed");
obj.draw_page(context); // Actual printing will happen in draw-page signal
break;} break;
}
Status::Abort => { Status::Abort => {
log::debug!("Layout dialog aborted"); log::debug!("Layout dialog aborted");
imp.print_operation.cancel(); imp.print_operation.cancel();
@ -438,6 +447,13 @@ mod imp {
} }
} }
} }
}),
);
self.print_operation
.connect_draw_page(glib::clone!(@weak obj =>
move |_operation, context, _page_nr| {
obj.draw_page(context);
} }
)); ));
} }