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