Skip to main content

gtk4/auto/
print_settings.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    NumberUpLayout, PageOrientation, PageRange, PageSet, PaperSize, PrintDuplex, PrintPages,
7    PrintQuality, Unit, ffi,
8};
9use glib::translate::*;
10
11glib::wrapper! {
12    /// t have
13    /// to re-set all his settings.
14    ///
15    /// Its also possible to enumerate the settings so that you can easily save
16    /// the settings for the next time your app runs, or even store them in a
17    /// document. The predefined keys try to use shared values as much as possible
18    /// so that moving such a document between systems still works.
19    ///
20    /// # Implements
21    ///
22    /// [`trait@glib::ObjectExt`]
23    #[doc(alias = "GtkPrintSettings")]
24    pub struct PrintSettings(Object<ffi::GtkPrintSettings>);
25
26    match fn {
27        type_ => || ffi::gtk_print_settings_get_type(),
28    }
29}
30
31impl PrintSettings {
32    /// Creates a new [`PrintSettings`][crate::PrintSettings] object.
33    ///
34    /// # Returns
35    ///
36    /// a new [`PrintSettings`][crate::PrintSettings] object
37    #[doc(alias = "gtk_print_settings_new")]
38    pub fn new() -> PrintSettings {
39        assert_initialized_main_thread!();
40        unsafe { from_glib_full(ffi::gtk_print_settings_new()) }
41    }
42
43    /// Reads the print settings from @file_name.
44    ///
45    /// Returns a new [`PrintSettings`][crate::PrintSettings] object with the restored settings,
46    /// or [`None`] if an error occurred. If the file could not be loaded then
47    /// error is set to either a `GFileError` or `GKeyFileError`.
48    ///
49    /// See [`to_file()`][Self::to_file()].
50    /// ## `file_name`
51    /// the filename to read the settings from
52    ///
53    /// # Returns
54    ///
55    /// the restored [`PrintSettings`][crate::PrintSettings]
56    #[doc(alias = "gtk_print_settings_new_from_file")]
57    #[doc(alias = "new_from_file")]
58    pub fn from_file(file_name: impl AsRef<std::path::Path>) -> Result<PrintSettings, glib::Error> {
59        assert_initialized_main_thread!();
60        unsafe {
61            let mut error = std::ptr::null_mut();
62            let ret = ffi::gtk_print_settings_new_from_file(
63                file_name.as_ref().to_glib_none().0,
64                &mut error,
65            );
66            if error.is_null() {
67                Ok(from_glib_full(ret))
68            } else {
69                Err(from_glib_full(error))
70            }
71        }
72    }
73
74    /// Deserialize print settings from an a{sv} variant.
75    ///
76    /// The variant must be in the format produced by
77    /// [`to_gvariant()`][Self::to_gvariant()].
78    /// ## `variant`
79    /// an a{sv} `GVariant`
80    ///
81    /// # Returns
82    ///
83    /// a new [`PrintSettings`][crate::PrintSettings] object
84    #[doc(alias = "gtk_print_settings_new_from_gvariant")]
85    #[doc(alias = "new_from_gvariant")]
86    pub fn from_gvariant(variant: &glib::Variant) -> PrintSettings {
87        assert_initialized_main_thread!();
88        unsafe {
89            from_glib_full(ffi::gtk_print_settings_new_from_gvariant(
90                variant.to_glib_none().0,
91            ))
92        }
93    }
94
95    /// Reads the print settings from the group @group_name in @key_file.
96    ///
97    /// Returns a new [`PrintSettings`][crate::PrintSettings] object with the restored settings,
98    /// or [`None`] if an error occurred. If the file could not be loaded then
99    /// error is set to either `GFileError` or `GKeyFileError`.
100    /// ## `key_file`
101    /// the `GKeyFile` to retrieve the settings from
102    /// ## `group_name`
103    /// Print Settings
104    ///
105    /// # Returns
106    ///
107    /// the restored [`PrintSettings`][crate::PrintSettings]
108    #[doc(alias = "gtk_print_settings_new_from_key_file")]
109    #[doc(alias = "new_from_key_file")]
110    pub fn from_key_file(
111        key_file: &glib::KeyFile,
112        group_name: Option<&str>,
113    ) -> Result<PrintSettings, glib::Error> {
114        assert_initialized_main_thread!();
115        unsafe {
116            let mut error = std::ptr::null_mut();
117            let ret = ffi::gtk_print_settings_new_from_key_file(
118                key_file.to_glib_none().0,
119                group_name.to_glib_none().0,
120                &mut error,
121            );
122            if error.is_null() {
123                Ok(from_glib_full(ret))
124            } else {
125                Err(from_glib_full(error))
126            }
127        }
128    }
129
130    #[doc(alias = "gtk_print_settings_copy")]
131    #[must_use]
132    pub fn copy(&self) -> PrintSettings {
133        unsafe { from_glib_full(ffi::gtk_print_settings_copy(self.to_glib_none().0)) }
134    }
135
136    /// Calls @func for each key-value pair of @self.
137    /// ## `func`
138    /// the function to call
139    #[doc(alias = "gtk_print_settings_foreach")]
140    pub fn foreach<P: FnMut(&str, &str)>(&self, func: P) {
141        let mut func_data: P = func;
142        unsafe extern "C" fn func_func<P: FnMut(&str, &str)>(
143            key: *const std::ffi::c_char,
144            value: *const std::ffi::c_char,
145            user_data: glib::ffi::gpointer,
146        ) {
147            unsafe {
148                let key: Borrowed<glib::GString> = from_glib_borrow(key);
149                let value: Borrowed<glib::GString> = from_glib_borrow(value);
150                let callback = user_data as *mut P;
151                (*callback)(key.as_str(), value.as_str())
152            }
153        }
154        let func = Some(func_func::<P> as _);
155        let super_callback0: &mut P = &mut func_data;
156        unsafe {
157            ffi::gtk_print_settings_foreach(
158                self.to_glib_none().0,
159                func,
160                super_callback0 as *mut _ as *mut _,
161            );
162        }
163    }
164
165    /// Looks up the string value associated with @key.
166    /// ## `key`
167    /// a key
168    ///
169    /// # Returns
170    ///
171    /// the string value for @key
172    #[doc(alias = "gtk_print_settings_get")]
173    pub fn get(&self, key: &str) -> Option<glib::GString> {
174        unsafe {
175            from_glib_none(ffi::gtk_print_settings_get(
176                self.to_glib_none().0,
177                key.to_glib_none().0,
178            ))
179        }
180    }
181
182    ///  represents [`true`], any other
183    /// string [`false`].
184    /// ## `key`
185    /// a key
186    ///
187    /// # Returns
188    ///
189    /// [`true`], if @key maps to a true value.
190    #[doc(alias = "gtk_print_settings_get_bool")]
191    #[doc(alias = "get_bool")]
192    pub fn bool(&self, key: &str) -> bool {
193        unsafe {
194            from_glib(ffi::gtk_print_settings_get_bool(
195                self.to_glib_none().0,
196                key.to_glib_none().0,
197            ))
198        }
199    }
200
201    /// Gets the value of [`PRINT_SETTINGS_COLLATE`][crate::PRINT_SETTINGS_COLLATE].
202    ///
203    /// # Returns
204    ///
205    /// whether to collate the printed pages
206    #[doc(alias = "gtk_print_settings_get_collate")]
207    #[doc(alias = "get_collate")]
208    pub fn is_collate(&self) -> bool {
209        unsafe { from_glib(ffi::gtk_print_settings_get_collate(self.to_glib_none().0)) }
210    }
211
212    /// Gets the value of [`PRINT_SETTINGS_DEFAULT_SOURCE`][crate::PRINT_SETTINGS_DEFAULT_SOURCE].
213    ///
214    /// # Returns
215    ///
216    /// the default source
217    #[doc(alias = "gtk_print_settings_get_default_source")]
218    #[doc(alias = "get_default_source")]
219    pub fn default_source(&self) -> Option<glib::GString> {
220        unsafe {
221            from_glib_none(ffi::gtk_print_settings_get_default_source(
222                self.to_glib_none().0,
223            ))
224        }
225    }
226
227    /// Gets the value of [`PRINT_SETTINGS_DITHER`][crate::PRINT_SETTINGS_DITHER].
228    ///
229    /// # Returns
230    ///
231    /// the dithering that is used
232    #[doc(alias = "gtk_print_settings_get_dither")]
233    #[doc(alias = "get_dither")]
234    pub fn dither(&self) -> Option<glib::GString> {
235        unsafe { from_glib_none(ffi::gtk_print_settings_get_dither(self.to_glib_none().0)) }
236    }
237
238    /// Returns the double value associated with @key, or 0.
239    /// ## `key`
240    /// a key
241    ///
242    /// # Returns
243    ///
244    /// the double value of @key
245    #[doc(alias = "gtk_print_settings_get_double")]
246    #[doc(alias = "get_double")]
247    pub fn double(&self, key: &str) -> f64 {
248        unsafe { ffi::gtk_print_settings_get_double(self.to_glib_none().0, key.to_glib_none().0) }
249    }
250
251    /// Returns the floating point number represented by
252    /// the value that is associated with @key, or @default_val
253    /// if the value does not represent a floating point number.
254    ///
255    /// Floating point numbers are parsed with g_ascii_strtod().
256    /// ## `key`
257    /// a key
258    /// ## `def`
259    /// the default value
260    ///
261    /// # Returns
262    ///
263    /// the floating point number associated with @key
264    #[doc(alias = "gtk_print_settings_get_double_with_default")]
265    #[doc(alias = "get_double_with_default")]
266    pub fn double_with_default(&self, key: &str, def: f64) -> f64 {
267        unsafe {
268            ffi::gtk_print_settings_get_double_with_default(
269                self.to_glib_none().0,
270                key.to_glib_none().0,
271                def,
272            )
273        }
274    }
275
276    /// Gets the value of [`PRINT_SETTINGS_DUPLEX`][crate::PRINT_SETTINGS_DUPLEX].
277    ///
278    /// # Returns
279    ///
280    /// whether to print the output in duplex.
281    #[doc(alias = "gtk_print_settings_get_duplex")]
282    #[doc(alias = "get_duplex")]
283    pub fn duplex(&self) -> PrintDuplex {
284        unsafe { from_glib(ffi::gtk_print_settings_get_duplex(self.to_glib_none().0)) }
285    }
286
287    /// Gets the value of [`PRINT_SETTINGS_FINISHINGS`][crate::PRINT_SETTINGS_FINISHINGS].
288    ///
289    /// # Returns
290    ///
291    /// the finishings
292    #[doc(alias = "gtk_print_settings_get_finishings")]
293    #[doc(alias = "get_finishings")]
294    pub fn finishings(&self) -> Option<glib::GString> {
295        unsafe {
296            from_glib_none(ffi::gtk_print_settings_get_finishings(
297                self.to_glib_none().0,
298            ))
299        }
300    }
301
302    /// Returns the integer value of @key, or 0.
303    /// ## `key`
304    /// a key
305    ///
306    /// # Returns
307    ///
308    /// the integer value of @key
309    #[doc(alias = "gtk_print_settings_get_int")]
310    #[doc(alias = "get_int")]
311    pub fn int(&self, key: &str) -> i32 {
312        unsafe { ffi::gtk_print_settings_get_int(self.to_glib_none().0, key.to_glib_none().0) }
313    }
314
315    /// Returns the value of @key, interpreted as
316    /// an integer, or the default value.
317    /// ## `key`
318    /// a key
319    /// ## `def`
320    /// the default value
321    ///
322    /// # Returns
323    ///
324    /// the integer value of @key
325    #[doc(alias = "gtk_print_settings_get_int_with_default")]
326    #[doc(alias = "get_int_with_default")]
327    pub fn int_with_default(&self, key: &str, def: i32) -> i32 {
328        unsafe {
329            ffi::gtk_print_settings_get_int_with_default(
330                self.to_glib_none().0,
331                key.to_glib_none().0,
332                def,
333            )
334        }
335    }
336
337    /// Returns the value associated with @key, interpreted
338    /// as a length.
339    ///
340    /// The returned value is converted to @units.
341    /// ## `key`
342    /// a key
343    /// ## `unit`
344    /// the unit of the return value
345    ///
346    /// # Returns
347    ///
348    /// the length value of @key, converted to @unit
349    #[doc(alias = "gtk_print_settings_get_length")]
350    #[doc(alias = "get_length")]
351    pub fn length(&self, key: &str, unit: Unit) -> f64 {
352        unsafe {
353            ffi::gtk_print_settings_get_length(
354                self.to_glib_none().0,
355                key.to_glib_none().0,
356                unit.into_glib(),
357            )
358        }
359    }
360
361    /// Gets the value of [`PRINT_SETTINGS_MEDIA_TYPE`][crate::PRINT_SETTINGS_MEDIA_TYPE].
362    ///
363    /// The set of media types is defined in PWG 5101.1-2002 PWG.
364    ///
365    /// # Returns
366    ///
367    /// the media type
368    #[doc(alias = "gtk_print_settings_get_media_type")]
369    #[doc(alias = "get_media_type")]
370    pub fn media_type(&self) -> Option<glib::GString> {
371        unsafe {
372            from_glib_none(ffi::gtk_print_settings_get_media_type(
373                self.to_glib_none().0,
374            ))
375        }
376    }
377
378    /// Gets the value of [`PRINT_SETTINGS_N_COPIES`][crate::PRINT_SETTINGS_N_COPIES].
379    ///
380    /// # Returns
381    ///
382    /// the number of copies to print
383    #[doc(alias = "gtk_print_settings_get_n_copies")]
384    #[doc(alias = "get_n_copies")]
385    pub fn n_copies(&self) -> i32 {
386        unsafe { ffi::gtk_print_settings_get_n_copies(self.to_glib_none().0) }
387    }
388
389    /// Gets the value of [`PRINT_SETTINGS_NUMBER_UP`][crate::PRINT_SETTINGS_NUMBER_UP].
390    ///
391    /// # Returns
392    ///
393    /// the number of pages per sheet
394    #[doc(alias = "gtk_print_settings_get_number_up")]
395    #[doc(alias = "get_number_up")]
396    pub fn number_up(&self) -> i32 {
397        unsafe { ffi::gtk_print_settings_get_number_up(self.to_glib_none().0) }
398    }
399
400    /// Gets the value of [`PRINT_SETTINGS_NUMBER_UP_LAYOUT`][crate::PRINT_SETTINGS_NUMBER_UP_LAYOUT].
401    ///
402    /// # Returns
403    ///
404    /// layout of page in number-up mode
405    #[doc(alias = "gtk_print_settings_get_number_up_layout")]
406    #[doc(alias = "get_number_up_layout")]
407    pub fn number_up_layout(&self) -> NumberUpLayout {
408        unsafe {
409            from_glib(ffi::gtk_print_settings_get_number_up_layout(
410                self.to_glib_none().0,
411            ))
412        }
413    }
414
415    /// Get the value of [`PRINT_SETTINGS_ORIENTATION`][crate::PRINT_SETTINGS_ORIENTATION],
416    /// converted to a [`PageOrientation`][crate::PageOrientation].
417    ///
418    /// # Returns
419    ///
420    /// the orientation
421    #[doc(alias = "gtk_print_settings_get_orientation")]
422    #[doc(alias = "get_orientation")]
423    pub fn orientation(&self) -> PageOrientation {
424        unsafe {
425            from_glib(ffi::gtk_print_settings_get_orientation(
426                self.to_glib_none().0,
427            ))
428        }
429    }
430
431    /// Gets the value of [`PRINT_SETTINGS_OUTPUT_BIN`][crate::PRINT_SETTINGS_OUTPUT_BIN].
432    ///
433    /// # Returns
434    ///
435    /// the output bin
436    #[doc(alias = "gtk_print_settings_get_output_bin")]
437    #[doc(alias = "get_output_bin")]
438    pub fn output_bin(&self) -> Option<glib::GString> {
439        unsafe {
440            from_glib_none(ffi::gtk_print_settings_get_output_bin(
441                self.to_glib_none().0,
442            ))
443        }
444    }
445
446    /// Gets the value of [`PRINT_SETTINGS_PAGE_RANGES`][crate::PRINT_SETTINGS_PAGE_RANGES].
447    ///
448    /// # Returns
449    ///
450    /// an array
451    ///   of [`PageRange`][crate::PageRange]s. Use g_free() to free the array when
452    ///   it is no longer needed.
453    #[doc(alias = "gtk_print_settings_get_page_ranges")]
454    #[doc(alias = "get_page_ranges")]
455    pub fn page_ranges(&self) -> Vec<PageRange> {
456        unsafe {
457            let mut num_ranges = std::mem::MaybeUninit::uninit();
458            let ret = FromGlibContainer::from_glib_full_num(
459                ffi::gtk_print_settings_get_page_ranges(
460                    self.to_glib_none().0,
461                    num_ranges.as_mut_ptr(),
462                ),
463                num_ranges.assume_init() as _,
464            );
465            ret
466        }
467    }
468
469    /// Gets the value of [`PRINT_SETTINGS_PAGE_SET`][crate::PRINT_SETTINGS_PAGE_SET].
470    ///
471    /// # Returns
472    ///
473    /// the set of pages to print
474    #[doc(alias = "gtk_print_settings_get_page_set")]
475    #[doc(alias = "get_page_set")]
476    pub fn page_set(&self) -> PageSet {
477        unsafe { from_glib(ffi::gtk_print_settings_get_page_set(self.to_glib_none().0)) }
478    }
479
480    /// Gets the value of [`PRINT_SETTINGS_PAPER_HEIGHT`][crate::PRINT_SETTINGS_PAPER_HEIGHT],
481    /// converted to @unit.
482    /// ## `unit`
483    /// the unit for the return value
484    ///
485    /// # Returns
486    ///
487    /// the paper height, in units of @unit
488    #[doc(alias = "gtk_print_settings_get_paper_height")]
489    #[doc(alias = "get_paper_height")]
490    pub fn paper_height(&self, unit: Unit) -> f64 {
491        unsafe { ffi::gtk_print_settings_get_paper_height(self.to_glib_none().0, unit.into_glib()) }
492    }
493
494    /// Gets the value of [`PRINT_SETTINGS_PAPER_FORMAT`][crate::PRINT_SETTINGS_PAPER_FORMAT],
495    /// converted to a [`PaperSize`][crate::PaperSize].
496    ///
497    /// # Returns
498    ///
499    /// the paper size
500    #[doc(alias = "gtk_print_settings_get_paper_size")]
501    #[doc(alias = "get_paper_size")]
502    pub fn paper_size(&self) -> Option<PaperSize> {
503        unsafe {
504            from_glib_full(ffi::gtk_print_settings_get_paper_size(
505                self.to_glib_none().0,
506            ))
507        }
508    }
509
510    /// Gets the value of [`PRINT_SETTINGS_PAPER_WIDTH`][crate::PRINT_SETTINGS_PAPER_WIDTH],
511    /// converted to @unit.
512    /// ## `unit`
513    /// the unit for the return value
514    ///
515    /// # Returns
516    ///
517    /// the paper width, in units of @unit
518    #[doc(alias = "gtk_print_settings_get_paper_width")]
519    #[doc(alias = "get_paper_width")]
520    pub fn paper_width(&self, unit: Unit) -> f64 {
521        unsafe { ffi::gtk_print_settings_get_paper_width(self.to_glib_none().0, unit.into_glib()) }
522    }
523
524    /// Gets the value of [`PRINT_SETTINGS_PRINT_PAGES`][crate::PRINT_SETTINGS_PRINT_PAGES].
525    ///
526    /// # Returns
527    ///
528    /// which pages to print
529    #[doc(alias = "gtk_print_settings_get_print_pages")]
530    #[doc(alias = "get_print_pages")]
531    pub fn print_pages(&self) -> PrintPages {
532        unsafe {
533            from_glib(ffi::gtk_print_settings_get_print_pages(
534                self.to_glib_none().0,
535            ))
536        }
537    }
538
539    /// Convenience function to obtain the value of
540    /// [`PRINT_SETTINGS_PRINTER`][crate::PRINT_SETTINGS_PRINTER].
541    ///
542    /// # Returns
543    ///
544    /// the printer name
545    #[doc(alias = "gtk_print_settings_get_printer")]
546    #[doc(alias = "get_printer")]
547    pub fn printer(&self) -> Option<glib::GString> {
548        unsafe { from_glib_none(ffi::gtk_print_settings_get_printer(self.to_glib_none().0)) }
549    }
550
551    /// Gets the value of [`PRINT_SETTINGS_PRINTER_LPI`][crate::PRINT_SETTINGS_PRINTER_LPI].
552    ///
553    /// # Returns
554    ///
555    /// the resolution in lpi (lines per inch)
556    #[doc(alias = "gtk_print_settings_get_printer_lpi")]
557    #[doc(alias = "get_printer_lpi")]
558    pub fn printer_lpi(&self) -> f64 {
559        unsafe { ffi::gtk_print_settings_get_printer_lpi(self.to_glib_none().0) }
560    }
561
562    /// Gets the value of [`PRINT_SETTINGS_QUALITY`][crate::PRINT_SETTINGS_QUALITY].
563    ///
564    /// # Returns
565    ///
566    /// the print quality
567    #[doc(alias = "gtk_print_settings_get_quality")]
568    #[doc(alias = "get_quality")]
569    pub fn quality(&self) -> PrintQuality {
570        unsafe { from_glib(ffi::gtk_print_settings_get_quality(self.to_glib_none().0)) }
571    }
572
573    /// Gets the value of [`PRINT_SETTINGS_RESOLUTION`][crate::PRINT_SETTINGS_RESOLUTION].
574    ///
575    /// # Returns
576    ///
577    /// the resolution in dpi
578    #[doc(alias = "gtk_print_settings_get_resolution")]
579    #[doc(alias = "get_resolution")]
580    pub fn resolution(&self) -> i32 {
581        unsafe { ffi::gtk_print_settings_get_resolution(self.to_glib_none().0) }
582    }
583
584    /// Gets the value of [`PRINT_SETTINGS_RESOLUTION_X`][crate::PRINT_SETTINGS_RESOLUTION_X].
585    ///
586    /// # Returns
587    ///
588    /// the horizontal resolution in dpi
589    #[doc(alias = "gtk_print_settings_get_resolution_x")]
590    #[doc(alias = "get_resolution_x")]
591    pub fn resolution_x(&self) -> i32 {
592        unsafe { ffi::gtk_print_settings_get_resolution_x(self.to_glib_none().0) }
593    }
594
595    /// Gets the value of [`PRINT_SETTINGS_RESOLUTION_Y`][crate::PRINT_SETTINGS_RESOLUTION_Y].
596    ///
597    /// # Returns
598    ///
599    /// the vertical resolution in dpi
600    #[doc(alias = "gtk_print_settings_get_resolution_y")]
601    #[doc(alias = "get_resolution_y")]
602    pub fn resolution_y(&self) -> i32 {
603        unsafe { ffi::gtk_print_settings_get_resolution_y(self.to_glib_none().0) }
604    }
605
606    /// Gets the value of [`PRINT_SETTINGS_REVERSE`][crate::PRINT_SETTINGS_REVERSE].
607    ///
608    /// # Returns
609    ///
610    /// whether to reverse the order of the printed pages
611    #[doc(alias = "gtk_print_settings_get_reverse")]
612    #[doc(alias = "get_reverse")]
613    pub fn is_reverse(&self) -> bool {
614        unsafe { from_glib(ffi::gtk_print_settings_get_reverse(self.to_glib_none().0)) }
615    }
616
617    /// Gets the value of [`PRINT_SETTINGS_SCALE`][crate::PRINT_SETTINGS_SCALE].
618    ///
619    /// # Returns
620    ///
621    /// the scale in percent
622    #[doc(alias = "gtk_print_settings_get_scale")]
623    #[doc(alias = "get_scale")]
624    pub fn scale(&self) -> f64 {
625        unsafe { ffi::gtk_print_settings_get_scale(self.to_glib_none().0) }
626    }
627
628    /// Gets the value of [`PRINT_SETTINGS_USE_COLOR`][crate::PRINT_SETTINGS_USE_COLOR].
629    ///
630    /// # Returns
631    ///
632    /// whether to use color
633    #[doc(alias = "gtk_print_settings_get_use_color")]
634    #[doc(alias = "get_use_color")]
635    pub fn uses_color(&self) -> bool {
636        unsafe { from_glib(ffi::gtk_print_settings_get_use_color(self.to_glib_none().0)) }
637    }
638
639    /// Returns [`true`], if a value is associated with @key.
640    /// ## `key`
641    /// a key
642    ///
643    /// # Returns
644    ///
645    /// [`true`], if @key has a value
646    #[doc(alias = "gtk_print_settings_has_key")]
647    pub fn has_key(&self, key: &str) -> bool {
648        unsafe {
649            from_glib(ffi::gtk_print_settings_has_key(
650                self.to_glib_none().0,
651                key.to_glib_none().0,
652            ))
653        }
654    }
655
656    /// Reads the print settings from @file_name.
657    ///
658    /// If the file could not be loaded then error is set to either
659    /// a `GFileError` or `GKeyFileError`.
660    ///
661    /// See [`to_file()`][Self::to_file()].
662    /// ## `file_name`
663    /// the filename to read the settings from
664    ///
665    /// # Returns
666    ///
667    /// [`true`] on success
668    #[doc(alias = "gtk_print_settings_load_file")]
669    pub fn load_file(&self, file_name: impl AsRef<std::path::Path>) -> Result<(), glib::Error> {
670        unsafe {
671            let mut error = std::ptr::null_mut();
672            let is_ok = ffi::gtk_print_settings_load_file(
673                self.to_glib_none().0,
674                file_name.as_ref().to_glib_none().0,
675                &mut error,
676            );
677            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
678            if error.is_null() {
679                Ok(())
680            } else {
681                Err(from_glib_full(error))
682            }
683        }
684    }
685
686    /// Reads the print settings from the group @group_name in @key_file.
687    ///
688    /// If the file could not be loaded then error is set to either a
689    /// `GFileError` or `GKeyFileError`.
690    /// ## `key_file`
691    /// the `GKeyFile` to retrieve the settings from
692    /// ## `group_name`
693    /// Print Settings
694    ///
695    /// # Returns
696    ///
697    /// [`true`] on success
698    #[doc(alias = "gtk_print_settings_load_key_file")]
699    pub fn load_key_file(
700        &self,
701        key_file: &glib::KeyFile,
702        group_name: Option<&str>,
703    ) -> Result<(), glib::Error> {
704        unsafe {
705            let mut error = std::ptr::null_mut();
706            let is_ok = ffi::gtk_print_settings_load_key_file(
707                self.to_glib_none().0,
708                key_file.to_glib_none().0,
709                group_name.to_glib_none().0,
710                &mut error,
711            );
712            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
713            if error.is_null() {
714                Ok(())
715            } else {
716                Err(from_glib_full(error))
717            }
718        }
719    }
720
721    /// Associates @value with @key.
722    /// ## `key`
723    /// a key
724    /// ## `value`
725    /// a string value
726    #[doc(alias = "gtk_print_settings_set")]
727    pub fn set(&self, key: &str, value: Option<&str>) {
728        unsafe {
729            ffi::gtk_print_settings_set(
730                self.to_glib_none().0,
731                key.to_glib_none().0,
732                value.to_glib_none().0,
733            );
734        }
735    }
736
737    /// Sets @key to a boolean value.
738    /// ## `key`
739    /// a key
740    /// ## `value`
741    /// a boolean
742    #[doc(alias = "gtk_print_settings_set_bool")]
743    pub fn set_bool(&self, key: &str, value: bool) {
744        unsafe {
745            ffi::gtk_print_settings_set_bool(
746                self.to_glib_none().0,
747                key.to_glib_none().0,
748                value.into_glib(),
749            );
750        }
751    }
752
753    /// Sets the value of [`PRINT_SETTINGS_COLLATE`][crate::PRINT_SETTINGS_COLLATE].
754    /// ## `collate`
755    /// whether to collate the output
756    #[doc(alias = "gtk_print_settings_set_collate")]
757    pub fn set_collate(&self, collate: bool) {
758        unsafe {
759            ffi::gtk_print_settings_set_collate(self.to_glib_none().0, collate.into_glib());
760        }
761    }
762
763    /// Sets the value of [`PRINT_SETTINGS_DEFAULT_SOURCE`][crate::PRINT_SETTINGS_DEFAULT_SOURCE].
764    /// ## `default_source`
765    /// the default source
766    #[doc(alias = "gtk_print_settings_set_default_source")]
767    pub fn set_default_source(&self, default_source: &str) {
768        unsafe {
769            ffi::gtk_print_settings_set_default_source(
770                self.to_glib_none().0,
771                default_source.to_glib_none().0,
772            );
773        }
774    }
775
776    /// Sets the value of [`PRINT_SETTINGS_DITHER`][crate::PRINT_SETTINGS_DITHER].
777    /// ## `dither`
778    /// the dithering that is used
779    #[doc(alias = "gtk_print_settings_set_dither")]
780    pub fn set_dither(&self, dither: &str) {
781        unsafe {
782            ffi::gtk_print_settings_set_dither(self.to_glib_none().0, dither.to_glib_none().0);
783        }
784    }
785
786    /// Sets @key to a double value.
787    /// ## `key`
788    /// a key
789    /// ## `value`
790    /// a double value
791    #[doc(alias = "gtk_print_settings_set_double")]
792    pub fn set_double(&self, key: &str, value: f64) {
793        unsafe {
794            ffi::gtk_print_settings_set_double(self.to_glib_none().0, key.to_glib_none().0, value);
795        }
796    }
797
798    /// Sets the value of [`PRINT_SETTINGS_DUPLEX`][crate::PRINT_SETTINGS_DUPLEX].
799    /// ## `duplex`
800    /// a [`PrintDuplex`][crate::PrintDuplex] value
801    #[doc(alias = "gtk_print_settings_set_duplex")]
802    pub fn set_duplex(&self, duplex: PrintDuplex) {
803        unsafe {
804            ffi::gtk_print_settings_set_duplex(self.to_glib_none().0, duplex.into_glib());
805        }
806    }
807
808    /// Sets the value of [`PRINT_SETTINGS_FINISHINGS`][crate::PRINT_SETTINGS_FINISHINGS].
809    /// ## `finishings`
810    /// the finishings
811    #[doc(alias = "gtk_print_settings_set_finishings")]
812    pub fn set_finishings(&self, finishings: &str) {
813        unsafe {
814            ffi::gtk_print_settings_set_finishings(
815                self.to_glib_none().0,
816                finishings.to_glib_none().0,
817            );
818        }
819    }
820
821    /// Sets @key to an integer value.
822    /// ## `key`
823    /// a key
824    /// ## `value`
825    /// an integer
826    #[doc(alias = "gtk_print_settings_set_int")]
827    pub fn set_int(&self, key: &str, value: i32) {
828        unsafe {
829            ffi::gtk_print_settings_set_int(self.to_glib_none().0, key.to_glib_none().0, value);
830        }
831    }
832
833    /// Associates a length in units of @unit with @key.
834    /// ## `key`
835    /// a key
836    /// ## `value`
837    /// a length
838    /// ## `unit`
839    /// the unit of @length
840    #[doc(alias = "gtk_print_settings_set_length")]
841    pub fn set_length(&self, key: &str, value: f64, unit: Unit) {
842        unsafe {
843            ffi::gtk_print_settings_set_length(
844                self.to_glib_none().0,
845                key.to_glib_none().0,
846                value,
847                unit.into_glib(),
848            );
849        }
850    }
851
852    /// Sets the value of [`PRINT_SETTINGS_MEDIA_TYPE`][crate::PRINT_SETTINGS_MEDIA_TYPE].
853    ///
854    /// The set of media types is defined in PWG 5101.1-2002 PWG.
855    /// ## `media_type`
856    /// the media type
857    #[doc(alias = "gtk_print_settings_set_media_type")]
858    pub fn set_media_type(&self, media_type: &str) {
859        unsafe {
860            ffi::gtk_print_settings_set_media_type(
861                self.to_glib_none().0,
862                media_type.to_glib_none().0,
863            );
864        }
865    }
866
867    /// Sets the value of [`PRINT_SETTINGS_N_COPIES`][crate::PRINT_SETTINGS_N_COPIES].
868    /// ## `num_copies`
869    /// the number of copies
870    #[doc(alias = "gtk_print_settings_set_n_copies")]
871    pub fn set_n_copies(&self, num_copies: i32) {
872        unsafe {
873            ffi::gtk_print_settings_set_n_copies(self.to_glib_none().0, num_copies);
874        }
875    }
876
877    /// Sets the value of [`PRINT_SETTINGS_NUMBER_UP`][crate::PRINT_SETTINGS_NUMBER_UP].
878    /// ## `number_up`
879    /// the number of pages per sheet
880    #[doc(alias = "gtk_print_settings_set_number_up")]
881    pub fn set_number_up(&self, number_up: i32) {
882        unsafe {
883            ffi::gtk_print_settings_set_number_up(self.to_glib_none().0, number_up);
884        }
885    }
886
887    /// Sets the value of [`PRINT_SETTINGS_NUMBER_UP_LAYOUT`][crate::PRINT_SETTINGS_NUMBER_UP_LAYOUT].
888    /// ## `number_up_layout`
889    /// a [`NumberUpLayout`][crate::NumberUpLayout] value
890    #[doc(alias = "gtk_print_settings_set_number_up_layout")]
891    pub fn set_number_up_layout(&self, number_up_layout: NumberUpLayout) {
892        unsafe {
893            ffi::gtk_print_settings_set_number_up_layout(
894                self.to_glib_none().0,
895                number_up_layout.into_glib(),
896            );
897        }
898    }
899
900    /// Sets the value of [`PRINT_SETTINGS_ORIENTATION`][crate::PRINT_SETTINGS_ORIENTATION].
901    /// ## `orientation`
902    /// a page orientation
903    #[doc(alias = "gtk_print_settings_set_orientation")]
904    pub fn set_orientation(&self, orientation: PageOrientation) {
905        unsafe {
906            ffi::gtk_print_settings_set_orientation(self.to_glib_none().0, orientation.into_glib());
907        }
908    }
909
910    /// Sets the value of [`PRINT_SETTINGS_OUTPUT_BIN`][crate::PRINT_SETTINGS_OUTPUT_BIN].
911    /// ## `output_bin`
912    /// the output bin
913    #[doc(alias = "gtk_print_settings_set_output_bin")]
914    pub fn set_output_bin(&self, output_bin: &str) {
915        unsafe {
916            ffi::gtk_print_settings_set_output_bin(
917                self.to_glib_none().0,
918                output_bin.to_glib_none().0,
919            );
920        }
921    }
922
923    /// Sets the value of [`PRINT_SETTINGS_PAGE_SET`][crate::PRINT_SETTINGS_PAGE_SET].
924    /// ## `page_set`
925    /// a [`PageSet`][crate::PageSet] value
926    #[doc(alias = "gtk_print_settings_set_page_set")]
927    pub fn set_page_set(&self, page_set: PageSet) {
928        unsafe {
929            ffi::gtk_print_settings_set_page_set(self.to_glib_none().0, page_set.into_glib());
930        }
931    }
932
933    /// Sets the value of [`PRINT_SETTINGS_PAPER_HEIGHT`][crate::PRINT_SETTINGS_PAPER_HEIGHT].
934    /// ## `height`
935    /// the paper height
936    /// ## `unit`
937    /// the units of @height
938    #[doc(alias = "gtk_print_settings_set_paper_height")]
939    pub fn set_paper_height(&self, height: f64, unit: Unit) {
940        unsafe {
941            ffi::gtk_print_settings_set_paper_height(
942                self.to_glib_none().0,
943                height,
944                unit.into_glib(),
945            );
946        }
947    }
948
949    /// Sets the value of [`PRINT_SETTINGS_PAPER_FORMAT`][crate::PRINT_SETTINGS_PAPER_FORMAT],
950    /// [`PRINT_SETTINGS_PAPER_WIDTH`][crate::PRINT_SETTINGS_PAPER_WIDTH] and
951    /// [`PRINT_SETTINGS_PAPER_HEIGHT`][crate::PRINT_SETTINGS_PAPER_HEIGHT].
952    /// ## `paper_size`
953    /// a paper size
954    #[doc(alias = "gtk_print_settings_set_paper_size")]
955    pub fn set_paper_size(&self, paper_size: &PaperSize) {
956        unsafe {
957            ffi::gtk_print_settings_set_paper_size(
958                self.to_glib_none().0,
959                mut_override(paper_size.to_glib_none().0),
960            );
961        }
962    }
963
964    /// Sets the value of [`PRINT_SETTINGS_PAPER_WIDTH`][crate::PRINT_SETTINGS_PAPER_WIDTH].
965    /// ## `width`
966    /// the paper width
967    /// ## `unit`
968    /// the units of @width
969    #[doc(alias = "gtk_print_settings_set_paper_width")]
970    pub fn set_paper_width(&self, width: f64, unit: Unit) {
971        unsafe {
972            ffi::gtk_print_settings_set_paper_width(self.to_glib_none().0, width, unit.into_glib());
973        }
974    }
975
976    /// Sets the value of [`PRINT_SETTINGS_PRINT_PAGES`][crate::PRINT_SETTINGS_PRINT_PAGES].
977    /// ## `pages`
978    /// a [`PrintPages`][crate::PrintPages] value
979    #[doc(alias = "gtk_print_settings_set_print_pages")]
980    pub fn set_print_pages(&self, pages: PrintPages) {
981        unsafe {
982            ffi::gtk_print_settings_set_print_pages(self.to_glib_none().0, pages.into_glib());
983        }
984    }
985
986    /// Convenience function to set [`PRINT_SETTINGS_PRINTER`][crate::PRINT_SETTINGS_PRINTER]
987    /// to @printer.
988    /// ## `printer`
989    /// the printer name
990    #[doc(alias = "gtk_print_settings_set_printer")]
991    pub fn set_printer(&self, printer: &str) {
992        unsafe {
993            ffi::gtk_print_settings_set_printer(self.to_glib_none().0, printer.to_glib_none().0);
994        }
995    }
996
997    /// Sets the value of [`PRINT_SETTINGS_PRINTER_LPI`][crate::PRINT_SETTINGS_PRINTER_LPI].
998    /// ## `lpi`
999    /// the resolution in lpi (lines per inch)
1000    #[doc(alias = "gtk_print_settings_set_printer_lpi")]
1001    pub fn set_printer_lpi(&self, lpi: f64) {
1002        unsafe {
1003            ffi::gtk_print_settings_set_printer_lpi(self.to_glib_none().0, lpi);
1004        }
1005    }
1006
1007    /// Sets the value of [`PRINT_SETTINGS_QUALITY`][crate::PRINT_SETTINGS_QUALITY].
1008    /// ## `quality`
1009    /// a [`PrintQuality`][crate::PrintQuality] value
1010    #[doc(alias = "gtk_print_settings_set_quality")]
1011    pub fn set_quality(&self, quality: PrintQuality) {
1012        unsafe {
1013            ffi::gtk_print_settings_set_quality(self.to_glib_none().0, quality.into_glib());
1014        }
1015    }
1016
1017    /// Sets the values of [`PRINT_SETTINGS_RESOLUTION`][crate::PRINT_SETTINGS_RESOLUTION],
1018    /// [`PRINT_SETTINGS_RESOLUTION_X`][crate::PRINT_SETTINGS_RESOLUTION_X] and
1019    /// [`PRINT_SETTINGS_RESOLUTION_Y`][crate::PRINT_SETTINGS_RESOLUTION_Y].
1020    /// ## `resolution`
1021    /// the resolution in dpi
1022    #[doc(alias = "gtk_print_settings_set_resolution")]
1023    pub fn set_resolution(&self, resolution: i32) {
1024        unsafe {
1025            ffi::gtk_print_settings_set_resolution(self.to_glib_none().0, resolution);
1026        }
1027    }
1028
1029    /// Sets the values of [`PRINT_SETTINGS_RESOLUTION`][crate::PRINT_SETTINGS_RESOLUTION],
1030    /// [`PRINT_SETTINGS_RESOLUTION_X`][crate::PRINT_SETTINGS_RESOLUTION_X] and
1031    /// [`PRINT_SETTINGS_RESOLUTION_Y`][crate::PRINT_SETTINGS_RESOLUTION_Y].
1032    /// ## `resolution_x`
1033    /// the horizontal resolution in dpi
1034    /// ## `resolution_y`
1035    /// the vertical resolution in dpi
1036    #[doc(alias = "gtk_print_settings_set_resolution_xy")]
1037    pub fn set_resolution_xy(&self, resolution_x: i32, resolution_y: i32) {
1038        unsafe {
1039            ffi::gtk_print_settings_set_resolution_xy(
1040                self.to_glib_none().0,
1041                resolution_x,
1042                resolution_y,
1043            );
1044        }
1045    }
1046
1047    /// Sets the value of [`PRINT_SETTINGS_REVERSE`][crate::PRINT_SETTINGS_REVERSE].
1048    /// ## `reverse`
1049    /// whether to reverse the output
1050    #[doc(alias = "gtk_print_settings_set_reverse")]
1051    pub fn set_reverse(&self, reverse: bool) {
1052        unsafe {
1053            ffi::gtk_print_settings_set_reverse(self.to_glib_none().0, reverse.into_glib());
1054        }
1055    }
1056
1057    /// Sets the value of [`PRINT_SETTINGS_SCALE`][crate::PRINT_SETTINGS_SCALE].
1058    /// ## `scale`
1059    /// the scale in percent
1060    #[doc(alias = "gtk_print_settings_set_scale")]
1061    pub fn set_scale(&self, scale: f64) {
1062        unsafe {
1063            ffi::gtk_print_settings_set_scale(self.to_glib_none().0, scale);
1064        }
1065    }
1066
1067    /// Sets the value of [`PRINT_SETTINGS_USE_COLOR`][crate::PRINT_SETTINGS_USE_COLOR].
1068    /// ## `use_color`
1069    /// whether to use color
1070    #[doc(alias = "gtk_print_settings_set_use_color")]
1071    pub fn set_use_color(&self, use_color: bool) {
1072        unsafe {
1073            ffi::gtk_print_settings_set_use_color(self.to_glib_none().0, use_color.into_glib());
1074        }
1075    }
1076
1077    /// This function saves the print settings from @self to @file_name.
1078    ///
1079    /// If the file could not be written then error is set to either a
1080    /// `GFileError` or `GKeyFileError`.
1081    /// ## `file_name`
1082    /// the file to save to
1083    ///
1084    /// # Returns
1085    ///
1086    /// [`true`] on success
1087    #[doc(alias = "gtk_print_settings_to_file")]
1088    pub fn to_file(&self, file_name: impl AsRef<std::path::Path>) -> Result<(), glib::Error> {
1089        unsafe {
1090            let mut error = std::ptr::null_mut();
1091            let is_ok = ffi::gtk_print_settings_to_file(
1092                self.to_glib_none().0,
1093                file_name.as_ref().to_glib_none().0,
1094                &mut error,
1095            );
1096            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1097            if error.is_null() {
1098                Ok(())
1099            } else {
1100                Err(from_glib_full(error))
1101            }
1102        }
1103    }
1104
1105    /// Serialize print settings to an a{sv} variant.
1106    ///
1107    /// # Returns
1108    ///
1109    /// a new, floating, `GVariant`
1110    #[doc(alias = "gtk_print_settings_to_gvariant")]
1111    pub fn to_gvariant(&self) -> glib::Variant {
1112        unsafe { from_glib_none(ffi::gtk_print_settings_to_gvariant(self.to_glib_none().0)) }
1113    }
1114
1115    /// This function adds the print settings from @self to @key_file.
1116    /// ## `key_file`
1117    /// the `GKeyFile` to save the print settings to
1118    /// ## `group_name`
1119    /// Print Settings
1120    #[doc(alias = "gtk_print_settings_to_key_file")]
1121    pub fn to_key_file(&self, key_file: &glib::KeyFile, group_name: Option<&str>) {
1122        unsafe {
1123            ffi::gtk_print_settings_to_key_file(
1124                self.to_glib_none().0,
1125                key_file.to_glib_none().0,
1126                group_name.to_glib_none().0,
1127            );
1128        }
1129    }
1130
1131    /// Removes any value associated with @key.
1132    ///
1133    /// This has the same effect as setting the value to [`None`].
1134    /// ## `key`
1135    /// a key
1136    #[doc(alias = "gtk_print_settings_unset")]
1137    pub fn unset(&self, key: &str) {
1138        unsafe {
1139            ffi::gtk_print_settings_unset(self.to_glib_none().0, key.to_glib_none().0);
1140        }
1141    }
1142}
1143
1144impl Default for PrintSettings {
1145    fn default() -> Self {
1146        Self::new()
1147    }
1148}