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