print: Fix SVG previews sometimes failing to load
This is a workaround. It is still not clear why the loading can fail. Fix #422
This commit is contained in:
parent
c415b449f0
commit
273b8231d5
3 changed files with 14 additions and 10 deletions
1
news.d/47.3/fixed-svg-print-preview-missing
Normal file
1
news.d/47.3/fixed-svg-print-preview-missing
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Sometimes SVGs are not shown in the print preview.
|
||||||
1
news.d/47.3/released
Normal file
1
news.d/47.3/released
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
2025-01-13
|
||||||
|
|
@ -462,6 +462,16 @@ impl LpPrint {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let preview_image = LpImage::new_still();
|
||||||
|
preview_image.set_fixed_background_color(Some(gdk::RGBA::new(0.94, 0.94, 0.94, 1.)));
|
||||||
|
glib::spawn_future_local(glib::clone!(
|
||||||
|
#[strong]
|
||||||
|
preview_image,
|
||||||
|
#[strong]
|
||||||
|
file,
|
||||||
|
async move { preview_image.load(&file).await }
|
||||||
|
));
|
||||||
|
|
||||||
let print_dialog = gtk::PrintDialog::builder()
|
let print_dialog = gtk::PrintDialog::builder()
|
||||||
.accept_label(gettext("Continue…"))
|
.accept_label(gettext("Continue…"))
|
||||||
.title(gettext("Print Image"))
|
.title(gettext("Print Image"))
|
||||||
|
|
@ -490,25 +500,17 @@ impl LpPrint {
|
||||||
Ok(print_setup) => print_setup,
|
Ok(print_setup) => print_setup,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::new(image, parent, print_dialog, print_setup);
|
Self::new(image, preview_image, parent, print_dialog, print_setup);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
image: LpImage,
|
image: LpImage,
|
||||||
|
preview_image: LpImage,
|
||||||
parent: gtk::Window,
|
parent: gtk::Window,
|
||||||
print_dialog: gtk::PrintDialog,
|
print_dialog: gtk::PrintDialog,
|
||||||
print_setup: gtk::PrintSetup,
|
print_setup: gtk::PrintSetup,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let preview_image = LpImage::new_still();
|
|
||||||
preview_image.set_fixed_background_color(Some(gdk::RGBA::new(0.94, 0.94, 0.94, 1.)));
|
|
||||||
if let Some(file) = image.file() {
|
|
||||||
let preview_image_ = preview_image.clone();
|
|
||||||
glib::spawn_future_local(async move { preview_image_.load(&file).await });
|
|
||||||
} else {
|
|
||||||
log::error!("Trying to print image without file");
|
|
||||||
}
|
|
||||||
|
|
||||||
let obj: Self = glib::Object::builder()
|
let obj: Self = glib::Object::builder()
|
||||||
.property("image", image)
|
.property("image", image)
|
||||||
.property("preview-image", preview_image)
|
.property("preview-image", preview_image)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue