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