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 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
====

View file

@ -358,8 +358,17 @@ mod imp {
op.set_n_pages(1);
});
self.print_operation.connect_draw_page(glib::clone!(@weak obj =>
move |operation, context, _page_nr| {
self.print_operation.connect_request_page_setup(
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 basename = obj
@ -394,8 +403,7 @@ mod imp {
let size_unit = obj.size_unit();
imp.width.set_value(
size_unit
.round(obj.original_size().0 as f64 * obj.width_unit_factor()),
size_unit.round(obj.original_size().0 as f64 * obj.width_unit_factor()),
);
// Default to inch for USA and Liberia
@ -424,13 +432,14 @@ mod imp {
loop {
match imp.status.get() {
Status::Prepare => {
Status::Prepare => {
glib::MainContext::default().iteration(true);
}
}
Status::Print => {
log::debug!("Layout dialog confirmed");
obj.draw_page(context);
break;}
// Actual printing will happen in draw-page signal
break;
}
Status::Abort => {
log::debug!("Layout dialog aborted");
imp.print_operation.cancel();
@ -438,8 +447,15 @@ mod imp {
}
}
}
}
));
}),
);
self.print_operation
.connect_draw_page(glib::clone!(@weak obj =>
move |_operation, context, _page_nr| {
obj.draw_page(context);
}
));
}
fn properties() -> &'static [glib::ParamSpec] {