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