Skip to main content

gtk4/auto/
print_operation.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    PageSetup, PrintContext, PrintOperationAction, PrintOperationPreview, PrintOperationResult,
7    PrintSettings, PrintStatus, Unit, Widget, Window, ffi,
8};
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{SignalHandlerId, connect_raw},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// High-level, portable printing API.
19    ///
20    /// It looks a bit different than other GTK dialogs such as the
21    /// [`FileChooser`][crate::FileChooser], since some platforms don’t expose enough
22    /// infrastructure to implement a good print dialog. On such
23    /// platforms, [`PrintOperation`][crate::PrintOperation] uses the native print dialog.
24    /// On platforms which do not provide a native print dialog, GTK
25    /// uses its own, see [`PrintUnixDialog`][crate::PrintUnixDialog].
26    ///
27    /// The typical way to use the high-level printing API is to create
28    /// a [`PrintOperation`][crate::PrintOperation] object with [`new()`][Self::new()]
29    /// when the user selects to print. Then you set some properties on it,
30    /// e.g. the page size, any [`PrintSettings`][crate::PrintSettings] from previous print
31    /// operations, the number of pages, the current page, etc.
32    ///
33    /// Then you start the print operation by calling [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()].
34    /// It will then show a dialog, let the user select a printer and options.
35    /// When the user finished the dialog, various signals will be emitted on
36    /// the [`PrintOperation`][crate::PrintOperation], the main one being
37    /// [`draw-page`][struct@crate::PrintOperation#draw-page], which you are supposed to handle
38    /// and render the page on the provided [`PrintContext`][crate::PrintContext] using Cairo.
39    ///
40    /// # The high-level printing API
41    ///
42    /// **⚠️ The following code is in c ⚠️**
43    ///
44    /// ```c
45    /// static GtkPrintSettings *settings = NULL;
46    ///
47    /// static void
48    /// do_print (void)
49    /// {
50    ///   GtkPrintOperation *print;
51    ///   GtkPrintOperationResult res;
52    ///
53    ///   print = gtk_print_operation_new ();
54    ///
55    ///   if (settings != NULL)
56    ///     gtk_print_operation_set_print_settings (print, settings);
57    ///
58    ///   g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
59    ///   g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
60    ///
61    ///   res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
62    ///                                  GTK_WINDOW (main_window), NULL);
63    ///
64    ///   if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
65    ///     {
66    ///       if (settings != NULL)
67    ///         g_object_unref (settings);
68    ///       settings = g_object_ref (gtk_print_operation_get_print_settings (print));
69    ///     }
70    ///
71    ///   g_object_unref (print);
72    /// }
73    /// ```
74    ///
75    /// By default [`PrintOperation`][crate::PrintOperation] uses an external application to do
76    /// print preview. To implement a custom print preview, an application
77    /// must connect to the preview signal. The functions
78    /// [`PrintOperationPreviewExt::render_page()`][crate::prelude::PrintOperationPreviewExt::render_page()],
79    /// [`PrintOperationPreviewExt::end_preview()`][crate::prelude::PrintOperationPreviewExt::end_preview()] and
80    /// [`PrintOperationPreviewExt::is_selected()`][crate::prelude::PrintOperationPreviewExt::is_selected()]
81    /// are useful when implementing a print preview.
82    ///
83    /// ## Properties
84    ///
85    ///
86    /// #### `allow-async`
87    ///  Determines whether the print operation may run asynchronously or not.
88    ///
89    /// Some systems don't support asynchronous printing, but those that do
90    /// will return [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] as the status, and
91    /// emit the [`done`][struct@crate::PrintOperation#done] signal when the operation
92    /// is actually done.
93    ///
94    /// The Windows port does not support asynchronous operation at all (this
95    /// is unlikely to change). On other platforms, all actions except for
96    /// [`PrintOperationAction::Export`][crate::PrintOperationAction::Export] support asynchronous operation.
97    ///
98    /// Readable | Writable
99    ///
100    ///
101    /// #### `current-page`
102    ///  The current page in the document.
103    ///
104    /// If this is set before [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
105    /// the user will be able to select to print only the current page.
106    ///
107    /// Note that this only makes sense for pre-paginated documents.
108    ///
109    /// Readable | Writable
110    ///
111    ///
112    /// #### `custom-tab-label`
113    ///  Used as the label of the tab containing custom widgets.
114    ///
115    /// Note that this property may be ignored on some platforms.
116    ///
117    /// If this is [`None`], GTK uses a default label.
118    ///
119    /// Readable | Writable
120    ///
121    ///
122    /// #### `default-page-setup`
123    ///  The [`PageSetup`][crate::PageSetup] used by default.
124    ///
125    /// This page setup will be used by [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
126    /// but it can be overridden on a per-page basis by connecting
127    /// to the [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] signal.
128    ///
129    /// Readable | Writable
130    ///
131    ///
132    /// #### `embed-page-setup`
133    ///  If [`true`], page size combo box and orientation combo box
134    /// are embedded into page setup page.
135    ///
136    /// Readable | Writable
137    ///
138    ///
139    /// #### `export-filename`
140    ///  The name of a file to generate instead of showing the print dialog.
141    ///
142    /// Currently, PDF is the only supported format.
143    ///
144    /// The intended use of this property is for implementing
145    /// “Export to PDF” actions.
146    ///
147    /// “Print to PDF” support is independent of this and is done
148    /// by letting the user pick the “Print to PDF” item from the
149    /// list of printers in the print dialog.
150    ///
151    /// Readable | Writable
152    ///
153    ///
154    /// #### `has-selection`
155    ///  Determines whether there is a selection in your application.
156    ///
157    /// This can allow your application to print the selection.
158    /// This is typically used to make a "Selection" button sensitive.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `job-name`
164    ///  A string used to identify the job (e.g. in monitoring
165    /// applications like eggcups).
166    ///
167    /// If you don't set a job name, GTK picks a default one
168    /// by numbering successive print jobs.
169    ///
170    /// Readable | Writable
171    ///
172    ///
173    /// #### `n-pages`
174    ///  The number of pages in the document.
175    ///
176    /// This must be set to a positive number before the rendering
177    /// starts. It may be set in a [`begin-print`][struct@crate::PrintOperation#begin-print]
178    /// signal handler.
179    ///
180    /// Note that the page numbers passed to the
181    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] and
182    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e.
183    /// if the user chooses to print all pages, the last ::draw-page signal
184    /// will be for page @n_pages - 1.
185    ///
186    /// Readable | Writable
187    ///
188    ///
189    /// #### `n-pages-to-print`
190    ///  The number of pages that will be printed.
191    ///
192    /// Note that this value is set during print preparation phase
193    /// ([`PrintStatus::Preparing`][crate::PrintStatus::Preparing]), so this value should never be
194    /// get before the data generation phase ([`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData]).
195    /// You can connect to the [`status-changed`][struct@crate::PrintOperation#status-changed] signal
196    /// and call [`PrintOperationExt::n_pages_to_print()`][crate::prelude::PrintOperationExt::n_pages_to_print()] when
197    /// print status is [`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData].
198    ///
199    /// This is typically used to track the progress of print operation.
200    ///
201    /// Readable
202    ///
203    ///
204    /// #### `print-settings`
205    ///  The [`PrintSettings`][crate::PrintSettings] used for initializing the dialog.
206    ///
207    /// Setting this property is typically used to re-establish
208    /// print settings from a previous print operation, see
209    /// [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()].
210    ///
211    /// Readable | Writable
212    ///
213    ///
214    /// #### `show-progress`
215    ///  Determines whether to show a progress dialog during the
216    /// print operation.
217    ///
218    /// Readable | Writable
219    ///
220    ///
221    /// #### `status`
222    ///  The status of the print operation.
223    ///
224    /// Readable
225    ///
226    ///
227    /// #### `status-string`
228    ///  A string representation of the status of the print operation.
229    ///
230    /// The string is translated and suitable for displaying the print
231    /// status e.g. in a [`Statusbar`][crate::Statusbar].
232    ///
233    /// See the [`status`][struct@crate::PrintOperation#status] property for a status
234    /// value that is suitable for programmatic use.
235    ///
236    /// Readable
237    ///
238    ///
239    /// #### `support-selection`
240    ///  If [`true`], the print operation will support print of selection.
241    ///
242    /// This allows the print dialog to show a "Selection" button.
243    ///
244    /// Readable | Writable
245    ///
246    ///
247    /// #### `track-print-status`
248    ///  If [`true`], the print operation will try to continue report on
249    /// the status of the print job in the printer queues and printer.
250    ///
251    /// This can allow your application to show things like “out of paper”
252    /// issues, and when the print job actually reaches the printer.
253    /// However, this is often implemented using polling, and should
254    /// not be enabled unless needed.
255    ///
256    /// Readable | Writable
257    ///
258    ///
259    /// #### `unit`
260    ///  The transformation for the cairo context obtained from
261    /// [`PrintContext`][crate::PrintContext] is set up in such a way that distances
262    /// are measured in units of @unit.
263    ///
264    /// Readable | Writable
265    ///
266    ///
267    /// #### `use-full-page`
268    ///  If [`true`], the transformation for the cairo context obtained
269    /// from [`PrintContext`][crate::PrintContext] puts the origin at the top left corner
270    /// of the page.
271    ///
272    /// This may not be the top left corner of the sheet, depending on
273    /// page orientation and the number of pages per sheet. Otherwise,
274    /// the origin is at the top left corner of the imageable area (i.e.
275    /// inside the margins).
276    ///
277    /// Readable | Writable
278    ///
279    /// ## Signals
280    ///
281    ///
282    /// #### `begin-print`
283    ///  Emitted after the user has finished changing print settings
284    /// in the dialog, before the actual rendering starts.
285    ///
286    /// A typical use for ::begin-print is to use the parameters from the
287    /// [`PrintContext`][crate::PrintContext] and paginate the document accordingly,
288    /// and then set the number of pages with
289    /// [`PrintOperationExt::set_n_pages()`][crate::prelude::PrintOperationExt::set_n_pages()].
290    ///
291    ///
292    ///
293    ///
294    /// #### `create-custom-widget`
295    ///  Emitted when displaying the print dialog.
296    ///
297    /// If you return a widget in a handler for this signal it will be
298    /// added to a custom tab in the print dialog. You typically return a
299    /// container widget with multiple widgets in it.
300    ///
301    /// The print dialog owns the returned widget, and its lifetime is not
302    /// controlled by the application. However, the widget is guaranteed
303    /// to stay around until the [`custom-widget-apply`][struct@crate::PrintOperation#custom-widget-apply]
304    /// signal is emitted on the operation. Then you can read out any
305    /// information you need from the widgets.
306    ///
307    ///
308    ///
309    ///
310    /// #### `custom-widget-apply`
311    ///  Emitted right before ::begin-print if you added
312    /// a custom widget in the ::create-custom-widget handler.
313    ///
314    /// When you get this signal you should read the information from the
315    /// custom widgets, as the widgets are not guaranteed to be around at a
316    /// later time.
317    ///
318    ///
319    ///
320    ///
321    /// #### `done`
322    ///  Emitted when the print operation run has finished doing
323    /// everything required for printing.
324    ///
325    /// @result gives you information about what happened during the run.
326    /// If @result is [`PrintOperationResult::Error`][crate::PrintOperationResult::Error] then you can call
327    /// `Gtk::PrintOperation::get_error()` for more information.
328    ///
329    /// If you enabled print status tracking then
330    /// [`PrintOperationExt::is_finished()`][crate::prelude::PrintOperationExt::is_finished()] may still return [`false`]
331    /// after the ::done signal was emitted.
332    ///
333    ///
334    ///
335    ///
336    /// #### `draw-page`
337    ///  layout_height);
338    ///   text_height = (double)layout_height / PANGO_SCALE;
339    ///
340    ///   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
341    ///   pango_cairo_show_layout (cr, layout);
342    ///
343    ///   g_object_unref (layout);
344    /// }
345    /// ```text
346    ///
347    /// Use [`PrintOperationExt::set_use_full_page()`][crate::prelude::PrintOperationExt::set_use_full_page()] and
348    /// [`PrintOperationExt::set_unit()`][crate::prelude::PrintOperationExt::set_unit()] before starting the print
349    /// operation to set up the transformation of the cairo context
350    /// according to your needs.
351    ///
352    ///
353    ///
354    ///
355    /// #### `end-print`
356    ///  Emitted after all pages have been rendered.
357    ///
358    /// A handler for this signal can clean up any resources that have
359    /// been allocated in the [`begin-print`][struct@crate::PrintOperation#begin-print] handler.
360    ///
361    ///
362    ///
363    ///
364    /// #### `paginate`
365    ///  Emitted after the ::begin-print signal, but before the actual rendering
366    /// starts.
367    ///
368    /// It keeps getting emitted until a connected signal handler returns [`true`].
369    ///
370    /// The ::paginate signal is intended to be used for paginating a document
371    /// in small chunks, to avoid blocking the user interface for a long
372    /// time. The signal handler should update the number of pages using
373    /// [`PrintOperationExt::set_n_pages()`][crate::prelude::PrintOperationExt::set_n_pages()], and return [`true`] if the document
374    /// has been completely paginated.
375    ///
376    /// If you don't need to do pagination in chunks, you can simply do
377    /// it all in the ::begin-print handler, and set the number of pages
378    /// from there.
379    ///
380    ///
381    ///
382    ///
383    /// #### `preview`
384    ///  Gets emitted when a preview is requested from the native dialog.
385    ///
386    /// The default handler for this signal uses an external viewer
387    /// application to preview.
388    ///
389    /// To implement a custom print preview, an application must return
390    /// [`true`] from its handler for this signal. In order to use the
391    /// provided @context for the preview implementation, it must be
392    /// given a suitable cairo context with
393    /// [`PrintContext::set_cairo_context()`][crate::PrintContext::set_cairo_context()].
394    ///
395    /// The custom preview implementation can use
396    /// [`PrintOperationPreviewExt::is_selected()`][crate::prelude::PrintOperationPreviewExt::is_selected()] and
397    /// [`PrintOperationPreviewExt::render_page()`][crate::prelude::PrintOperationPreviewExt::render_page()] to find pages which
398    /// are selected for print and render them. The preview must be
399    /// finished by calling [`PrintOperationPreviewExt::end_preview()`][crate::prelude::PrintOperationPreviewExt::end_preview()]
400    /// (typically in response to the user clicking a close button).
401    ///
402    ///
403    ///
404    ///
405    /// #### `request-page-setup`
406    ///  Emitted once for every page that is printed.
407    ///
408    /// This gives the application a chance to modify the page setup.
409    /// Any changes done to @setup will be in force only for printing
410    /// this page.
411    ///
412    ///
413    ///
414    ///
415    /// #### `status-changed`
416    ///  Emitted at between the various phases of the print operation.
417    ///
418    /// See [`PrintStatus`][crate::PrintStatus] for the phases that are being discriminated.
419    /// Use [`PrintOperationExt::status()`][crate::prelude::PrintOperationExt::status()] to find out the current
420    /// status.
421    ///
422    ///
423    ///
424    ///
425    /// #### `update-custom-widget`
426    ///  Emitted after change of selected printer.
427    ///
428    /// The actual page setup and print settings are passed to the custom
429    /// widget, which can actualize itself according to this change.
430    ///
431    ///
432    /// <details><summary><h4>PrintOperationPreview</h4></summary>
433    ///
434    ///
435    /// #### `got-page-size`
436    ///  Emitted once for each page that gets rendered to the preview.
437    ///
438    /// A handler for this signal should update the @context
439    /// according to @page_setup and set up a suitable cairo
440    /// context, using [`PrintContext::set_cairo_context()`][crate::PrintContext::set_cairo_context()].
441    ///
442    ///
443    ///
444    ///
445    /// #### `ready`
446    ///  The ::ready signal gets emitted once per preview operation,
447    /// before the first page is rendered.
448    ///
449    /// A handler for this signal can be used for setup tasks.
450    ///
451    ///
452    /// </details>
453    ///
454    /// # Implements
455    ///
456    /// [`PrintOperationExt`][trait@crate::prelude::PrintOperationExt], [`trait@glib::ObjectExt`], [`PrintOperationPreviewExt`][trait@crate::prelude::PrintOperationPreviewExt]
457    #[doc(alias = "GtkPrintOperation")]
458    pub struct PrintOperation(Object<ffi::GtkPrintOperation, ffi::GtkPrintOperationClass>) @implements PrintOperationPreview;
459
460    match fn {
461        type_ => || ffi::gtk_print_operation_get_type(),
462    }
463}
464
465impl PrintOperation {
466    pub const NONE: Option<&'static PrintOperation> = None;
467
468    /// Creates a new [`PrintOperation`][crate::PrintOperation].
469    ///
470    /// # Returns
471    ///
472    /// a new [`PrintOperation`][crate::PrintOperation]
473    #[doc(alias = "gtk_print_operation_new")]
474    pub fn new() -> PrintOperation {
475        assert_initialized_main_thread!();
476        unsafe { from_glib_full(ffi::gtk_print_operation_new()) }
477    }
478
479    // rustdoc-stripper-ignore-next
480    /// Creates a new builder-pattern struct instance to construct [`PrintOperation`] objects.
481    ///
482    /// This method returns an instance of [`PrintOperationBuilder`](crate::builders::PrintOperationBuilder) which can be used to create [`PrintOperation`] objects.
483    pub fn builder() -> PrintOperationBuilder {
484        PrintOperationBuilder::new()
485    }
486}
487
488impl Default for PrintOperation {
489    fn default() -> Self {
490        Self::new()
491    }
492}
493
494// rustdoc-stripper-ignore-next
495/// A [builder-pattern] type to construct [`PrintOperation`] objects.
496///
497/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
498#[must_use = "The builder must be built to be used"]
499pub struct PrintOperationBuilder {
500    builder: glib::object::ObjectBuilder<'static, PrintOperation>,
501}
502
503impl PrintOperationBuilder {
504    fn new() -> Self {
505        Self {
506            builder: glib::object::Object::builder(),
507        }
508    }
509
510    /// Determines whether the print operation may run asynchronously or not.
511    ///
512    /// Some systems don't support asynchronous printing, but those that do
513    /// will return [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] as the status, and
514    /// emit the [`done`][struct@crate::PrintOperation#done] signal when the operation
515    /// is actually done.
516    ///
517    /// The Windows port does not support asynchronous operation at all (this
518    /// is unlikely to change). On other platforms, all actions except for
519    /// [`PrintOperationAction::Export`][crate::PrintOperationAction::Export] support asynchronous operation.
520    pub fn allow_async(self, allow_async: bool) -> Self {
521        Self {
522            builder: self.builder.property("allow-async", allow_async),
523        }
524    }
525
526    /// The current page in the document.
527    ///
528    /// If this is set before [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
529    /// the user will be able to select to print only the current page.
530    ///
531    /// Note that this only makes sense for pre-paginated documents.
532    pub fn current_page(self, current_page: i32) -> Self {
533        Self {
534            builder: self.builder.property("current-page", current_page),
535        }
536    }
537
538    /// Used as the label of the tab containing custom widgets.
539    ///
540    /// Note that this property may be ignored on some platforms.
541    ///
542    /// If this is [`None`], GTK uses a default label.
543    pub fn custom_tab_label(self, custom_tab_label: impl Into<glib::GString>) -> Self {
544        Self {
545            builder: self
546                .builder
547                .property("custom-tab-label", custom_tab_label.into()),
548        }
549    }
550
551    /// The [`PageSetup`][crate::PageSetup] used by default.
552    ///
553    /// This page setup will be used by [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
554    /// but it can be overridden on a per-page basis by connecting
555    /// to the [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] signal.
556    pub fn default_page_setup(self, default_page_setup: &PageSetup) -> Self {
557        Self {
558            builder: self
559                .builder
560                .property("default-page-setup", default_page_setup.clone()),
561        }
562    }
563
564    /// If [`true`], page size combo box and orientation combo box
565    /// are embedded into page setup page.
566    pub fn embed_page_setup(self, embed_page_setup: bool) -> Self {
567        Self {
568            builder: self.builder.property("embed-page-setup", embed_page_setup),
569        }
570    }
571
572    /// The name of a file to generate instead of showing the print dialog.
573    ///
574    /// Currently, PDF is the only supported format.
575    ///
576    /// The intended use of this property is for implementing
577    /// “Export to PDF” actions.
578    ///
579    /// “Print to PDF” support is independent of this and is done
580    /// by letting the user pick the “Print to PDF” item from the
581    /// list of printers in the print dialog.
582    pub fn export_filename(self, export_filename: impl Into<glib::GString>) -> Self {
583        Self {
584            builder: self
585                .builder
586                .property("export-filename", export_filename.into()),
587        }
588    }
589
590    /// Determines whether there is a selection in your application.
591    ///
592    /// This can allow your application to print the selection.
593    /// This is typically used to make a "Selection" button sensitive.
594    pub fn has_selection(self, has_selection: bool) -> Self {
595        Self {
596            builder: self.builder.property("has-selection", has_selection),
597        }
598    }
599
600    /// A string used to identify the job (e.g. in monitoring
601    /// applications like eggcups).
602    ///
603    /// If you don't set a job name, GTK picks a default one
604    /// by numbering successive print jobs.
605    pub fn job_name(self, job_name: impl Into<glib::GString>) -> Self {
606        Self {
607            builder: self.builder.property("job-name", job_name.into()),
608        }
609    }
610
611    /// The number of pages in the document.
612    ///
613    /// This must be set to a positive number before the rendering
614    /// starts. It may be set in a [`begin-print`][struct@crate::PrintOperation#begin-print]
615    /// signal handler.
616    ///
617    /// Note that the page numbers passed to the
618    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] and
619    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e.
620    /// if the user chooses to print all pages, the last ::draw-page signal
621    /// will be for page @n_pages - 1.
622    pub fn n_pages(self, n_pages: i32) -> Self {
623        Self {
624            builder: self.builder.property("n-pages", n_pages),
625        }
626    }
627
628    /// The [`PrintSettings`][crate::PrintSettings] used for initializing the dialog.
629    ///
630    /// Setting this property is typically used to re-establish
631    /// print settings from a previous print operation, see
632    /// [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()].
633    pub fn print_settings(self, print_settings: &PrintSettings) -> Self {
634        Self {
635            builder: self
636                .builder
637                .property("print-settings", print_settings.clone()),
638        }
639    }
640
641    /// Determines whether to show a progress dialog during the
642    /// print operation.
643    pub fn show_progress(self, show_progress: bool) -> Self {
644        Self {
645            builder: self.builder.property("show-progress", show_progress),
646        }
647    }
648
649    /// If [`true`], the print operation will support print of selection.
650    ///
651    /// This allows the print dialog to show a "Selection" button.
652    pub fn support_selection(self, support_selection: bool) -> Self {
653        Self {
654            builder: self
655                .builder
656                .property("support-selection", support_selection),
657        }
658    }
659
660    /// If [`true`], the print operation will try to continue report on
661    /// the status of the print job in the printer queues and printer.
662    ///
663    /// This can allow your application to show things like “out of paper”
664    /// issues, and when the print job actually reaches the printer.
665    /// However, this is often implemented using polling, and should
666    /// not be enabled unless needed.
667    pub fn track_print_status(self, track_print_status: bool) -> Self {
668        Self {
669            builder: self
670                .builder
671                .property("track-print-status", track_print_status),
672        }
673    }
674
675    /// The transformation for the cairo context obtained from
676    /// [`PrintContext`][crate::PrintContext] is set up in such a way that distances
677    /// are measured in units of @unit.
678    pub fn unit(self, unit: Unit) -> Self {
679        Self {
680            builder: self.builder.property("unit", unit),
681        }
682    }
683
684    /// If [`true`], the transformation for the cairo context obtained
685    /// from [`PrintContext`][crate::PrintContext] puts the origin at the top left corner
686    /// of the page.
687    ///
688    /// This may not be the top left corner of the sheet, depending on
689    /// page orientation and the number of pages per sheet. Otherwise,
690    /// the origin is at the top left corner of the imageable area (i.e.
691    /// inside the margins).
692    pub fn use_full_page(self, use_full_page: bool) -> Self {
693        Self {
694            builder: self.builder.property("use-full-page", use_full_page),
695        }
696    }
697
698    // rustdoc-stripper-ignore-next
699    /// Build the [`PrintOperation`].
700    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
701    pub fn build(self) -> PrintOperation {
702        assert_initialized_main_thread!();
703        self.builder.build()
704    }
705}
706
707/// Trait containing all [`struct@PrintOperation`] methods.
708///
709/// # Implementors
710///
711/// [`PrintOperation`][struct@crate::PrintOperation]
712pub trait PrintOperationExt: IsA<PrintOperation> + 'static {
713    /// Cancels a running print operation.
714    ///
715    /// This function may be called from a [`begin-print`][struct@crate::PrintOperation#begin-print],
716    /// [`paginate`][struct@crate::PrintOperation#paginate] or [`draw-page`][struct@crate::PrintOperation#draw-page]
717    /// signal handler to stop the currently running print operation.
718    #[doc(alias = "gtk_print_operation_cancel")]
719    fn cancel(&self) {
720        unsafe {
721            ffi::gtk_print_operation_cancel(self.as_ref().to_glib_none().0);
722        }
723    }
724
725    /// Signal that drawing of particular page is complete.
726    ///
727    /// It is called after completion of page drawing (e.g. drawing
728    /// in another thread). If [`set_defer_drawing()`][Self::set_defer_drawing()]
729    /// was called before, then this function has to be called by application.
730    /// Otherwise it is called by GTK itself.
731    #[doc(alias = "gtk_print_operation_draw_page_finish")]
732    fn draw_page_finish(&self) {
733        unsafe {
734            ffi::gtk_print_operation_draw_page_finish(self.as_ref().to_glib_none().0);
735        }
736    }
737
738    /// Returns the default page setup.
739    ///
740    /// # Returns
741    ///
742    /// the default page setup
743    #[doc(alias = "gtk_print_operation_get_default_page_setup")]
744    #[doc(alias = "get_default_page_setup")]
745    #[doc(alias = "default-page-setup")]
746    fn default_page_setup(&self) -> PageSetup {
747        unsafe {
748            from_glib_none(ffi::gtk_print_operation_get_default_page_setup(
749                self.as_ref().to_glib_none().0,
750            ))
751        }
752    }
753
754    /// Gets whether page setup selection combos are embedded
755    ///
756    /// # Returns
757    ///
758    /// whether page setup selection combos are embedded
759    #[doc(alias = "gtk_print_operation_get_embed_page_setup")]
760    #[doc(alias = "get_embed_page_setup")]
761    #[doc(alias = "embed-page-setup")]
762    fn embeds_page_setup(&self) -> bool {
763        unsafe {
764            from_glib(ffi::gtk_print_operation_get_embed_page_setup(
765                self.as_ref().to_glib_none().0,
766            ))
767        }
768    }
769
770    /// Gets whether there is a selection.
771    ///
772    /// # Returns
773    ///
774    /// whether there is a selection
775    #[doc(alias = "gtk_print_operation_get_has_selection")]
776    #[doc(alias = "get_has_selection")]
777    #[doc(alias = "has-selection")]
778    fn has_selection(&self) -> bool {
779        unsafe {
780            from_glib(ffi::gtk_print_operation_get_has_selection(
781                self.as_ref().to_glib_none().0,
782            ))
783        }
784    }
785
786    /// Returns the number of pages that will be printed.
787    ///
788    /// Note that this value is set during print preparation phase
789    /// ([`PrintStatus::Preparing`][crate::PrintStatus::Preparing]), so this function should never be
790    /// called before the data generation phase ([`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData]).
791    /// You can connect to the [`status-changed`][struct@crate::PrintOperation#status-changed]
792    /// signal and call gtk_print_operation_get_n_pages_to_print() when
793    /// print status is [`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData].
794    ///
795    /// This is typically used to track the progress of print operation.
796    ///
797    /// # Returns
798    ///
799    /// the number of pages that will be printed
800    #[doc(alias = "gtk_print_operation_get_n_pages_to_print")]
801    #[doc(alias = "get_n_pages_to_print")]
802    #[doc(alias = "n-pages-to-print")]
803    fn n_pages_to_print(&self) -> i32 {
804        unsafe { ffi::gtk_print_operation_get_n_pages_to_print(self.as_ref().to_glib_none().0) }
805    }
806
807    /// Returns the current print settings.
808    ///
809    /// Note that the return value is [`None`] until either
810    /// [`set_print_settings()`][Self::set_print_settings()] or
811    /// [`run()`][Self::run()] have been called.
812    ///
813    /// # Returns
814    ///
815    /// the current print settings of @self.
816    #[doc(alias = "gtk_print_operation_get_print_settings")]
817    #[doc(alias = "get_print_settings")]
818    #[doc(alias = "print-settings")]
819    fn print_settings(&self) -> Option<PrintSettings> {
820        unsafe {
821            from_glib_none(ffi::gtk_print_operation_get_print_settings(
822                self.as_ref().to_glib_none().0,
823            ))
824        }
825    }
826
827    /// Returns the status of the print operation.
828    ///
829    /// Also see [`status_string()`][Self::status_string()].
830    ///
831    /// # Returns
832    ///
833    /// the status of the print operation
834    #[doc(alias = "gtk_print_operation_get_status")]
835    #[doc(alias = "get_status")]
836    fn status(&self) -> PrintStatus {
837        unsafe {
838            from_glib(ffi::gtk_print_operation_get_status(
839                self.as_ref().to_glib_none().0,
840            ))
841        }
842    }
843
844    /// Returns a string representation of the status of the
845    /// print operation.
846    ///
847    /// The string is translated and suitable for displaying
848    /// the print status e.g. in a [`Statusbar`][crate::Statusbar].
849    ///
850    /// Use [`status()`][Self::status()] to obtain
851    /// a status value that is suitable for programmatic use.
852    ///
853    /// # Returns
854    ///
855    /// a string representation of the status
856    ///    of the print operation
857    #[doc(alias = "gtk_print_operation_get_status_string")]
858    #[doc(alias = "get_status_string")]
859    #[doc(alias = "status-string")]
860    fn status_string(&self) -> glib::GString {
861        unsafe {
862            from_glib_none(ffi::gtk_print_operation_get_status_string(
863                self.as_ref().to_glib_none().0,
864            ))
865        }
866    }
867
868    /// Gets whether the application supports print of selection
869    ///
870    /// # Returns
871    ///
872    /// whether the application supports print of selection
873    #[doc(alias = "gtk_print_operation_get_support_selection")]
874    #[doc(alias = "get_support_selection")]
875    #[doc(alias = "support-selection")]
876    fn supports_selection(&self) -> bool {
877        unsafe {
878            from_glib(ffi::gtk_print_operation_get_support_selection(
879                self.as_ref().to_glib_none().0,
880            ))
881        }
882    }
883
884    /// A convenience function to find out if the print operation
885    /// is finished.
886    ///
887    /// a print operation is finished if its status is either
888    /// [`PrintStatus::Finished`][crate::PrintStatus::Finished] or [`PrintStatus::FinishedAborted`][crate::PrintStatus::FinishedAborted].
889    ///
890    /// Note: when you enable print status tracking the print operation
891    /// can be in a non-finished state even after done has been called, as
892    /// the operation status then tracks the print job status on the printer.
893    ///
894    /// # Returns
895    ///
896    /// [`true`], if the print operation is finished.
897    #[doc(alias = "gtk_print_operation_is_finished")]
898    fn is_finished(&self) -> bool {
899        unsafe {
900            from_glib(ffi::gtk_print_operation_is_finished(
901                self.as_ref().to_glib_none().0,
902            ))
903        }
904    }
905
906    /// message);
907    ///    g_signal_connect (error_dialog, "response",
908    ///                      G_CALLBACK (gtk_window_destroy), NULL);
909    ///    gtk_window_present (GTK_WINDOW (error_dialog));
910    ///    g_error_free (error);
911    ///  }
912    /// else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
913    ///  {
914    ///    if (settings != NULL)
915    /// g_object_unref (settings);
916    ///    settings = g_object_ref (gtk_print_operation_get_print_settings (print));
917    ///  }
918    /// ```text
919    ///
920    /// Note that gtk_print_operation_run() can only be called once on a
921    /// given [`PrintOperation`][crate::PrintOperation].
922    /// ## `action`
923    /// the action to start
924    /// ## `parent`
925    /// Transient parent of the dialog
926    ///
927    /// # Returns
928    ///
929    /// the result of the print operation. A return value of
930    ///   [`PrintOperationResult::Apply`][crate::PrintOperationResult::Apply] indicates that the printing was
931    ///   completed successfully. In this case, it is a good idea to obtain
932    ///   the used print settings with
933    ///   [`print_settings()`][Self::print_settings()]
934    ///   and store them for reuse with the next print operation. A value of
935    ///   [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] means the operation is running
936    ///   asynchronously, and will emit the [`done`][struct@crate::PrintOperation#done]
937    ///   signal when done.
938    #[doc(alias = "gtk_print_operation_run")]
939    fn run(
940        &self,
941        action: PrintOperationAction,
942        parent: Option<&impl IsA<Window>>,
943    ) -> Result<PrintOperationResult, glib::Error> {
944        unsafe {
945            let mut error = std::ptr::null_mut();
946            let ret = ffi::gtk_print_operation_run(
947                self.as_ref().to_glib_none().0,
948                action.into_glib(),
949                parent.map(|p| p.as_ref()).to_glib_none().0,
950                &mut error,
951            );
952            if error.is_null() {
953                Ok(from_glib(ret))
954            } else {
955                Err(from_glib_full(error))
956            }
957        }
958    }
959
960    /// Sets whether gtk_print_operation_run() may return
961    /// before the print operation is completed.
962    ///
963    /// Note that some platforms may not allow asynchronous
964    /// operation.
965    /// ## `allow_async`
966    /// [`true`] to allow asynchronous operation
967    #[doc(alias = "gtk_print_operation_set_allow_async")]
968    #[doc(alias = "allow-async")]
969    fn set_allow_async(&self, allow_async: bool) {
970        unsafe {
971            ffi::gtk_print_operation_set_allow_async(
972                self.as_ref().to_glib_none().0,
973                allow_async.into_glib(),
974            );
975        }
976    }
977
978    /// Sets the current page.
979    ///
980    /// If this is called before [`run()`][Self::run()],
981    /// the user will be able to select to print only the current page.
982    ///
983    /// Note that this only makes sense for pre-paginated documents.
984    /// ## `current_page`
985    /// the current page, 0-based
986    #[doc(alias = "gtk_print_operation_set_current_page")]
987    #[doc(alias = "current-page")]
988    fn set_current_page(&self, current_page: i32) {
989        unsafe {
990            ffi::gtk_print_operation_set_current_page(self.as_ref().to_glib_none().0, current_page);
991        }
992    }
993
994    /// Sets the label for the tab holding custom widgets.
995    /// ## `label`
996    /// the label to use, or [`None`] to use the default label
997    #[doc(alias = "gtk_print_operation_set_custom_tab_label")]
998    #[doc(alias = "custom-tab-label")]
999    fn set_custom_tab_label(&self, label: Option<&str>) {
1000        unsafe {
1001            ffi::gtk_print_operation_set_custom_tab_label(
1002                self.as_ref().to_glib_none().0,
1003                label.to_glib_none().0,
1004            );
1005        }
1006    }
1007
1008    /// Makes @default_page_setup the default page setup for @self.
1009    ///
1010    /// This page setup will be used by [`run()`][Self::run()],
1011    /// but it can be overridden on a per-page basis by connecting
1012    /// to the [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] signal.
1013    /// ## `default_page_setup`
1014    /// a [`PageSetup`][crate::PageSetup]
1015    #[doc(alias = "gtk_print_operation_set_default_page_setup")]
1016    #[doc(alias = "default-page-setup")]
1017    fn set_default_page_setup(&self, default_page_setup: Option<&PageSetup>) {
1018        unsafe {
1019            ffi::gtk_print_operation_set_default_page_setup(
1020                self.as_ref().to_glib_none().0,
1021                default_page_setup.to_glib_none().0,
1022            );
1023        }
1024    }
1025
1026    /// Sets up the [`PrintOperation`][crate::PrintOperation] to wait for calling of
1027    /// [`draw_page_finish()`][Self::draw_page_finish()] from application.
1028    ///
1029    /// This can be used for drawing page in another thread.
1030    ///
1031    /// This function must be called in the callback of the
1032    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signal.
1033    #[doc(alias = "gtk_print_operation_set_defer_drawing")]
1034    fn set_defer_drawing(&self) {
1035        unsafe {
1036            ffi::gtk_print_operation_set_defer_drawing(self.as_ref().to_glib_none().0);
1037        }
1038    }
1039
1040    /// Embed page size combo box and orientation combo box into page setup page.
1041    ///
1042    /// Selected page setup is stored as default page setup in [`PrintOperation`][crate::PrintOperation].
1043    /// ## `embed`
1044    /// [`true`] to embed page setup selection in the [`PrintUnixDialog`][crate::PrintUnixDialog]
1045    #[doc(alias = "gtk_print_operation_set_embed_page_setup")]
1046    #[doc(alias = "embed-page-setup")]
1047    fn set_embed_page_setup(&self, embed: bool) {
1048        unsafe {
1049            ffi::gtk_print_operation_set_embed_page_setup(
1050                self.as_ref().to_glib_none().0,
1051                embed.into_glib(),
1052            );
1053        }
1054    }
1055
1056    /// Sets up the [`PrintOperation`][crate::PrintOperation] to generate a file instead
1057    /// of showing the print dialog.
1058    ///
1059    /// The intended use of this function is for implementing
1060    /// “Export to PDF” actions. Currently, PDF is the only supported
1061    /// format.
1062    ///
1063    /// “Print to PDF” support is independent of this and is done
1064    /// by letting the user pick the “Print to PDF” item from the list
1065    /// of printers in the print dialog.
1066    /// ## `filename`
1067    /// the filename for the exported file
1068    #[doc(alias = "gtk_print_operation_set_export_filename")]
1069    #[doc(alias = "export-filename")]
1070    fn set_export_filename(&self, filename: impl AsRef<std::path::Path>) {
1071        unsafe {
1072            ffi::gtk_print_operation_set_export_filename(
1073                self.as_ref().to_glib_none().0,
1074                filename.as_ref().to_glib_none().0,
1075            );
1076        }
1077    }
1078
1079    /// Sets whether there is a selection to print.
1080    ///
1081    /// Application has to set number of pages to which the selection
1082    /// will draw by [`set_n_pages()`][Self::set_n_pages()] in a handler
1083    /// for the [`begin-print`][struct@crate::PrintOperation#begin-print] signal.
1084    /// ## `has_selection`
1085    /// [`true`] indicates that a selection exists
1086    #[doc(alias = "gtk_print_operation_set_has_selection")]
1087    #[doc(alias = "has-selection")]
1088    fn set_has_selection(&self, has_selection: bool) {
1089        unsafe {
1090            ffi::gtk_print_operation_set_has_selection(
1091                self.as_ref().to_glib_none().0,
1092                has_selection.into_glib(),
1093            );
1094        }
1095    }
1096
1097    /// Sets the name of the print job.
1098    ///
1099    /// The name is used to identify the job (e.g. in monitoring
1100    /// applications like eggcups).
1101    ///
1102    /// If you don’t set a job name, GTK picks a default one by
1103    /// numbering successive print jobs.
1104    /// ## `job_name`
1105    /// a string that identifies the print job
1106    #[doc(alias = "gtk_print_operation_set_job_name")]
1107    #[doc(alias = "job-name")]
1108    fn set_job_name(&self, job_name: &str) {
1109        unsafe {
1110            ffi::gtk_print_operation_set_job_name(
1111                self.as_ref().to_glib_none().0,
1112                job_name.to_glib_none().0,
1113            );
1114        }
1115    }
1116
1117    /// Sets the number of pages in the document.
1118    ///
1119    /// This must be set to a positive number before the rendering
1120    /// starts. It may be set in a [`begin-print`][struct@crate::PrintOperation#begin-print]
1121    /// signal handler.
1122    ///
1123    /// Note that the page numbers passed to the
1124    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup]
1125    /// and [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e.
1126    /// if the user chooses to print all pages, the last ::draw-page signal
1127    /// will be for page @n_pages - 1.
1128    /// ## `n_pages`
1129    /// the number of pages
1130    #[doc(alias = "gtk_print_operation_set_n_pages")]
1131    #[doc(alias = "n-pages")]
1132    fn set_n_pages(&self, n_pages: i32) {
1133        unsafe {
1134            ffi::gtk_print_operation_set_n_pages(self.as_ref().to_glib_none().0, n_pages);
1135        }
1136    }
1137
1138    /// Sets the print settings for @self.
1139    ///
1140    /// This is typically used to re-establish print settings
1141    /// from a previous print operation, see [`run()`][Self::run()].
1142    /// ## `print_settings`
1143    /// [`PrintSettings`][crate::PrintSettings]
1144    #[doc(alias = "gtk_print_operation_set_print_settings")]
1145    #[doc(alias = "print-settings")]
1146    fn set_print_settings(&self, print_settings: Option<&PrintSettings>) {
1147        unsafe {
1148            ffi::gtk_print_operation_set_print_settings(
1149                self.as_ref().to_glib_none().0,
1150                print_settings.to_glib_none().0,
1151            );
1152        }
1153    }
1154
1155    /// If @show_progress is [`true`], the print operation will show
1156    /// a progress dialog during the print operation.
1157    /// ## `show_progress`
1158    /// [`true`] to show a progress dialog
1159    #[doc(alias = "gtk_print_operation_set_show_progress")]
1160    #[doc(alias = "show-progress")]
1161    fn set_show_progress(&self, show_progress: bool) {
1162        unsafe {
1163            ffi::gtk_print_operation_set_show_progress(
1164                self.as_ref().to_glib_none().0,
1165                show_progress.into_glib(),
1166            );
1167        }
1168    }
1169
1170    /// Sets whether selection is supported by [`PrintOperation`][crate::PrintOperation].
1171    /// ## `support_selection`
1172    /// [`true`] to support selection
1173    #[doc(alias = "gtk_print_operation_set_support_selection")]
1174    #[doc(alias = "support-selection")]
1175    fn set_support_selection(&self, support_selection: bool) {
1176        unsafe {
1177            ffi::gtk_print_operation_set_support_selection(
1178                self.as_ref().to_glib_none().0,
1179                support_selection.into_glib(),
1180            );
1181        }
1182    }
1183
1184    /// If track_status is [`true`], the print operation will try to continue
1185    /// report on the status of the print job in the printer queues and printer.
1186    ///
1187    /// This can allow your application to show things like “out of paper”
1188    /// issues, and when the print job actually reaches the printer.
1189    ///
1190    /// This function is often implemented using some form of polling,
1191    /// so it should not be enabled unless needed.
1192    /// ## `track_status`
1193    /// [`true`] to track status after printing
1194    #[doc(alias = "gtk_print_operation_set_track_print_status")]
1195    #[doc(alias = "track-print-status")]
1196    fn set_track_print_status(&self, track_status: bool) {
1197        unsafe {
1198            ffi::gtk_print_operation_set_track_print_status(
1199                self.as_ref().to_glib_none().0,
1200                track_status.into_glib(),
1201            );
1202        }
1203    }
1204
1205    /// Sets up the transformation for the cairo context obtained from
1206    /// [`PrintContext`][crate::PrintContext] in such a way that distances are measured in
1207    /// units of @unit.
1208    /// ## `unit`
1209    /// the unit to use
1210    #[doc(alias = "gtk_print_operation_set_unit")]
1211    #[doc(alias = "unit")]
1212    fn set_unit(&self, unit: Unit) {
1213        unsafe {
1214            ffi::gtk_print_operation_set_unit(self.as_ref().to_glib_none().0, unit.into_glib());
1215        }
1216    }
1217
1218    /// If @full_page is [`true`], the transformation for the cairo context
1219    /// obtained from [`PrintContext`][crate::PrintContext] puts the origin at the top left
1220    /// corner of the page.
1221    ///
1222    /// This may not be the top left corner of the sheet, depending on page
1223    /// orientation and the number of pages per sheet). Otherwise, the origin
1224    /// is at the top left corner of the imageable area (i.e. inside the margins).
1225    /// ## `full_page`
1226    /// [`true`] to set up the [`PrintContext`][crate::PrintContext] for the full page
1227    #[doc(alias = "gtk_print_operation_set_use_full_page")]
1228    #[doc(alias = "use-full-page")]
1229    fn set_use_full_page(&self, full_page: bool) {
1230        unsafe {
1231            ffi::gtk_print_operation_set_use_full_page(
1232                self.as_ref().to_glib_none().0,
1233                full_page.into_glib(),
1234            );
1235        }
1236    }
1237
1238    /// Determines whether the print operation may run asynchronously or not.
1239    ///
1240    /// Some systems don't support asynchronous printing, but those that do
1241    /// will return [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] as the status, and
1242    /// emit the [`done`][struct@crate::PrintOperation#done] signal when the operation
1243    /// is actually done.
1244    ///
1245    /// The Windows port does not support asynchronous operation at all (this
1246    /// is unlikely to change). On other platforms, all actions except for
1247    /// [`PrintOperationAction::Export`][crate::PrintOperationAction::Export] support asynchronous operation.
1248    #[doc(alias = "allow-async")]
1249    fn allows_async(&self) -> bool {
1250        ObjectExt::property(self.as_ref(), "allow-async")
1251    }
1252
1253    /// The current page in the document.
1254    ///
1255    /// If this is set before [`run()`][Self::run()],
1256    /// the user will be able to select to print only the current page.
1257    ///
1258    /// Note that this only makes sense for pre-paginated documents.
1259    #[doc(alias = "current-page")]
1260    fn current_page(&self) -> i32 {
1261        ObjectExt::property(self.as_ref(), "current-page")
1262    }
1263
1264    /// Used as the label of the tab containing custom widgets.
1265    ///
1266    /// Note that this property may be ignored on some platforms.
1267    ///
1268    /// If this is [`None`], GTK uses a default label.
1269    #[doc(alias = "custom-tab-label")]
1270    fn custom_tab_label(&self) -> Option<glib::GString> {
1271        ObjectExt::property(self.as_ref(), "custom-tab-label")
1272    }
1273
1274    /// The name of a file to generate instead of showing the print dialog.
1275    ///
1276    /// Currently, PDF is the only supported format.
1277    ///
1278    /// The intended use of this property is for implementing
1279    /// “Export to PDF” actions.
1280    ///
1281    /// “Print to PDF” support is independent of this and is done
1282    /// by letting the user pick the “Print to PDF” item from the
1283    /// list of printers in the print dialog.
1284    #[doc(alias = "export-filename")]
1285    fn export_filename(&self) -> Option<glib::GString> {
1286        ObjectExt::property(self.as_ref(), "export-filename")
1287    }
1288
1289    /// A string used to identify the job (e.g. in monitoring
1290    /// applications like eggcups).
1291    ///
1292    /// If you don't set a job name, GTK picks a default one
1293    /// by numbering successive print jobs.
1294    #[doc(alias = "job-name")]
1295    fn job_name(&self) -> Option<glib::GString> {
1296        ObjectExt::property(self.as_ref(), "job-name")
1297    }
1298
1299    /// The number of pages in the document.
1300    ///
1301    /// This must be set to a positive number before the rendering
1302    /// starts. It may be set in a [`begin-print`][struct@crate::PrintOperation#begin-print]
1303    /// signal handler.
1304    ///
1305    /// Note that the page numbers passed to the
1306    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] and
1307    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e.
1308    /// if the user chooses to print all pages, the last ::draw-page signal
1309    /// will be for page @n_pages - 1.
1310    #[doc(alias = "n-pages")]
1311    fn n_pages(&self) -> i32 {
1312        ObjectExt::property(self.as_ref(), "n-pages")
1313    }
1314
1315    /// Determines whether to show a progress dialog during the
1316    /// print operation.
1317    #[doc(alias = "show-progress")]
1318    fn shows_progress(&self) -> bool {
1319        ObjectExt::property(self.as_ref(), "show-progress")
1320    }
1321
1322    /// If [`true`], the print operation will try to continue report on
1323    /// the status of the print job in the printer queues and printer.
1324    ///
1325    /// This can allow your application to show things like “out of paper”
1326    /// issues, and when the print job actually reaches the printer.
1327    /// However, this is often implemented using polling, and should
1328    /// not be enabled unless needed.
1329    #[doc(alias = "track-print-status")]
1330    fn tracks_print_status(&self) -> bool {
1331        ObjectExt::property(self.as_ref(), "track-print-status")
1332    }
1333
1334    /// The transformation for the cairo context obtained from
1335    /// [`PrintContext`][crate::PrintContext] is set up in such a way that distances
1336    /// are measured in units of @unit.
1337    fn unit(&self) -> Unit {
1338        ObjectExt::property(self.as_ref(), "unit")
1339    }
1340
1341    /// If [`true`], the transformation for the cairo context obtained
1342    /// from [`PrintContext`][crate::PrintContext] puts the origin at the top left corner
1343    /// of the page.
1344    ///
1345    /// This may not be the top left corner of the sheet, depending on
1346    /// page orientation and the number of pages per sheet. Otherwise,
1347    /// the origin is at the top left corner of the imageable area (i.e.
1348    /// inside the margins).
1349    #[doc(alias = "use-full-page")]
1350    fn uses_full_page(&self) -> bool {
1351        ObjectExt::property(self.as_ref(), "use-full-page")
1352    }
1353
1354    /// Emitted after the user has finished changing print settings
1355    /// in the dialog, before the actual rendering starts.
1356    ///
1357    /// A typical use for ::begin-print is to use the parameters from the
1358    /// [`PrintContext`][crate::PrintContext] and paginate the document accordingly,
1359    /// and then set the number of pages with
1360    /// [`set_n_pages()`][Self::set_n_pages()].
1361    /// ## `context`
1362    /// the [`PrintContext`][crate::PrintContext] for the current operation
1363    #[doc(alias = "begin-print")]
1364    fn connect_begin_print<F: Fn(&Self, &PrintContext) + 'static>(&self, f: F) -> SignalHandlerId {
1365        unsafe extern "C" fn begin_print_trampoline<
1366            P: IsA<PrintOperation>,
1367            F: Fn(&P, &PrintContext) + 'static,
1368        >(
1369            this: *mut ffi::GtkPrintOperation,
1370            context: *mut ffi::GtkPrintContext,
1371            f: glib::ffi::gpointer,
1372        ) {
1373            unsafe {
1374                let f: &F = &*(f as *const F);
1375                f(
1376                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1377                    &from_glib_borrow(context),
1378                )
1379            }
1380        }
1381        unsafe {
1382            let f: Box_<F> = Box_::new(f);
1383            connect_raw(
1384                self.as_ptr() as *mut _,
1385                c"begin-print".as_ptr(),
1386                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1387                    begin_print_trampoline::<Self, F> as *const (),
1388                )),
1389                Box_::into_raw(f),
1390            )
1391        }
1392    }
1393
1394    /// Emitted when displaying the print dialog.
1395    ///
1396    /// If you return a widget in a handler for this signal it will be
1397    /// added to a custom tab in the print dialog. You typically return a
1398    /// container widget with multiple widgets in it.
1399    ///
1400    /// The print dialog owns the returned widget, and its lifetime is not
1401    /// controlled by the application. However, the widget is guaranteed
1402    /// to stay around until the [`custom-widget-apply`][struct@crate::PrintOperation#custom-widget-apply]
1403    /// signal is emitted on the operation. Then you can read out any
1404    /// information you need from the widgets.
1405    ///
1406    /// # Returns
1407    ///
1408    /// A custom widget that gets embedded in
1409    ///   the print dialog
1410    #[doc(alias = "create-custom-widget")]
1411    fn connect_create_custom_widget<F: Fn(&Self) -> Option<glib::Object> + 'static>(
1412        &self,
1413        f: F,
1414    ) -> SignalHandlerId {
1415        unsafe extern "C" fn create_custom_widget_trampoline<
1416            P: IsA<PrintOperation>,
1417            F: Fn(&P) -> Option<glib::Object> + 'static,
1418        >(
1419            this: *mut ffi::GtkPrintOperation,
1420            f: glib::ffi::gpointer,
1421        ) -> *mut glib::gobject_ffi::GObject {
1422            unsafe {
1423                let f: &F = &*(f as *const F);
1424                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref()) /*Not checked*/
1425                    .to_glib_none()
1426                    .0
1427            }
1428        }
1429        unsafe {
1430            let f: Box_<F> = Box_::new(f);
1431            connect_raw(
1432                self.as_ptr() as *mut _,
1433                c"create-custom-widget".as_ptr(),
1434                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1435                    create_custom_widget_trampoline::<Self, F> as *const (),
1436                )),
1437                Box_::into_raw(f),
1438            )
1439        }
1440    }
1441
1442    /// Emitted right before ::begin-print if you added
1443    /// a custom widget in the ::create-custom-widget handler.
1444    ///
1445    /// When you get this signal you should read the information from the
1446    /// custom widgets, as the widgets are not guaranteed to be around at a
1447    /// later time.
1448    /// ## `widget`
1449    /// the custom widget added in ::create-custom-widget
1450    #[doc(alias = "custom-widget-apply")]
1451    fn connect_custom_widget_apply<F: Fn(&Self, &Widget) + 'static>(
1452        &self,
1453        f: F,
1454    ) -> SignalHandlerId {
1455        unsafe extern "C" fn custom_widget_apply_trampoline<
1456            P: IsA<PrintOperation>,
1457            F: Fn(&P, &Widget) + 'static,
1458        >(
1459            this: *mut ffi::GtkPrintOperation,
1460            widget: *mut ffi::GtkWidget,
1461            f: glib::ffi::gpointer,
1462        ) {
1463            unsafe {
1464                let f: &F = &*(f as *const F);
1465                f(
1466                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1467                    &from_glib_borrow(widget),
1468                )
1469            }
1470        }
1471        unsafe {
1472            let f: Box_<F> = Box_::new(f);
1473            connect_raw(
1474                self.as_ptr() as *mut _,
1475                c"custom-widget-apply".as_ptr(),
1476                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1477                    custom_widget_apply_trampoline::<Self, F> as *const (),
1478                )),
1479                Box_::into_raw(f),
1480            )
1481        }
1482    }
1483
1484    /// Emitted when the print operation run has finished doing
1485    /// everything required for printing.
1486    ///
1487    /// @result gives you information about what happened during the run.
1488    /// If @result is [`PrintOperationResult::Error`][crate::PrintOperationResult::Error] then you can call
1489    /// `Gtk::PrintOperation::get_error()` for more information.
1490    ///
1491    /// If you enabled print status tracking then
1492    /// [`is_finished()`][Self::is_finished()] may still return [`false`]
1493    /// after the ::done signal was emitted.
1494    /// ## `result`
1495    /// the result of the print operation
1496    #[doc(alias = "done")]
1497    fn connect_done<F: Fn(&Self, PrintOperationResult) + 'static>(&self, f: F) -> SignalHandlerId {
1498        unsafe extern "C" fn done_trampoline<
1499            P: IsA<PrintOperation>,
1500            F: Fn(&P, PrintOperationResult) + 'static,
1501        >(
1502            this: *mut ffi::GtkPrintOperation,
1503            result: ffi::GtkPrintOperationResult,
1504            f: glib::ffi::gpointer,
1505        ) {
1506            unsafe {
1507                let f: &F = &*(f as *const F);
1508                f(
1509                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1510                    from_glib(result),
1511                )
1512            }
1513        }
1514        unsafe {
1515            let f: Box_<F> = Box_::new(f);
1516            connect_raw(
1517                self.as_ptr() as *mut _,
1518                c"done".as_ptr(),
1519                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1520                    done_trampoline::<Self, F> as *const (),
1521                )),
1522                Box_::into_raw(f),
1523            )
1524        }
1525    }
1526
1527    /// layout_height);
1528    ///   text_height = (double)layout_height / PANGO_SCALE;
1529    ///
1530    ///   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
1531    ///   pango_cairo_show_layout (cr, layout);
1532    ///
1533    ///   g_object_unref (layout);
1534    /// }
1535    /// ```text
1536    ///
1537    /// Use [`set_use_full_page()`][Self::set_use_full_page()] and
1538    /// [`set_unit()`][Self::set_unit()] before starting the print
1539    /// operation to set up the transformation of the cairo context
1540    /// according to your needs.
1541    /// ## `context`
1542    /// the [`PrintContext`][crate::PrintContext] for the current operation
1543    /// ## `page_nr`
1544    /// the number of the currently printed page (0-based)
1545    #[doc(alias = "draw-page")]
1546    fn connect_draw_page<F: Fn(&Self, &PrintContext, i32) + 'static>(
1547        &self,
1548        f: F,
1549    ) -> SignalHandlerId {
1550        unsafe extern "C" fn draw_page_trampoline<
1551            P: IsA<PrintOperation>,
1552            F: Fn(&P, &PrintContext, i32) + 'static,
1553        >(
1554            this: *mut ffi::GtkPrintOperation,
1555            context: *mut ffi::GtkPrintContext,
1556            page_nr: std::ffi::c_int,
1557            f: glib::ffi::gpointer,
1558        ) {
1559            unsafe {
1560                let f: &F = &*(f as *const F);
1561                f(
1562                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1563                    &from_glib_borrow(context),
1564                    page_nr,
1565                )
1566            }
1567        }
1568        unsafe {
1569            let f: Box_<F> = Box_::new(f);
1570            connect_raw(
1571                self.as_ptr() as *mut _,
1572                c"draw-page".as_ptr(),
1573                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1574                    draw_page_trampoline::<Self, F> as *const (),
1575                )),
1576                Box_::into_raw(f),
1577            )
1578        }
1579    }
1580
1581    /// Emitted after all pages have been rendered.
1582    ///
1583    /// A handler for this signal can clean up any resources that have
1584    /// been allocated in the [`begin-print`][struct@crate::PrintOperation#begin-print] handler.
1585    /// ## `context`
1586    /// the [`PrintContext`][crate::PrintContext] for the current operation
1587    #[doc(alias = "end-print")]
1588    fn connect_end_print<F: Fn(&Self, &PrintContext) + 'static>(&self, f: F) -> SignalHandlerId {
1589        unsafe extern "C" fn end_print_trampoline<
1590            P: IsA<PrintOperation>,
1591            F: Fn(&P, &PrintContext) + 'static,
1592        >(
1593            this: *mut ffi::GtkPrintOperation,
1594            context: *mut ffi::GtkPrintContext,
1595            f: glib::ffi::gpointer,
1596        ) {
1597            unsafe {
1598                let f: &F = &*(f as *const F);
1599                f(
1600                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1601                    &from_glib_borrow(context),
1602                )
1603            }
1604        }
1605        unsafe {
1606            let f: Box_<F> = Box_::new(f);
1607            connect_raw(
1608                self.as_ptr() as *mut _,
1609                c"end-print".as_ptr(),
1610                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1611                    end_print_trampoline::<Self, F> as *const (),
1612                )),
1613                Box_::into_raw(f),
1614            )
1615        }
1616    }
1617
1618    /// Emitted after the ::begin-print signal, but before the actual rendering
1619    /// starts.
1620    ///
1621    /// It keeps getting emitted until a connected signal handler returns [`true`].
1622    ///
1623    /// The ::paginate signal is intended to be used for paginating a document
1624    /// in small chunks, to avoid blocking the user interface for a long
1625    /// time. The signal handler should update the number of pages using
1626    /// [`set_n_pages()`][Self::set_n_pages()], and return [`true`] if the document
1627    /// has been completely paginated.
1628    ///
1629    /// If you don't need to do pagination in chunks, you can simply do
1630    /// it all in the ::begin-print handler, and set the number of pages
1631    /// from there.
1632    /// ## `context`
1633    /// the [`PrintContext`][crate::PrintContext] for the current operation
1634    ///
1635    /// # Returns
1636    ///
1637    /// [`true`] if pagination is complete
1638    #[doc(alias = "paginate")]
1639    fn connect_paginate<F: Fn(&Self, &PrintContext) -> bool + 'static>(
1640        &self,
1641        f: F,
1642    ) -> SignalHandlerId {
1643        unsafe extern "C" fn paginate_trampoline<
1644            P: IsA<PrintOperation>,
1645            F: Fn(&P, &PrintContext) -> bool + 'static,
1646        >(
1647            this: *mut ffi::GtkPrintOperation,
1648            context: *mut ffi::GtkPrintContext,
1649            f: glib::ffi::gpointer,
1650        ) -> glib::ffi::gboolean {
1651            unsafe {
1652                let f: &F = &*(f as *const F);
1653                f(
1654                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1655                    &from_glib_borrow(context),
1656                )
1657                .into_glib()
1658            }
1659        }
1660        unsafe {
1661            let f: Box_<F> = Box_::new(f);
1662            connect_raw(
1663                self.as_ptr() as *mut _,
1664                c"paginate".as_ptr(),
1665                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1666                    paginate_trampoline::<Self, F> as *const (),
1667                )),
1668                Box_::into_raw(f),
1669            )
1670        }
1671    }
1672
1673    /// Gets emitted when a preview is requested from the native dialog.
1674    ///
1675    /// The default handler for this signal uses an external viewer
1676    /// application to preview.
1677    ///
1678    /// To implement a custom print preview, an application must return
1679    /// [`true`] from its handler for this signal. In order to use the
1680    /// provided @context for the preview implementation, it must be
1681    /// given a suitable cairo context with
1682    /// [`PrintContext::set_cairo_context()`][crate::PrintContext::set_cairo_context()].
1683    ///
1684    /// The custom preview implementation can use
1685    /// [`PrintOperationPreviewExt::is_selected()`][crate::prelude::PrintOperationPreviewExt::is_selected()] and
1686    /// [`PrintOperationPreviewExt::render_page()`][crate::prelude::PrintOperationPreviewExt::render_page()] to find pages which
1687    /// are selected for print and render them. The preview must be
1688    /// finished by calling [`PrintOperationPreviewExt::end_preview()`][crate::prelude::PrintOperationPreviewExt::end_preview()]
1689    /// (typically in response to the user clicking a close button).
1690    /// ## `preview`
1691    /// the [`PrintOperationPreview`][crate::PrintOperationPreview] for the current operation
1692    /// ## `context`
1693    /// the [`PrintContext`][crate::PrintContext] that will be used
1694    /// ## `parent`
1695    /// the [`Window`][crate::Window] to use as window parent
1696    ///
1697    /// # Returns
1698    ///
1699    /// [`true`] if the listener wants to take over control of the preview
1700    #[doc(alias = "preview")]
1701    fn connect_preview<
1702        F: Fn(&Self, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static,
1703    >(
1704        &self,
1705        f: F,
1706    ) -> SignalHandlerId {
1707        unsafe extern "C" fn preview_trampoline<
1708            P: IsA<PrintOperation>,
1709            F: Fn(&P, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static,
1710        >(
1711            this: *mut ffi::GtkPrintOperation,
1712            preview: *mut ffi::GtkPrintOperationPreview,
1713            context: *mut ffi::GtkPrintContext,
1714            parent: *mut ffi::GtkWindow,
1715            f: glib::ffi::gpointer,
1716        ) -> glib::ffi::gboolean {
1717            unsafe {
1718                let f: &F = &*(f as *const F);
1719                f(
1720                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1721                    &from_glib_borrow(preview),
1722                    &from_glib_borrow(context),
1723                    Option::<Window>::from_glib_borrow(parent).as_ref().as_ref(),
1724                )
1725                .into_glib()
1726            }
1727        }
1728        unsafe {
1729            let f: Box_<F> = Box_::new(f);
1730            connect_raw(
1731                self.as_ptr() as *mut _,
1732                c"preview".as_ptr(),
1733                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1734                    preview_trampoline::<Self, F> as *const (),
1735                )),
1736                Box_::into_raw(f),
1737            )
1738        }
1739    }
1740
1741    /// Emitted once for every page that is printed.
1742    ///
1743    /// This gives the application a chance to modify the page setup.
1744    /// Any changes done to @setup will be in force only for printing
1745    /// this page.
1746    /// ## `context`
1747    /// the [`PrintContext`][crate::PrintContext] for the current operation
1748    /// ## `page_nr`
1749    /// the number of the currently printed page (0-based)
1750    /// ## `setup`
1751    /// the [`PageSetup`][crate::PageSetup]
1752    #[doc(alias = "request-page-setup")]
1753    fn connect_request_page_setup<F: Fn(&Self, &PrintContext, i32, &PageSetup) + 'static>(
1754        &self,
1755        f: F,
1756    ) -> SignalHandlerId {
1757        unsafe extern "C" fn request_page_setup_trampoline<
1758            P: IsA<PrintOperation>,
1759            F: Fn(&P, &PrintContext, i32, &PageSetup) + 'static,
1760        >(
1761            this: *mut ffi::GtkPrintOperation,
1762            context: *mut ffi::GtkPrintContext,
1763            page_nr: std::ffi::c_int,
1764            setup: *mut ffi::GtkPageSetup,
1765            f: glib::ffi::gpointer,
1766        ) {
1767            unsafe {
1768                let f: &F = &*(f as *const F);
1769                f(
1770                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1771                    &from_glib_borrow(context),
1772                    page_nr,
1773                    &from_glib_borrow(setup),
1774                )
1775            }
1776        }
1777        unsafe {
1778            let f: Box_<F> = Box_::new(f);
1779            connect_raw(
1780                self.as_ptr() as *mut _,
1781                c"request-page-setup".as_ptr(),
1782                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1783                    request_page_setup_trampoline::<Self, F> as *const (),
1784                )),
1785                Box_::into_raw(f),
1786            )
1787        }
1788    }
1789
1790    /// Emitted at between the various phases of the print operation.
1791    ///
1792    /// See [`PrintStatus`][crate::PrintStatus] for the phases that are being discriminated.
1793    /// Use [`status()`][Self::status()] to find out the current
1794    /// status.
1795    #[doc(alias = "status-changed")]
1796    fn connect_status_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1797        unsafe extern "C" fn status_changed_trampoline<
1798            P: IsA<PrintOperation>,
1799            F: Fn(&P) + 'static,
1800        >(
1801            this: *mut ffi::GtkPrintOperation,
1802            f: glib::ffi::gpointer,
1803        ) {
1804            unsafe {
1805                let f: &F = &*(f as *const F);
1806                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1807            }
1808        }
1809        unsafe {
1810            let f: Box_<F> = Box_::new(f);
1811            connect_raw(
1812                self.as_ptr() as *mut _,
1813                c"status-changed".as_ptr(),
1814                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1815                    status_changed_trampoline::<Self, F> as *const (),
1816                )),
1817                Box_::into_raw(f),
1818            )
1819        }
1820    }
1821
1822    /// Emitted after change of selected printer.
1823    ///
1824    /// The actual page setup and print settings are passed to the custom
1825    /// widget, which can actualize itself according to this change.
1826    /// ## `widget`
1827    /// the custom widget added in ::create-custom-widget
1828    /// ## `setup`
1829    /// actual page setup
1830    /// ## `settings`
1831    /// actual print settings
1832    #[doc(alias = "update-custom-widget")]
1833    fn connect_update_custom_widget<F: Fn(&Self, &Widget, &PageSetup, &PrintSettings) + 'static>(
1834        &self,
1835        f: F,
1836    ) -> SignalHandlerId {
1837        unsafe extern "C" fn update_custom_widget_trampoline<
1838            P: IsA<PrintOperation>,
1839            F: Fn(&P, &Widget, &PageSetup, &PrintSettings) + 'static,
1840        >(
1841            this: *mut ffi::GtkPrintOperation,
1842            widget: *mut ffi::GtkWidget,
1843            setup: *mut ffi::GtkPageSetup,
1844            settings: *mut ffi::GtkPrintSettings,
1845            f: glib::ffi::gpointer,
1846        ) {
1847            unsafe {
1848                let f: &F = &*(f as *const F);
1849                f(
1850                    PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1851                    &from_glib_borrow(widget),
1852                    &from_glib_borrow(setup),
1853                    &from_glib_borrow(settings),
1854                )
1855            }
1856        }
1857        unsafe {
1858            let f: Box_<F> = Box_::new(f);
1859            connect_raw(
1860                self.as_ptr() as *mut _,
1861                c"update-custom-widget".as_ptr(),
1862                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1863                    update_custom_widget_trampoline::<Self, F> as *const (),
1864                )),
1865                Box_::into_raw(f),
1866            )
1867        }
1868    }
1869
1870    #[doc(alias = "allow-async")]
1871    fn connect_allow_async_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1872        unsafe extern "C" fn notify_allow_async_trampoline<
1873            P: IsA<PrintOperation>,
1874            F: Fn(&P) + 'static,
1875        >(
1876            this: *mut ffi::GtkPrintOperation,
1877            _param_spec: glib::ffi::gpointer,
1878            f: glib::ffi::gpointer,
1879        ) {
1880            unsafe {
1881                let f: &F = &*(f as *const F);
1882                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1883            }
1884        }
1885        unsafe {
1886            let f: Box_<F> = Box_::new(f);
1887            connect_raw(
1888                self.as_ptr() as *mut _,
1889                c"notify::allow-async".as_ptr(),
1890                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1891                    notify_allow_async_trampoline::<Self, F> as *const (),
1892                )),
1893                Box_::into_raw(f),
1894            )
1895        }
1896    }
1897
1898    #[doc(alias = "current-page")]
1899    fn connect_current_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1900        unsafe extern "C" fn notify_current_page_trampoline<
1901            P: IsA<PrintOperation>,
1902            F: Fn(&P) + 'static,
1903        >(
1904            this: *mut ffi::GtkPrintOperation,
1905            _param_spec: glib::ffi::gpointer,
1906            f: glib::ffi::gpointer,
1907        ) {
1908            unsafe {
1909                let f: &F = &*(f as *const F);
1910                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1911            }
1912        }
1913        unsafe {
1914            let f: Box_<F> = Box_::new(f);
1915            connect_raw(
1916                self.as_ptr() as *mut _,
1917                c"notify::current-page".as_ptr(),
1918                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1919                    notify_current_page_trampoline::<Self, F> as *const (),
1920                )),
1921                Box_::into_raw(f),
1922            )
1923        }
1924    }
1925
1926    #[doc(alias = "custom-tab-label")]
1927    fn connect_custom_tab_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1928        unsafe extern "C" fn notify_custom_tab_label_trampoline<
1929            P: IsA<PrintOperation>,
1930            F: Fn(&P) + 'static,
1931        >(
1932            this: *mut ffi::GtkPrintOperation,
1933            _param_spec: glib::ffi::gpointer,
1934            f: glib::ffi::gpointer,
1935        ) {
1936            unsafe {
1937                let f: &F = &*(f as *const F);
1938                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1939            }
1940        }
1941        unsafe {
1942            let f: Box_<F> = Box_::new(f);
1943            connect_raw(
1944                self.as_ptr() as *mut _,
1945                c"notify::custom-tab-label".as_ptr(),
1946                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1947                    notify_custom_tab_label_trampoline::<Self, F> as *const (),
1948                )),
1949                Box_::into_raw(f),
1950            )
1951        }
1952    }
1953
1954    #[doc(alias = "default-page-setup")]
1955    fn connect_default_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1956        unsafe extern "C" fn notify_default_page_setup_trampoline<
1957            P: IsA<PrintOperation>,
1958            F: Fn(&P) + 'static,
1959        >(
1960            this: *mut ffi::GtkPrintOperation,
1961            _param_spec: glib::ffi::gpointer,
1962            f: glib::ffi::gpointer,
1963        ) {
1964            unsafe {
1965                let f: &F = &*(f as *const F);
1966                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1967            }
1968        }
1969        unsafe {
1970            let f: Box_<F> = Box_::new(f);
1971            connect_raw(
1972                self.as_ptr() as *mut _,
1973                c"notify::default-page-setup".as_ptr(),
1974                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1975                    notify_default_page_setup_trampoline::<Self, F> as *const (),
1976                )),
1977                Box_::into_raw(f),
1978            )
1979        }
1980    }
1981
1982    #[doc(alias = "embed-page-setup")]
1983    fn connect_embed_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1984        unsafe extern "C" fn notify_embed_page_setup_trampoline<
1985            P: IsA<PrintOperation>,
1986            F: Fn(&P) + 'static,
1987        >(
1988            this: *mut ffi::GtkPrintOperation,
1989            _param_spec: glib::ffi::gpointer,
1990            f: glib::ffi::gpointer,
1991        ) {
1992            unsafe {
1993                let f: &F = &*(f as *const F);
1994                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1995            }
1996        }
1997        unsafe {
1998            let f: Box_<F> = Box_::new(f);
1999            connect_raw(
2000                self.as_ptr() as *mut _,
2001                c"notify::embed-page-setup".as_ptr(),
2002                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2003                    notify_embed_page_setup_trampoline::<Self, F> as *const (),
2004                )),
2005                Box_::into_raw(f),
2006            )
2007        }
2008    }
2009
2010    #[doc(alias = "export-filename")]
2011    fn connect_export_filename_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2012        unsafe extern "C" fn notify_export_filename_trampoline<
2013            P: IsA<PrintOperation>,
2014            F: Fn(&P) + 'static,
2015        >(
2016            this: *mut ffi::GtkPrintOperation,
2017            _param_spec: glib::ffi::gpointer,
2018            f: glib::ffi::gpointer,
2019        ) {
2020            unsafe {
2021                let f: &F = &*(f as *const F);
2022                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2023            }
2024        }
2025        unsafe {
2026            let f: Box_<F> = Box_::new(f);
2027            connect_raw(
2028                self.as_ptr() as *mut _,
2029                c"notify::export-filename".as_ptr(),
2030                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2031                    notify_export_filename_trampoline::<Self, F> as *const (),
2032                )),
2033                Box_::into_raw(f),
2034            )
2035        }
2036    }
2037
2038    #[doc(alias = "has-selection")]
2039    fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2040        unsafe extern "C" fn notify_has_selection_trampoline<
2041            P: IsA<PrintOperation>,
2042            F: Fn(&P) + 'static,
2043        >(
2044            this: *mut ffi::GtkPrintOperation,
2045            _param_spec: glib::ffi::gpointer,
2046            f: glib::ffi::gpointer,
2047        ) {
2048            unsafe {
2049                let f: &F = &*(f as *const F);
2050                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2051            }
2052        }
2053        unsafe {
2054            let f: Box_<F> = Box_::new(f);
2055            connect_raw(
2056                self.as_ptr() as *mut _,
2057                c"notify::has-selection".as_ptr(),
2058                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2059                    notify_has_selection_trampoline::<Self, F> as *const (),
2060                )),
2061                Box_::into_raw(f),
2062            )
2063        }
2064    }
2065
2066    #[doc(alias = "job-name")]
2067    fn connect_job_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2068        unsafe extern "C" fn notify_job_name_trampoline<
2069            P: IsA<PrintOperation>,
2070            F: Fn(&P) + 'static,
2071        >(
2072            this: *mut ffi::GtkPrintOperation,
2073            _param_spec: glib::ffi::gpointer,
2074            f: glib::ffi::gpointer,
2075        ) {
2076            unsafe {
2077                let f: &F = &*(f as *const F);
2078                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2079            }
2080        }
2081        unsafe {
2082            let f: Box_<F> = Box_::new(f);
2083            connect_raw(
2084                self.as_ptr() as *mut _,
2085                c"notify::job-name".as_ptr(),
2086                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2087                    notify_job_name_trampoline::<Self, F> as *const (),
2088                )),
2089                Box_::into_raw(f),
2090            )
2091        }
2092    }
2093
2094    #[doc(alias = "n-pages")]
2095    fn connect_n_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2096        unsafe extern "C" fn notify_n_pages_trampoline<
2097            P: IsA<PrintOperation>,
2098            F: Fn(&P) + 'static,
2099        >(
2100            this: *mut ffi::GtkPrintOperation,
2101            _param_spec: glib::ffi::gpointer,
2102            f: glib::ffi::gpointer,
2103        ) {
2104            unsafe {
2105                let f: &F = &*(f as *const F);
2106                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2107            }
2108        }
2109        unsafe {
2110            let f: Box_<F> = Box_::new(f);
2111            connect_raw(
2112                self.as_ptr() as *mut _,
2113                c"notify::n-pages".as_ptr(),
2114                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2115                    notify_n_pages_trampoline::<Self, F> as *const (),
2116                )),
2117                Box_::into_raw(f),
2118            )
2119        }
2120    }
2121
2122    #[doc(alias = "n-pages-to-print")]
2123    fn connect_n_pages_to_print_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2124        unsafe extern "C" fn notify_n_pages_to_print_trampoline<
2125            P: IsA<PrintOperation>,
2126            F: Fn(&P) + 'static,
2127        >(
2128            this: *mut ffi::GtkPrintOperation,
2129            _param_spec: glib::ffi::gpointer,
2130            f: glib::ffi::gpointer,
2131        ) {
2132            unsafe {
2133                let f: &F = &*(f as *const F);
2134                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2135            }
2136        }
2137        unsafe {
2138            let f: Box_<F> = Box_::new(f);
2139            connect_raw(
2140                self.as_ptr() as *mut _,
2141                c"notify::n-pages-to-print".as_ptr(),
2142                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2143                    notify_n_pages_to_print_trampoline::<Self, F> as *const (),
2144                )),
2145                Box_::into_raw(f),
2146            )
2147        }
2148    }
2149
2150    #[doc(alias = "print-settings")]
2151    fn connect_print_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2152        unsafe extern "C" fn notify_print_settings_trampoline<
2153            P: IsA<PrintOperation>,
2154            F: Fn(&P) + 'static,
2155        >(
2156            this: *mut ffi::GtkPrintOperation,
2157            _param_spec: glib::ffi::gpointer,
2158            f: glib::ffi::gpointer,
2159        ) {
2160            unsafe {
2161                let f: &F = &*(f as *const F);
2162                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2163            }
2164        }
2165        unsafe {
2166            let f: Box_<F> = Box_::new(f);
2167            connect_raw(
2168                self.as_ptr() as *mut _,
2169                c"notify::print-settings".as_ptr(),
2170                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2171                    notify_print_settings_trampoline::<Self, F> as *const (),
2172                )),
2173                Box_::into_raw(f),
2174            )
2175        }
2176    }
2177
2178    #[doc(alias = "show-progress")]
2179    fn connect_show_progress_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2180        unsafe extern "C" fn notify_show_progress_trampoline<
2181            P: IsA<PrintOperation>,
2182            F: Fn(&P) + 'static,
2183        >(
2184            this: *mut ffi::GtkPrintOperation,
2185            _param_spec: glib::ffi::gpointer,
2186            f: glib::ffi::gpointer,
2187        ) {
2188            unsafe {
2189                let f: &F = &*(f as *const F);
2190                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2191            }
2192        }
2193        unsafe {
2194            let f: Box_<F> = Box_::new(f);
2195            connect_raw(
2196                self.as_ptr() as *mut _,
2197                c"notify::show-progress".as_ptr(),
2198                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2199                    notify_show_progress_trampoline::<Self, F> as *const (),
2200                )),
2201                Box_::into_raw(f),
2202            )
2203        }
2204    }
2205
2206    #[doc(alias = "status")]
2207    fn connect_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2208        unsafe extern "C" fn notify_status_trampoline<
2209            P: IsA<PrintOperation>,
2210            F: Fn(&P) + 'static,
2211        >(
2212            this: *mut ffi::GtkPrintOperation,
2213            _param_spec: glib::ffi::gpointer,
2214            f: glib::ffi::gpointer,
2215        ) {
2216            unsafe {
2217                let f: &F = &*(f as *const F);
2218                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2219            }
2220        }
2221        unsafe {
2222            let f: Box_<F> = Box_::new(f);
2223            connect_raw(
2224                self.as_ptr() as *mut _,
2225                c"notify::status".as_ptr(),
2226                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2227                    notify_status_trampoline::<Self, F> as *const (),
2228                )),
2229                Box_::into_raw(f),
2230            )
2231        }
2232    }
2233
2234    #[doc(alias = "status-string")]
2235    fn connect_status_string_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2236        unsafe extern "C" fn notify_status_string_trampoline<
2237            P: IsA<PrintOperation>,
2238            F: Fn(&P) + 'static,
2239        >(
2240            this: *mut ffi::GtkPrintOperation,
2241            _param_spec: glib::ffi::gpointer,
2242            f: glib::ffi::gpointer,
2243        ) {
2244            unsafe {
2245                let f: &F = &*(f as *const F);
2246                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2247            }
2248        }
2249        unsafe {
2250            let f: Box_<F> = Box_::new(f);
2251            connect_raw(
2252                self.as_ptr() as *mut _,
2253                c"notify::status-string".as_ptr(),
2254                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2255                    notify_status_string_trampoline::<Self, F> as *const (),
2256                )),
2257                Box_::into_raw(f),
2258            )
2259        }
2260    }
2261
2262    #[doc(alias = "support-selection")]
2263    fn connect_support_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2264        unsafe extern "C" fn notify_support_selection_trampoline<
2265            P: IsA<PrintOperation>,
2266            F: Fn(&P) + 'static,
2267        >(
2268            this: *mut ffi::GtkPrintOperation,
2269            _param_spec: glib::ffi::gpointer,
2270            f: glib::ffi::gpointer,
2271        ) {
2272            unsafe {
2273                let f: &F = &*(f as *const F);
2274                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2275            }
2276        }
2277        unsafe {
2278            let f: Box_<F> = Box_::new(f);
2279            connect_raw(
2280                self.as_ptr() as *mut _,
2281                c"notify::support-selection".as_ptr(),
2282                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2283                    notify_support_selection_trampoline::<Self, F> as *const (),
2284                )),
2285                Box_::into_raw(f),
2286            )
2287        }
2288    }
2289
2290    #[doc(alias = "track-print-status")]
2291    fn connect_track_print_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2292        unsafe extern "C" fn notify_track_print_status_trampoline<
2293            P: IsA<PrintOperation>,
2294            F: Fn(&P) + 'static,
2295        >(
2296            this: *mut ffi::GtkPrintOperation,
2297            _param_spec: glib::ffi::gpointer,
2298            f: glib::ffi::gpointer,
2299        ) {
2300            unsafe {
2301                let f: &F = &*(f as *const F);
2302                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2303            }
2304        }
2305        unsafe {
2306            let f: Box_<F> = Box_::new(f);
2307            connect_raw(
2308                self.as_ptr() as *mut _,
2309                c"notify::track-print-status".as_ptr(),
2310                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2311                    notify_track_print_status_trampoline::<Self, F> as *const (),
2312                )),
2313                Box_::into_raw(f),
2314            )
2315        }
2316    }
2317
2318    #[doc(alias = "unit")]
2319    fn connect_unit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2320        unsafe extern "C" fn notify_unit_trampoline<P: IsA<PrintOperation>, F: Fn(&P) + 'static>(
2321            this: *mut ffi::GtkPrintOperation,
2322            _param_spec: glib::ffi::gpointer,
2323            f: glib::ffi::gpointer,
2324        ) {
2325            unsafe {
2326                let f: &F = &*(f as *const F);
2327                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2328            }
2329        }
2330        unsafe {
2331            let f: Box_<F> = Box_::new(f);
2332            connect_raw(
2333                self.as_ptr() as *mut _,
2334                c"notify::unit".as_ptr(),
2335                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2336                    notify_unit_trampoline::<Self, F> as *const (),
2337                )),
2338                Box_::into_raw(f),
2339            )
2340        }
2341    }
2342
2343    #[doc(alias = "use-full-page")]
2344    fn connect_use_full_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2345        unsafe extern "C" fn notify_use_full_page_trampoline<
2346            P: IsA<PrintOperation>,
2347            F: Fn(&P) + 'static,
2348        >(
2349            this: *mut ffi::GtkPrintOperation,
2350            _param_spec: glib::ffi::gpointer,
2351            f: glib::ffi::gpointer,
2352        ) {
2353            unsafe {
2354                let f: &F = &*(f as *const F);
2355                f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2356            }
2357        }
2358        unsafe {
2359            let f: Box_<F> = Box_::new(f);
2360            connect_raw(
2361                self.as_ptr() as *mut _,
2362                c"notify::use-full-page".as_ptr(),
2363                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2364                    notify_use_full_page_trampoline::<Self, F> as *const (),
2365                )),
2366                Box_::into_raw(f),
2367            )
2368        }
2369    }
2370}
2371
2372impl<O: IsA<PrintOperation>> PrintOperationExt for O {}