print: Init preview image more cleanly
This commit is contained in:
parent
db6a7e7f2a
commit
0e490f38ad
2 changed files with 15 additions and 7 deletions
|
|
@ -249,6 +249,8 @@ mod imp {
|
|||
#[property(get, set, construct_only)]
|
||||
pub(super) image: OnceCell<LpImage>,
|
||||
#[property(get, set, construct_only)]
|
||||
pub(super) preview_image: OnceCell<LpImage>,
|
||||
#[property(get, set, construct_only)]
|
||||
pub(super) parent_window: OnceCell<gtk::Window>,
|
||||
#[property(get, set, construct_only)]
|
||||
pub(super) print_settings: OnceCell<gtk::PrintSettings>,
|
||||
|
|
@ -479,19 +481,25 @@ glib::wrapper! {
|
|||
|
||||
impl LpPrint {
|
||||
pub fn new(
|
||||
image1: LpImage,
|
||||
image: LpImage,
|
||||
parent_window: gtk::Window,
|
||||
print_settings: Option<gtk::PrintSettings>,
|
||||
page_setup: Option<gtk::PageSetup>,
|
||||
) -> Self {
|
||||
let image = LpImage::new_still();
|
||||
image.set_fixed_background_color(Some(gdk::RGBA::new(0.94, 0.94, 0.94, 1.)));
|
||||
let image2 = image.clone();
|
||||
glib::spawn_future_local(async move { image2.load(&image1.file().unwrap()).await });
|
||||
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 print_settings = print_settings.unwrap_or_default();
|
||||
|
||||
let obj: Self = glib::Object::builder()
|
||||
.property("image", image)
|
||||
.property("preview-image", preview_image)
|
||||
.property("print-settings", print_settings)
|
||||
.property("parent-window", parent_window)
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ mod imp_page {
|
|||
let width = self.print().user_width() * self.display_scale();
|
||||
let height = self.print().user_height() * self.display_scale();
|
||||
|
||||
let image = self.print().image();
|
||||
let image = self.print().preview_image();
|
||||
|
||||
image.allocate(
|
||||
width as i32,
|
||||
|
|
@ -195,7 +195,7 @@ impl Default for LpPrintPreviewPage {
|
|||
impl LpPrintPreviewPage {
|
||||
fn init(&self) {
|
||||
let imp = self.imp();
|
||||
let image = imp.preview().print().image();
|
||||
let image = imp.preview().print().preview_image();
|
||||
|
||||
image.set_sensitive(false);
|
||||
image.set_parent(self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue