1use crate::{
6 ffi, PageSetup, PrintContext, PrintOperationAction, PrintOperationPreview,
7 PrintOperationResult, PrintSettings, PrintStatus, Unit, Widget, Window,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 #[doc(alias = "GtkPrintOperation")]
19 pub struct PrintOperation(Object<ffi::GtkPrintOperation, ffi::GtkPrintOperationClass>) @implements PrintOperationPreview;
20
21 match fn {
22 type_ => || ffi::gtk_print_operation_get_type(),
23 }
24}
25
26impl PrintOperation {
27 pub const NONE: Option<&'static PrintOperation> = None;
28
29 #[doc(alias = "gtk_print_operation_new")]
30 pub fn new() -> PrintOperation {
31 assert_initialized_main_thread!();
32 unsafe { from_glib_full(ffi::gtk_print_operation_new()) }
33 }
34
35 pub fn builder() -> PrintOperationBuilder {
40 PrintOperationBuilder::new()
41 }
42}
43
44impl Default for PrintOperation {
45 fn default() -> Self {
46 Self::new()
47 }
48}
49
50#[must_use = "The builder must be built to be used"]
55pub struct PrintOperationBuilder {
56 builder: glib::object::ObjectBuilder<'static, PrintOperation>,
57}
58
59impl PrintOperationBuilder {
60 fn new() -> Self {
61 Self {
62 builder: glib::object::Object::builder(),
63 }
64 }
65
66 pub fn allow_async(self, allow_async: bool) -> Self {
67 Self {
68 builder: self.builder.property("allow-async", allow_async),
69 }
70 }
71
72 pub fn current_page(self, current_page: i32) -> Self {
73 Self {
74 builder: self.builder.property("current-page", current_page),
75 }
76 }
77
78 pub fn custom_tab_label(self, custom_tab_label: impl Into<glib::GString>) -> Self {
79 Self {
80 builder: self
81 .builder
82 .property("custom-tab-label", custom_tab_label.into()),
83 }
84 }
85
86 pub fn default_page_setup(self, default_page_setup: &PageSetup) -> Self {
87 Self {
88 builder: self
89 .builder
90 .property("default-page-setup", default_page_setup.clone()),
91 }
92 }
93
94 pub fn embed_page_setup(self, embed_page_setup: bool) -> Self {
95 Self {
96 builder: self.builder.property("embed-page-setup", embed_page_setup),
97 }
98 }
99
100 pub fn export_filename(self, export_filename: impl Into<glib::GString>) -> Self {
101 Self {
102 builder: self
103 .builder
104 .property("export-filename", export_filename.into()),
105 }
106 }
107
108 pub fn has_selection(self, has_selection: bool) -> Self {
109 Self {
110 builder: self.builder.property("has-selection", has_selection),
111 }
112 }
113
114 pub fn job_name(self, job_name: impl Into<glib::GString>) -> Self {
115 Self {
116 builder: self.builder.property("job-name", job_name.into()),
117 }
118 }
119
120 pub fn n_pages(self, n_pages: i32) -> Self {
121 Self {
122 builder: self.builder.property("n-pages", n_pages),
123 }
124 }
125
126 pub fn print_settings(self, print_settings: &PrintSettings) -> Self {
127 Self {
128 builder: self
129 .builder
130 .property("print-settings", print_settings.clone()),
131 }
132 }
133
134 pub fn show_progress(self, show_progress: bool) -> Self {
135 Self {
136 builder: self.builder.property("show-progress", show_progress),
137 }
138 }
139
140 pub fn support_selection(self, support_selection: bool) -> Self {
141 Self {
142 builder: self
143 .builder
144 .property("support-selection", support_selection),
145 }
146 }
147
148 pub fn track_print_status(self, track_print_status: bool) -> Self {
149 Self {
150 builder: self
151 .builder
152 .property("track-print-status", track_print_status),
153 }
154 }
155
156 pub fn unit(self, unit: Unit) -> Self {
157 Self {
158 builder: self.builder.property("unit", unit),
159 }
160 }
161
162 pub fn use_full_page(self, use_full_page: bool) -> Self {
163 Self {
164 builder: self.builder.property("use-full-page", use_full_page),
165 }
166 }
167
168 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
171 pub fn build(self) -> PrintOperation {
172 assert_initialized_main_thread!();
173 self.builder.build()
174 }
175}
176
177mod sealed {
178 pub trait Sealed {}
179 impl<T: super::IsA<super::PrintOperation>> Sealed for T {}
180}
181
182pub trait PrintOperationExt: IsA<PrintOperation> + sealed::Sealed + 'static {
183 #[doc(alias = "gtk_print_operation_cancel")]
184 fn cancel(&self) {
185 unsafe {
186 ffi::gtk_print_operation_cancel(self.as_ref().to_glib_none().0);
187 }
188 }
189
190 #[doc(alias = "gtk_print_operation_draw_page_finish")]
191 fn draw_page_finish(&self) {
192 unsafe {
193 ffi::gtk_print_operation_draw_page_finish(self.as_ref().to_glib_none().0);
194 }
195 }
196
197 #[doc(alias = "gtk_print_operation_get_default_page_setup")]
198 #[doc(alias = "get_default_page_setup")]
199 #[doc(alias = "default-page-setup")]
200 fn default_page_setup(&self) -> PageSetup {
201 unsafe {
202 from_glib_none(ffi::gtk_print_operation_get_default_page_setup(
203 self.as_ref().to_glib_none().0,
204 ))
205 }
206 }
207
208 #[doc(alias = "gtk_print_operation_get_embed_page_setup")]
209 #[doc(alias = "get_embed_page_setup")]
210 #[doc(alias = "embed-page-setup")]
211 fn embeds_page_setup(&self) -> bool {
212 unsafe {
213 from_glib(ffi::gtk_print_operation_get_embed_page_setup(
214 self.as_ref().to_glib_none().0,
215 ))
216 }
217 }
218
219 #[doc(alias = "gtk_print_operation_get_has_selection")]
220 #[doc(alias = "get_has_selection")]
221 #[doc(alias = "has-selection")]
222 fn has_selection(&self) -> bool {
223 unsafe {
224 from_glib(ffi::gtk_print_operation_get_has_selection(
225 self.as_ref().to_glib_none().0,
226 ))
227 }
228 }
229
230 #[doc(alias = "gtk_print_operation_get_n_pages_to_print")]
231 #[doc(alias = "get_n_pages_to_print")]
232 #[doc(alias = "n-pages-to-print")]
233 fn n_pages_to_print(&self) -> i32 {
234 unsafe { ffi::gtk_print_operation_get_n_pages_to_print(self.as_ref().to_glib_none().0) }
235 }
236
237 #[doc(alias = "gtk_print_operation_get_print_settings")]
238 #[doc(alias = "get_print_settings")]
239 #[doc(alias = "print-settings")]
240 fn print_settings(&self) -> Option<PrintSettings> {
241 unsafe {
242 from_glib_none(ffi::gtk_print_operation_get_print_settings(
243 self.as_ref().to_glib_none().0,
244 ))
245 }
246 }
247
248 #[doc(alias = "gtk_print_operation_get_status")]
249 #[doc(alias = "get_status")]
250 fn status(&self) -> PrintStatus {
251 unsafe {
252 from_glib(ffi::gtk_print_operation_get_status(
253 self.as_ref().to_glib_none().0,
254 ))
255 }
256 }
257
258 #[doc(alias = "gtk_print_operation_get_status_string")]
259 #[doc(alias = "get_status_string")]
260 #[doc(alias = "status-string")]
261 fn status_string(&self) -> glib::GString {
262 unsafe {
263 from_glib_none(ffi::gtk_print_operation_get_status_string(
264 self.as_ref().to_glib_none().0,
265 ))
266 }
267 }
268
269 #[doc(alias = "gtk_print_operation_get_support_selection")]
270 #[doc(alias = "get_support_selection")]
271 #[doc(alias = "support-selection")]
272 fn supports_selection(&self) -> bool {
273 unsafe {
274 from_glib(ffi::gtk_print_operation_get_support_selection(
275 self.as_ref().to_glib_none().0,
276 ))
277 }
278 }
279
280 #[doc(alias = "gtk_print_operation_is_finished")]
281 fn is_finished(&self) -> bool {
282 unsafe {
283 from_glib(ffi::gtk_print_operation_is_finished(
284 self.as_ref().to_glib_none().0,
285 ))
286 }
287 }
288
289 #[doc(alias = "gtk_print_operation_run")]
290 fn run(
291 &self,
292 action: PrintOperationAction,
293 parent: Option<&impl IsA<Window>>,
294 ) -> Result<PrintOperationResult, glib::Error> {
295 unsafe {
296 let mut error = std::ptr::null_mut();
297 let ret = ffi::gtk_print_operation_run(
298 self.as_ref().to_glib_none().0,
299 action.into_glib(),
300 parent.map(|p| p.as_ref()).to_glib_none().0,
301 &mut error,
302 );
303 if error.is_null() {
304 Ok(from_glib(ret))
305 } else {
306 Err(from_glib_full(error))
307 }
308 }
309 }
310
311 #[doc(alias = "gtk_print_operation_set_allow_async")]
312 #[doc(alias = "allow-async")]
313 fn set_allow_async(&self, allow_async: bool) {
314 unsafe {
315 ffi::gtk_print_operation_set_allow_async(
316 self.as_ref().to_glib_none().0,
317 allow_async.into_glib(),
318 );
319 }
320 }
321
322 #[doc(alias = "gtk_print_operation_set_current_page")]
323 #[doc(alias = "current-page")]
324 fn set_current_page(&self, current_page: i32) {
325 unsafe {
326 ffi::gtk_print_operation_set_current_page(self.as_ref().to_glib_none().0, current_page);
327 }
328 }
329
330 #[doc(alias = "gtk_print_operation_set_custom_tab_label")]
331 #[doc(alias = "custom-tab-label")]
332 fn set_custom_tab_label(&self, label: Option<&str>) {
333 unsafe {
334 ffi::gtk_print_operation_set_custom_tab_label(
335 self.as_ref().to_glib_none().0,
336 label.to_glib_none().0,
337 );
338 }
339 }
340
341 #[doc(alias = "gtk_print_operation_set_default_page_setup")]
342 #[doc(alias = "default-page-setup")]
343 fn set_default_page_setup(&self, default_page_setup: Option<&PageSetup>) {
344 unsafe {
345 ffi::gtk_print_operation_set_default_page_setup(
346 self.as_ref().to_glib_none().0,
347 default_page_setup.to_glib_none().0,
348 );
349 }
350 }
351
352 #[doc(alias = "gtk_print_operation_set_defer_drawing")]
353 fn set_defer_drawing(&self) {
354 unsafe {
355 ffi::gtk_print_operation_set_defer_drawing(self.as_ref().to_glib_none().0);
356 }
357 }
358
359 #[doc(alias = "gtk_print_operation_set_embed_page_setup")]
360 #[doc(alias = "embed-page-setup")]
361 fn set_embed_page_setup(&self, embed: bool) {
362 unsafe {
363 ffi::gtk_print_operation_set_embed_page_setup(
364 self.as_ref().to_glib_none().0,
365 embed.into_glib(),
366 );
367 }
368 }
369
370 #[doc(alias = "gtk_print_operation_set_export_filename")]
371 #[doc(alias = "export-filename")]
372 fn set_export_filename(&self, filename: impl AsRef<std::path::Path>) {
373 unsafe {
374 ffi::gtk_print_operation_set_export_filename(
375 self.as_ref().to_glib_none().0,
376 filename.as_ref().to_glib_none().0,
377 );
378 }
379 }
380
381 #[doc(alias = "gtk_print_operation_set_has_selection")]
382 #[doc(alias = "has-selection")]
383 fn set_has_selection(&self, has_selection: bool) {
384 unsafe {
385 ffi::gtk_print_operation_set_has_selection(
386 self.as_ref().to_glib_none().0,
387 has_selection.into_glib(),
388 );
389 }
390 }
391
392 #[doc(alias = "gtk_print_operation_set_job_name")]
393 #[doc(alias = "job-name")]
394 fn set_job_name(&self, job_name: &str) {
395 unsafe {
396 ffi::gtk_print_operation_set_job_name(
397 self.as_ref().to_glib_none().0,
398 job_name.to_glib_none().0,
399 );
400 }
401 }
402
403 #[doc(alias = "gtk_print_operation_set_n_pages")]
404 #[doc(alias = "n-pages")]
405 fn set_n_pages(&self, n_pages: i32) {
406 unsafe {
407 ffi::gtk_print_operation_set_n_pages(self.as_ref().to_glib_none().0, n_pages);
408 }
409 }
410
411 #[doc(alias = "gtk_print_operation_set_print_settings")]
412 #[doc(alias = "print-settings")]
413 fn set_print_settings(&self, print_settings: Option<&PrintSettings>) {
414 unsafe {
415 ffi::gtk_print_operation_set_print_settings(
416 self.as_ref().to_glib_none().0,
417 print_settings.to_glib_none().0,
418 );
419 }
420 }
421
422 #[doc(alias = "gtk_print_operation_set_show_progress")]
423 #[doc(alias = "show-progress")]
424 fn set_show_progress(&self, show_progress: bool) {
425 unsafe {
426 ffi::gtk_print_operation_set_show_progress(
427 self.as_ref().to_glib_none().0,
428 show_progress.into_glib(),
429 );
430 }
431 }
432
433 #[doc(alias = "gtk_print_operation_set_support_selection")]
434 #[doc(alias = "support-selection")]
435 fn set_support_selection(&self, support_selection: bool) {
436 unsafe {
437 ffi::gtk_print_operation_set_support_selection(
438 self.as_ref().to_glib_none().0,
439 support_selection.into_glib(),
440 );
441 }
442 }
443
444 #[doc(alias = "gtk_print_operation_set_track_print_status")]
445 #[doc(alias = "track-print-status")]
446 fn set_track_print_status(&self, track_status: bool) {
447 unsafe {
448 ffi::gtk_print_operation_set_track_print_status(
449 self.as_ref().to_glib_none().0,
450 track_status.into_glib(),
451 );
452 }
453 }
454
455 #[doc(alias = "gtk_print_operation_set_unit")]
456 #[doc(alias = "unit")]
457 fn set_unit(&self, unit: Unit) {
458 unsafe {
459 ffi::gtk_print_operation_set_unit(self.as_ref().to_glib_none().0, unit.into_glib());
460 }
461 }
462
463 #[doc(alias = "gtk_print_operation_set_use_full_page")]
464 #[doc(alias = "use-full-page")]
465 fn set_use_full_page(&self, full_page: bool) {
466 unsafe {
467 ffi::gtk_print_operation_set_use_full_page(
468 self.as_ref().to_glib_none().0,
469 full_page.into_glib(),
470 );
471 }
472 }
473
474 #[doc(alias = "allow-async")]
475 fn allows_async(&self) -> bool {
476 ObjectExt::property(self.as_ref(), "allow-async")
477 }
478
479 #[doc(alias = "current-page")]
480 fn current_page(&self) -> i32 {
481 ObjectExt::property(self.as_ref(), "current-page")
482 }
483
484 #[doc(alias = "custom-tab-label")]
485 fn custom_tab_label(&self) -> Option<glib::GString> {
486 ObjectExt::property(self.as_ref(), "custom-tab-label")
487 }
488
489 #[doc(alias = "export-filename")]
490 fn export_filename(&self) -> Option<glib::GString> {
491 ObjectExt::property(self.as_ref(), "export-filename")
492 }
493
494 #[doc(alias = "job-name")]
495 fn job_name(&self) -> Option<glib::GString> {
496 ObjectExt::property(self.as_ref(), "job-name")
497 }
498
499 #[doc(alias = "n-pages")]
500 fn n_pages(&self) -> i32 {
501 ObjectExt::property(self.as_ref(), "n-pages")
502 }
503
504 #[doc(alias = "show-progress")]
505 fn shows_progress(&self) -> bool {
506 ObjectExt::property(self.as_ref(), "show-progress")
507 }
508
509 #[doc(alias = "track-print-status")]
510 fn tracks_print_status(&self) -> bool {
511 ObjectExt::property(self.as_ref(), "track-print-status")
512 }
513
514 fn unit(&self) -> Unit {
515 ObjectExt::property(self.as_ref(), "unit")
516 }
517
518 #[doc(alias = "use-full-page")]
519 fn uses_full_page(&self) -> bool {
520 ObjectExt::property(self.as_ref(), "use-full-page")
521 }
522
523 #[doc(alias = "begin-print")]
524 fn connect_begin_print<F: Fn(&Self, &PrintContext) + 'static>(&self, f: F) -> SignalHandlerId {
525 unsafe extern "C" fn begin_print_trampoline<
526 P: IsA<PrintOperation>,
527 F: Fn(&P, &PrintContext) + 'static,
528 >(
529 this: *mut ffi::GtkPrintOperation,
530 context: *mut ffi::GtkPrintContext,
531 f: glib::ffi::gpointer,
532 ) {
533 let f: &F = &*(f as *const F);
534 f(
535 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
536 &from_glib_borrow(context),
537 )
538 }
539 unsafe {
540 let f: Box_<F> = Box_::new(f);
541 connect_raw(
542 self.as_ptr() as *mut _,
543 b"begin-print\0".as_ptr() as *const _,
544 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
545 begin_print_trampoline::<Self, F> as *const (),
546 )),
547 Box_::into_raw(f),
548 )
549 }
550 }
551
552 #[doc(alias = "create-custom-widget")]
553 fn connect_create_custom_widget<F: Fn(&Self) -> Option<glib::Object> + 'static>(
554 &self,
555 f: F,
556 ) -> SignalHandlerId {
557 unsafe extern "C" fn create_custom_widget_trampoline<
558 P: IsA<PrintOperation>,
559 F: Fn(&P) -> Option<glib::Object> + 'static,
560 >(
561 this: *mut ffi::GtkPrintOperation,
562 f: glib::ffi::gpointer,
563 ) -> *mut glib::gobject_ffi::GObject {
564 let f: &F = &*(f as *const F);
565 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref()) .to_glib_none()
567 .0
568 }
569 unsafe {
570 let f: Box_<F> = Box_::new(f);
571 connect_raw(
572 self.as_ptr() as *mut _,
573 b"create-custom-widget\0".as_ptr() as *const _,
574 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
575 create_custom_widget_trampoline::<Self, F> as *const (),
576 )),
577 Box_::into_raw(f),
578 )
579 }
580 }
581
582 #[doc(alias = "custom-widget-apply")]
583 fn connect_custom_widget_apply<F: Fn(&Self, &Widget) + 'static>(
584 &self,
585 f: F,
586 ) -> SignalHandlerId {
587 unsafe extern "C" fn custom_widget_apply_trampoline<
588 P: IsA<PrintOperation>,
589 F: Fn(&P, &Widget) + 'static,
590 >(
591 this: *mut ffi::GtkPrintOperation,
592 widget: *mut ffi::GtkWidget,
593 f: glib::ffi::gpointer,
594 ) {
595 let f: &F = &*(f as *const F);
596 f(
597 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
598 &from_glib_borrow(widget),
599 )
600 }
601 unsafe {
602 let f: Box_<F> = Box_::new(f);
603 connect_raw(
604 self.as_ptr() as *mut _,
605 b"custom-widget-apply\0".as_ptr() as *const _,
606 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
607 custom_widget_apply_trampoline::<Self, F> as *const (),
608 )),
609 Box_::into_raw(f),
610 )
611 }
612 }
613
614 #[doc(alias = "done")]
615 fn connect_done<F: Fn(&Self, PrintOperationResult) + 'static>(&self, f: F) -> SignalHandlerId {
616 unsafe extern "C" fn done_trampoline<
617 P: IsA<PrintOperation>,
618 F: Fn(&P, PrintOperationResult) + 'static,
619 >(
620 this: *mut ffi::GtkPrintOperation,
621 result: ffi::GtkPrintOperationResult,
622 f: glib::ffi::gpointer,
623 ) {
624 let f: &F = &*(f as *const F);
625 f(
626 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
627 from_glib(result),
628 )
629 }
630 unsafe {
631 let f: Box_<F> = Box_::new(f);
632 connect_raw(
633 self.as_ptr() as *mut _,
634 b"done\0".as_ptr() as *const _,
635 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
636 done_trampoline::<Self, F> as *const (),
637 )),
638 Box_::into_raw(f),
639 )
640 }
641 }
642
643 #[doc(alias = "draw-page")]
644 fn connect_draw_page<F: Fn(&Self, &PrintContext, i32) + 'static>(
645 &self,
646 f: F,
647 ) -> SignalHandlerId {
648 unsafe extern "C" fn draw_page_trampoline<
649 P: IsA<PrintOperation>,
650 F: Fn(&P, &PrintContext, i32) + 'static,
651 >(
652 this: *mut ffi::GtkPrintOperation,
653 context: *mut ffi::GtkPrintContext,
654 page_nr: std::ffi::c_int,
655 f: glib::ffi::gpointer,
656 ) {
657 let f: &F = &*(f as *const F);
658 f(
659 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
660 &from_glib_borrow(context),
661 page_nr,
662 )
663 }
664 unsafe {
665 let f: Box_<F> = Box_::new(f);
666 connect_raw(
667 self.as_ptr() as *mut _,
668 b"draw-page\0".as_ptr() as *const _,
669 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
670 draw_page_trampoline::<Self, F> as *const (),
671 )),
672 Box_::into_raw(f),
673 )
674 }
675 }
676
677 #[doc(alias = "end-print")]
678 fn connect_end_print<F: Fn(&Self, &PrintContext) + 'static>(&self, f: F) -> SignalHandlerId {
679 unsafe extern "C" fn end_print_trampoline<
680 P: IsA<PrintOperation>,
681 F: Fn(&P, &PrintContext) + 'static,
682 >(
683 this: *mut ffi::GtkPrintOperation,
684 context: *mut ffi::GtkPrintContext,
685 f: glib::ffi::gpointer,
686 ) {
687 let f: &F = &*(f as *const F);
688 f(
689 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
690 &from_glib_borrow(context),
691 )
692 }
693 unsafe {
694 let f: Box_<F> = Box_::new(f);
695 connect_raw(
696 self.as_ptr() as *mut _,
697 b"end-print\0".as_ptr() as *const _,
698 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
699 end_print_trampoline::<Self, F> as *const (),
700 )),
701 Box_::into_raw(f),
702 )
703 }
704 }
705
706 #[doc(alias = "paginate")]
707 fn connect_paginate<F: Fn(&Self, &PrintContext) -> bool + 'static>(
708 &self,
709 f: F,
710 ) -> SignalHandlerId {
711 unsafe extern "C" fn paginate_trampoline<
712 P: IsA<PrintOperation>,
713 F: Fn(&P, &PrintContext) -> bool + 'static,
714 >(
715 this: *mut ffi::GtkPrintOperation,
716 context: *mut ffi::GtkPrintContext,
717 f: glib::ffi::gpointer,
718 ) -> glib::ffi::gboolean {
719 let f: &F = &*(f as *const F);
720 f(
721 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
722 &from_glib_borrow(context),
723 )
724 .into_glib()
725 }
726 unsafe {
727 let f: Box_<F> = Box_::new(f);
728 connect_raw(
729 self.as_ptr() as *mut _,
730 b"paginate\0".as_ptr() as *const _,
731 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
732 paginate_trampoline::<Self, F> as *const (),
733 )),
734 Box_::into_raw(f),
735 )
736 }
737 }
738
739 #[doc(alias = "preview")]
740 fn connect_preview<
741 F: Fn(&Self, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static,
742 >(
743 &self,
744 f: F,
745 ) -> SignalHandlerId {
746 unsafe extern "C" fn preview_trampoline<
747 P: IsA<PrintOperation>,
748 F: Fn(&P, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static,
749 >(
750 this: *mut ffi::GtkPrintOperation,
751 preview: *mut ffi::GtkPrintOperationPreview,
752 context: *mut ffi::GtkPrintContext,
753 parent: *mut ffi::GtkWindow,
754 f: glib::ffi::gpointer,
755 ) -> glib::ffi::gboolean {
756 let f: &F = &*(f as *const F);
757 f(
758 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
759 &from_glib_borrow(preview),
760 &from_glib_borrow(context),
761 Option::<Window>::from_glib_borrow(parent).as_ref().as_ref(),
762 )
763 .into_glib()
764 }
765 unsafe {
766 let f: Box_<F> = Box_::new(f);
767 connect_raw(
768 self.as_ptr() as *mut _,
769 b"preview\0".as_ptr() as *const _,
770 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
771 preview_trampoline::<Self, F> as *const (),
772 )),
773 Box_::into_raw(f),
774 )
775 }
776 }
777
778 #[doc(alias = "request-page-setup")]
779 fn connect_request_page_setup<F: Fn(&Self, &PrintContext, i32, &PageSetup) + 'static>(
780 &self,
781 f: F,
782 ) -> SignalHandlerId {
783 unsafe extern "C" fn request_page_setup_trampoline<
784 P: IsA<PrintOperation>,
785 F: Fn(&P, &PrintContext, i32, &PageSetup) + 'static,
786 >(
787 this: *mut ffi::GtkPrintOperation,
788 context: *mut ffi::GtkPrintContext,
789 page_nr: std::ffi::c_int,
790 setup: *mut ffi::GtkPageSetup,
791 f: glib::ffi::gpointer,
792 ) {
793 let f: &F = &*(f as *const F);
794 f(
795 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
796 &from_glib_borrow(context),
797 page_nr,
798 &from_glib_borrow(setup),
799 )
800 }
801 unsafe {
802 let f: Box_<F> = Box_::new(f);
803 connect_raw(
804 self.as_ptr() as *mut _,
805 b"request-page-setup\0".as_ptr() as *const _,
806 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
807 request_page_setup_trampoline::<Self, F> as *const (),
808 )),
809 Box_::into_raw(f),
810 )
811 }
812 }
813
814 #[doc(alias = "status-changed")]
815 fn connect_status_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
816 unsafe extern "C" fn status_changed_trampoline<
817 P: IsA<PrintOperation>,
818 F: Fn(&P) + 'static,
819 >(
820 this: *mut ffi::GtkPrintOperation,
821 f: glib::ffi::gpointer,
822 ) {
823 let f: &F = &*(f as *const F);
824 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
825 }
826 unsafe {
827 let f: Box_<F> = Box_::new(f);
828 connect_raw(
829 self.as_ptr() as *mut _,
830 b"status-changed\0".as_ptr() as *const _,
831 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
832 status_changed_trampoline::<Self, F> as *const (),
833 )),
834 Box_::into_raw(f),
835 )
836 }
837 }
838
839 #[doc(alias = "update-custom-widget")]
840 fn connect_update_custom_widget<F: Fn(&Self, &Widget, &PageSetup, &PrintSettings) + 'static>(
841 &self,
842 f: F,
843 ) -> SignalHandlerId {
844 unsafe extern "C" fn update_custom_widget_trampoline<
845 P: IsA<PrintOperation>,
846 F: Fn(&P, &Widget, &PageSetup, &PrintSettings) + 'static,
847 >(
848 this: *mut ffi::GtkPrintOperation,
849 widget: *mut ffi::GtkWidget,
850 setup: *mut ffi::GtkPageSetup,
851 settings: *mut ffi::GtkPrintSettings,
852 f: glib::ffi::gpointer,
853 ) {
854 let f: &F = &*(f as *const F);
855 f(
856 PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
857 &from_glib_borrow(widget),
858 &from_glib_borrow(setup),
859 &from_glib_borrow(settings),
860 )
861 }
862 unsafe {
863 let f: Box_<F> = Box_::new(f);
864 connect_raw(
865 self.as_ptr() as *mut _,
866 b"update-custom-widget\0".as_ptr() as *const _,
867 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
868 update_custom_widget_trampoline::<Self, F> as *const (),
869 )),
870 Box_::into_raw(f),
871 )
872 }
873 }
874
875 #[doc(alias = "allow-async")]
876 fn connect_allow_async_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
877 unsafe extern "C" fn notify_allow_async_trampoline<
878 P: IsA<PrintOperation>,
879 F: Fn(&P) + 'static,
880 >(
881 this: *mut ffi::GtkPrintOperation,
882 _param_spec: glib::ffi::gpointer,
883 f: glib::ffi::gpointer,
884 ) {
885 let f: &F = &*(f as *const F);
886 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
887 }
888 unsafe {
889 let f: Box_<F> = Box_::new(f);
890 connect_raw(
891 self.as_ptr() as *mut _,
892 b"notify::allow-async\0".as_ptr() as *const _,
893 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
894 notify_allow_async_trampoline::<Self, F> as *const (),
895 )),
896 Box_::into_raw(f),
897 )
898 }
899 }
900
901 #[doc(alias = "current-page")]
902 fn connect_current_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
903 unsafe extern "C" fn notify_current_page_trampoline<
904 P: IsA<PrintOperation>,
905 F: Fn(&P) + 'static,
906 >(
907 this: *mut ffi::GtkPrintOperation,
908 _param_spec: glib::ffi::gpointer,
909 f: glib::ffi::gpointer,
910 ) {
911 let f: &F = &*(f as *const F);
912 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
913 }
914 unsafe {
915 let f: Box_<F> = Box_::new(f);
916 connect_raw(
917 self.as_ptr() as *mut _,
918 b"notify::current-page\0".as_ptr() as *const _,
919 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
920 notify_current_page_trampoline::<Self, F> as *const (),
921 )),
922 Box_::into_raw(f),
923 )
924 }
925 }
926
927 #[doc(alias = "custom-tab-label")]
928 fn connect_custom_tab_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
929 unsafe extern "C" fn notify_custom_tab_label_trampoline<
930 P: IsA<PrintOperation>,
931 F: Fn(&P) + 'static,
932 >(
933 this: *mut ffi::GtkPrintOperation,
934 _param_spec: glib::ffi::gpointer,
935 f: glib::ffi::gpointer,
936 ) {
937 let f: &F = &*(f as *const F);
938 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
939 }
940 unsafe {
941 let f: Box_<F> = Box_::new(f);
942 connect_raw(
943 self.as_ptr() as *mut _,
944 b"notify::custom-tab-label\0".as_ptr() as *const _,
945 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
946 notify_custom_tab_label_trampoline::<Self, F> as *const (),
947 )),
948 Box_::into_raw(f),
949 )
950 }
951 }
952
953 #[doc(alias = "default-page-setup")]
954 fn connect_default_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
955 unsafe extern "C" fn notify_default_page_setup_trampoline<
956 P: IsA<PrintOperation>,
957 F: Fn(&P) + 'static,
958 >(
959 this: *mut ffi::GtkPrintOperation,
960 _param_spec: glib::ffi::gpointer,
961 f: glib::ffi::gpointer,
962 ) {
963 let f: &F = &*(f as *const F);
964 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
965 }
966 unsafe {
967 let f: Box_<F> = Box_::new(f);
968 connect_raw(
969 self.as_ptr() as *mut _,
970 b"notify::default-page-setup\0".as_ptr() as *const _,
971 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
972 notify_default_page_setup_trampoline::<Self, F> as *const (),
973 )),
974 Box_::into_raw(f),
975 )
976 }
977 }
978
979 #[doc(alias = "embed-page-setup")]
980 fn connect_embed_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
981 unsafe extern "C" fn notify_embed_page_setup_trampoline<
982 P: IsA<PrintOperation>,
983 F: Fn(&P) + 'static,
984 >(
985 this: *mut ffi::GtkPrintOperation,
986 _param_spec: glib::ffi::gpointer,
987 f: glib::ffi::gpointer,
988 ) {
989 let f: &F = &*(f as *const F);
990 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
991 }
992 unsafe {
993 let f: Box_<F> = Box_::new(f);
994 connect_raw(
995 self.as_ptr() as *mut _,
996 b"notify::embed-page-setup\0".as_ptr() as *const _,
997 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
998 notify_embed_page_setup_trampoline::<Self, F> as *const (),
999 )),
1000 Box_::into_raw(f),
1001 )
1002 }
1003 }
1004
1005 #[doc(alias = "export-filename")]
1006 fn connect_export_filename_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1007 unsafe extern "C" fn notify_export_filename_trampoline<
1008 P: IsA<PrintOperation>,
1009 F: Fn(&P) + 'static,
1010 >(
1011 this: *mut ffi::GtkPrintOperation,
1012 _param_spec: glib::ffi::gpointer,
1013 f: glib::ffi::gpointer,
1014 ) {
1015 let f: &F = &*(f as *const F);
1016 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1017 }
1018 unsafe {
1019 let f: Box_<F> = Box_::new(f);
1020 connect_raw(
1021 self.as_ptr() as *mut _,
1022 b"notify::export-filename\0".as_ptr() as *const _,
1023 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1024 notify_export_filename_trampoline::<Self, F> as *const (),
1025 )),
1026 Box_::into_raw(f),
1027 )
1028 }
1029 }
1030
1031 #[doc(alias = "has-selection")]
1032 fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1033 unsafe extern "C" fn notify_has_selection_trampoline<
1034 P: IsA<PrintOperation>,
1035 F: Fn(&P) + 'static,
1036 >(
1037 this: *mut ffi::GtkPrintOperation,
1038 _param_spec: glib::ffi::gpointer,
1039 f: glib::ffi::gpointer,
1040 ) {
1041 let f: &F = &*(f as *const F);
1042 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1043 }
1044 unsafe {
1045 let f: Box_<F> = Box_::new(f);
1046 connect_raw(
1047 self.as_ptr() as *mut _,
1048 b"notify::has-selection\0".as_ptr() as *const _,
1049 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1050 notify_has_selection_trampoline::<Self, F> as *const (),
1051 )),
1052 Box_::into_raw(f),
1053 )
1054 }
1055 }
1056
1057 #[doc(alias = "job-name")]
1058 fn connect_job_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1059 unsafe extern "C" fn notify_job_name_trampoline<
1060 P: IsA<PrintOperation>,
1061 F: Fn(&P) + 'static,
1062 >(
1063 this: *mut ffi::GtkPrintOperation,
1064 _param_spec: glib::ffi::gpointer,
1065 f: glib::ffi::gpointer,
1066 ) {
1067 let f: &F = &*(f as *const F);
1068 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1069 }
1070 unsafe {
1071 let f: Box_<F> = Box_::new(f);
1072 connect_raw(
1073 self.as_ptr() as *mut _,
1074 b"notify::job-name\0".as_ptr() as *const _,
1075 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1076 notify_job_name_trampoline::<Self, F> as *const (),
1077 )),
1078 Box_::into_raw(f),
1079 )
1080 }
1081 }
1082
1083 #[doc(alias = "n-pages")]
1084 fn connect_n_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1085 unsafe extern "C" fn notify_n_pages_trampoline<
1086 P: IsA<PrintOperation>,
1087 F: Fn(&P) + 'static,
1088 >(
1089 this: *mut ffi::GtkPrintOperation,
1090 _param_spec: glib::ffi::gpointer,
1091 f: glib::ffi::gpointer,
1092 ) {
1093 let f: &F = &*(f as *const F);
1094 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1095 }
1096 unsafe {
1097 let f: Box_<F> = Box_::new(f);
1098 connect_raw(
1099 self.as_ptr() as *mut _,
1100 b"notify::n-pages\0".as_ptr() as *const _,
1101 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1102 notify_n_pages_trampoline::<Self, F> as *const (),
1103 )),
1104 Box_::into_raw(f),
1105 )
1106 }
1107 }
1108
1109 #[doc(alias = "n-pages-to-print")]
1110 fn connect_n_pages_to_print_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1111 unsafe extern "C" fn notify_n_pages_to_print_trampoline<
1112 P: IsA<PrintOperation>,
1113 F: Fn(&P) + 'static,
1114 >(
1115 this: *mut ffi::GtkPrintOperation,
1116 _param_spec: glib::ffi::gpointer,
1117 f: glib::ffi::gpointer,
1118 ) {
1119 let f: &F = &*(f as *const F);
1120 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1121 }
1122 unsafe {
1123 let f: Box_<F> = Box_::new(f);
1124 connect_raw(
1125 self.as_ptr() as *mut _,
1126 b"notify::n-pages-to-print\0".as_ptr() as *const _,
1127 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1128 notify_n_pages_to_print_trampoline::<Self, F> as *const (),
1129 )),
1130 Box_::into_raw(f),
1131 )
1132 }
1133 }
1134
1135 #[doc(alias = "print-settings")]
1136 fn connect_print_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1137 unsafe extern "C" fn notify_print_settings_trampoline<
1138 P: IsA<PrintOperation>,
1139 F: Fn(&P) + 'static,
1140 >(
1141 this: *mut ffi::GtkPrintOperation,
1142 _param_spec: glib::ffi::gpointer,
1143 f: glib::ffi::gpointer,
1144 ) {
1145 let f: &F = &*(f as *const F);
1146 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1147 }
1148 unsafe {
1149 let f: Box_<F> = Box_::new(f);
1150 connect_raw(
1151 self.as_ptr() as *mut _,
1152 b"notify::print-settings\0".as_ptr() as *const _,
1153 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1154 notify_print_settings_trampoline::<Self, F> as *const (),
1155 )),
1156 Box_::into_raw(f),
1157 )
1158 }
1159 }
1160
1161 #[doc(alias = "show-progress")]
1162 fn connect_show_progress_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1163 unsafe extern "C" fn notify_show_progress_trampoline<
1164 P: IsA<PrintOperation>,
1165 F: Fn(&P) + 'static,
1166 >(
1167 this: *mut ffi::GtkPrintOperation,
1168 _param_spec: glib::ffi::gpointer,
1169 f: glib::ffi::gpointer,
1170 ) {
1171 let f: &F = &*(f as *const F);
1172 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1173 }
1174 unsafe {
1175 let f: Box_<F> = Box_::new(f);
1176 connect_raw(
1177 self.as_ptr() as *mut _,
1178 b"notify::show-progress\0".as_ptr() as *const _,
1179 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1180 notify_show_progress_trampoline::<Self, F> as *const (),
1181 )),
1182 Box_::into_raw(f),
1183 )
1184 }
1185 }
1186
1187 #[doc(alias = "status")]
1188 fn connect_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1189 unsafe extern "C" fn notify_status_trampoline<
1190 P: IsA<PrintOperation>,
1191 F: Fn(&P) + 'static,
1192 >(
1193 this: *mut ffi::GtkPrintOperation,
1194 _param_spec: glib::ffi::gpointer,
1195 f: glib::ffi::gpointer,
1196 ) {
1197 let f: &F = &*(f as *const F);
1198 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1199 }
1200 unsafe {
1201 let f: Box_<F> = Box_::new(f);
1202 connect_raw(
1203 self.as_ptr() as *mut _,
1204 b"notify::status\0".as_ptr() as *const _,
1205 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1206 notify_status_trampoline::<Self, F> as *const (),
1207 )),
1208 Box_::into_raw(f),
1209 )
1210 }
1211 }
1212
1213 #[doc(alias = "status-string")]
1214 fn connect_status_string_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1215 unsafe extern "C" fn notify_status_string_trampoline<
1216 P: IsA<PrintOperation>,
1217 F: Fn(&P) + 'static,
1218 >(
1219 this: *mut ffi::GtkPrintOperation,
1220 _param_spec: glib::ffi::gpointer,
1221 f: glib::ffi::gpointer,
1222 ) {
1223 let f: &F = &*(f as *const F);
1224 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1225 }
1226 unsafe {
1227 let f: Box_<F> = Box_::new(f);
1228 connect_raw(
1229 self.as_ptr() as *mut _,
1230 b"notify::status-string\0".as_ptr() as *const _,
1231 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1232 notify_status_string_trampoline::<Self, F> as *const (),
1233 )),
1234 Box_::into_raw(f),
1235 )
1236 }
1237 }
1238
1239 #[doc(alias = "support-selection")]
1240 fn connect_support_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1241 unsafe extern "C" fn notify_support_selection_trampoline<
1242 P: IsA<PrintOperation>,
1243 F: Fn(&P) + 'static,
1244 >(
1245 this: *mut ffi::GtkPrintOperation,
1246 _param_spec: glib::ffi::gpointer,
1247 f: glib::ffi::gpointer,
1248 ) {
1249 let f: &F = &*(f as *const F);
1250 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1251 }
1252 unsafe {
1253 let f: Box_<F> = Box_::new(f);
1254 connect_raw(
1255 self.as_ptr() as *mut _,
1256 b"notify::support-selection\0".as_ptr() as *const _,
1257 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1258 notify_support_selection_trampoline::<Self, F> as *const (),
1259 )),
1260 Box_::into_raw(f),
1261 )
1262 }
1263 }
1264
1265 #[doc(alias = "track-print-status")]
1266 fn connect_track_print_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1267 unsafe extern "C" fn notify_track_print_status_trampoline<
1268 P: IsA<PrintOperation>,
1269 F: Fn(&P) + 'static,
1270 >(
1271 this: *mut ffi::GtkPrintOperation,
1272 _param_spec: glib::ffi::gpointer,
1273 f: glib::ffi::gpointer,
1274 ) {
1275 let f: &F = &*(f as *const F);
1276 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1277 }
1278 unsafe {
1279 let f: Box_<F> = Box_::new(f);
1280 connect_raw(
1281 self.as_ptr() as *mut _,
1282 b"notify::track-print-status\0".as_ptr() as *const _,
1283 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1284 notify_track_print_status_trampoline::<Self, F> as *const (),
1285 )),
1286 Box_::into_raw(f),
1287 )
1288 }
1289 }
1290
1291 #[doc(alias = "unit")]
1292 fn connect_unit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1293 unsafe extern "C" fn notify_unit_trampoline<P: IsA<PrintOperation>, F: Fn(&P) + 'static>(
1294 this: *mut ffi::GtkPrintOperation,
1295 _param_spec: glib::ffi::gpointer,
1296 f: glib::ffi::gpointer,
1297 ) {
1298 let f: &F = &*(f as *const F);
1299 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1300 }
1301 unsafe {
1302 let f: Box_<F> = Box_::new(f);
1303 connect_raw(
1304 self.as_ptr() as *mut _,
1305 b"notify::unit\0".as_ptr() as *const _,
1306 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1307 notify_unit_trampoline::<Self, F> as *const (),
1308 )),
1309 Box_::into_raw(f),
1310 )
1311 }
1312 }
1313
1314 #[doc(alias = "use-full-page")]
1315 fn connect_use_full_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1316 unsafe extern "C" fn notify_use_full_page_trampoline<
1317 P: IsA<PrintOperation>,
1318 F: Fn(&P) + 'static,
1319 >(
1320 this: *mut ffi::GtkPrintOperation,
1321 _param_spec: glib::ffi::gpointer,
1322 f: glib::ffi::gpointer,
1323 ) {
1324 let f: &F = &*(f as *const F);
1325 f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1326 }
1327 unsafe {
1328 let f: Box_<F> = Box_::new(f);
1329 connect_raw(
1330 self.as_ptr() as *mut _,
1331 b"notify::use-full-page\0".as_ptr() as *const _,
1332 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1333 notify_use_full_page_trampoline::<Self, F> as *const (),
1334 )),
1335 Box_::into_raw(f),
1336 )
1337 }
1338 }
1339}
1340
1341impl<O: IsA<PrintOperation>> PrintOperationExt for O {}