diff --git a/data/gtk/print.ui b/data/gtk/print.ui index 3b9738d..f883b91 100644 --- a/data/gtk/print.ui +++ b/data/gtk/print.ui @@ -110,27 +110,15 @@ Margins - + Horizontal - - - center - 5 - - - + 2 - + Vertical - - - center - 5 - - - + 2 @@ -139,15 +127,9 @@ Image Size - + Width - - - center - 5 - - - + 2 diff --git a/src/widgets/print.rs b/src/widgets/print.rs index 12b5808..a0ffec2 100644 --- a/src/widgets/print.rs +++ b/src/widgets/print.rs @@ -41,13 +41,13 @@ mod imp { // ListBox entries #[template_child] - pub(super) width: TemplateChild, + pub(super) width: TemplateChild, #[template_child] pub(super) scale: TemplateChild, #[template_child] - pub(super) margin_left: TemplateChild, + pub(super) margin_left: TemplateChild, #[template_child] - pub(super) margin_top: TemplateChild, + pub(super) margin_top: TemplateChild, #[template_child] pub(super) unit: TemplateChild, @@ -111,6 +111,15 @@ mod imp { obj.set_transient_for(Some(&obj.parent_window())); obj.set_modal(true); + self.width + .connect_value_notify(glib::clone!(@weak obj => move |_| obj.on_width_changed())); + self.margin_left.connect_value_notify( + glib::clone!(@weak obj => move |_| obj.on_margin_left_changed()), + ); + self.margin_top.connect_value_notify( + glib::clone!(@weak obj => move |_| obj.on_margin_top_changed()), + ); + self.print_operation .set_print_settings(Some(&obj.print_settings())); self.print_operation.set_allow_async(true); @@ -130,9 +139,12 @@ mod imp { glib::clone!(@weak obj => move |_operation, _context, _page_nr| { let imp = obj.imp(); - imp.width.set_increments(1., 5.); - imp.margin_left.set_increments(1., 5.); - imp.margin_top.set_increments(1., 5.); + imp.width.adjustment().set_step_increment(1.); + imp.width.adjustment().set_page_increment(5.); + imp.margin_left.adjustment().set_step_increment(1.); + imp.margin_left.adjustment().set_page_increment(5.); + imp.margin_top.adjustment().set_step_increment(1.); + imp.margin_top.adjustment().set_page_increment(5.); obj.set_ranges(); @@ -213,8 +225,7 @@ impl LpPrint { self.print_settings().resolution() as f64 } - #[template_callback] - pub fn width_changed(&self) { + pub fn on_width_changed(&self) { self.imp() .scale .set_label(&format!("{:.2}\u{202F}%", self.user_scale() * 100.)); @@ -234,8 +245,7 @@ impl LpPrint { self.user_width() / orig_width as f64 } - #[template_callback] - pub fn margin_left_changed(&self) { + pub fn on_margin_left_changed(&self) { self.draw_preview(); } @@ -244,8 +254,7 @@ impl LpPrint { self.imp().margin_left.value() / self.unit_factor() } - #[template_callback] - pub fn margin_top_changed(&self) { + pub fn on_margin_top_changed(&self) { self.draw_preview(); }