1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.PrintSettings; 26 27 private import glib.ConstructionException; 28 private import glib.ErrorG; 29 private import glib.GException; 30 private import glib.KeyFile; 31 private import glib.Str; 32 private import glib.Variant; 33 private import gobject.ObjectG; 34 private import gtk.PaperSize; 35 private import gtk.c.functions; 36 public import gtk.c.types; 37 public import gtkc.gtktypes; 38 39 40 /** 41 * A GtkPrintSettings object represents the settings of a print dialog in 42 * a system-independent way. The main use for this object is that once 43 * you’ve printed you can get a settings object that represents the settings 44 * the user chose, and the next time you print you can pass that object in so 45 * that the user doesn’t have to re-set all his settings. 46 * 47 * Its also possible to enumerate the settings so that you can easily save 48 * the settings for the next time your app runs, or even store them in a 49 * document. The predefined keys try to use shared values as much as possible 50 * so that moving such a document between systems still works. 51 * 52 * Printing support was added in GTK+ 2.10. 53 */ 54 public class PrintSettings : ObjectG 55 { 56 /** the main Gtk struct */ 57 protected GtkPrintSettings* gtkPrintSettings; 58 59 /** Get the main Gtk struct */ 60 public GtkPrintSettings* getPrintSettingsStruct(bool transferOwnership = false) 61 { 62 if (transferOwnership) 63 ownedRef = false; 64 return gtkPrintSettings; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gtkPrintSettings; 71 } 72 73 protected override void setStruct(GObject* obj) 74 { 75 gtkPrintSettings = cast(GtkPrintSettings*)obj; 76 super.setStruct(obj); 77 } 78 79 /** 80 * Sets our main struct and passes it to the parent class. 81 */ 82 public this (GtkPrintSettings* gtkPrintSettings, bool ownedRef = false) 83 { 84 this.gtkPrintSettings = gtkPrintSettings; 85 super(cast(GObject*)gtkPrintSettings, ownedRef); 86 } 87 88 89 /** */ 90 public static GType getType() 91 { 92 return gtk_print_settings_get_type(); 93 } 94 95 /** 96 * Creates a new #GtkPrintSettings object. 97 * 98 * Returns: a new #GtkPrintSettings object 99 * 100 * Since: 2.10 101 * 102 * Throws: ConstructionException GTK+ fails to create the object. 103 */ 104 public this() 105 { 106 auto p = gtk_print_settings_new(); 107 108 if(p is null) 109 { 110 throw new ConstructionException("null returned by new"); 111 } 112 113 this(cast(GtkPrintSettings*) p, true); 114 } 115 116 /** 117 * Reads the print settings from @file_name. Returns a new #GtkPrintSettings 118 * object with the restored settings, or %NULL if an error occurred. If the 119 * file could not be loaded then error is set to either a #GFileError or 120 * #GKeyFileError. See gtk_print_settings_to_file(). 121 * 122 * Params: 123 * fileName = the filename to read the settings from 124 * 125 * Returns: the restored #GtkPrintSettings 126 * 127 * Since: 2.12 128 * 129 * Throws: GException on failure. 130 * Throws: ConstructionException GTK+ fails to create the object. 131 */ 132 public this(string fileName) 133 { 134 GError* err = null; 135 136 auto p = gtk_print_settings_new_from_file(Str.toStringz(fileName), &err); 137 138 if (err !is null) 139 { 140 throw new GException( new ErrorG(err) ); 141 } 142 143 if(p is null) 144 { 145 throw new ConstructionException("null returned by new_from_file"); 146 } 147 148 this(cast(GtkPrintSettings*) p, true); 149 } 150 151 /** 152 * Deserialize print settings from an a{sv} variant in 153 * the format produced by gtk_print_settings_to_gvariant(). 154 * 155 * Params: 156 * variant = an a{sv} #GVariant 157 * 158 * Returns: a new #GtkPrintSettings object 159 * 160 * Since: 3.22 161 * 162 * Throws: ConstructionException GTK+ fails to create the object. 163 */ 164 public this(Variant variant) 165 { 166 auto p = gtk_print_settings_new_from_gvariant((variant is null) ? null : variant.getVariantStruct()); 167 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by new_from_gvariant"); 171 } 172 173 this(cast(GtkPrintSettings*) p, true); 174 } 175 176 /** 177 * Reads the print settings from the group @group_name in @key_file. Returns a 178 * new #GtkPrintSettings object with the restored settings, or %NULL if an 179 * error occurred. If the file could not be loaded then error is set to either 180 * a #GFileError or #GKeyFileError. 181 * 182 * Params: 183 * keyFile = the #GKeyFile to retrieve the settings from 184 * groupName = the name of the group to use, or %NULL to use 185 * the default “Print Settings” 186 * 187 * Returns: the restored #GtkPrintSettings 188 * 189 * Since: 2.12 190 * 191 * Throws: GException on failure. 192 * Throws: ConstructionException GTK+ fails to create the object. 193 */ 194 public this(KeyFile keyFile, string groupName) 195 { 196 GError* err = null; 197 198 auto p = gtk_print_settings_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err); 199 200 if (err !is null) 201 { 202 throw new GException( new ErrorG(err) ); 203 } 204 205 if(p is null) 206 { 207 throw new ConstructionException("null returned by new_from_key_file"); 208 } 209 210 this(cast(GtkPrintSettings*) p, true); 211 } 212 213 /** 214 * Copies a #GtkPrintSettings object. 215 * 216 * Returns: a newly allocated copy of @other 217 * 218 * Since: 2.10 219 */ 220 public PrintSettings copy() 221 { 222 auto p = gtk_print_settings_copy(gtkPrintSettings); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return ObjectG.getDObject!(PrintSettings)(cast(GtkPrintSettings*) p, true); 230 } 231 232 /** 233 * Calls @func for each key-value pair of @settings. 234 * 235 * Params: 236 * func = the function to call 237 * userData = user data for @func 238 * 239 * Since: 2.10 240 */ 241 public void foreac(GtkPrintSettingsFunc func, void* userData) 242 { 243 gtk_print_settings_foreach(gtkPrintSettings, func, userData); 244 } 245 246 /** 247 * Looks up the string value associated with @key. 248 * 249 * Params: 250 * key = a key 251 * 252 * Returns: the string value for @key 253 * 254 * Since: 2.10 255 */ 256 public string get(string key) 257 { 258 return Str.toString(gtk_print_settings_get(gtkPrintSettings, Str.toStringz(key))); 259 } 260 261 /** 262 * Returns the boolean represented by the value 263 * that is associated with @key. 264 * 265 * The string “true” represents %TRUE, any other 266 * string %FALSE. 267 * 268 * Params: 269 * key = a key 270 * 271 * Returns: %TRUE, if @key maps to a true value. 272 * 273 * Since: 2.10 274 */ 275 public bool getBool(string key) 276 { 277 return gtk_print_settings_get_bool(gtkPrintSettings, Str.toStringz(key)) != 0; 278 } 279 280 /** 281 * Gets the value of %GTK_PRINT_SETTINGS_COLLATE. 282 * 283 * Returns: whether to collate the printed pages 284 * 285 * Since: 2.10 286 */ 287 public bool getCollate() 288 { 289 return gtk_print_settings_get_collate(gtkPrintSettings) != 0; 290 } 291 292 /** 293 * Gets the value of %GTK_PRINT_SETTINGS_DEFAULT_SOURCE. 294 * 295 * Returns: the default source 296 * 297 * Since: 2.10 298 */ 299 public string getDefaultSource() 300 { 301 return Str.toString(gtk_print_settings_get_default_source(gtkPrintSettings)); 302 } 303 304 /** 305 * Gets the value of %GTK_PRINT_SETTINGS_DITHER. 306 * 307 * Returns: the dithering that is used 308 * 309 * Since: 2.10 310 */ 311 public string getDither() 312 { 313 return Str.toString(gtk_print_settings_get_dither(gtkPrintSettings)); 314 } 315 316 /** 317 * Returns the double value associated with @key, or 0. 318 * 319 * Params: 320 * key = a key 321 * 322 * Returns: the double value of @key 323 * 324 * Since: 2.10 325 */ 326 public double getDouble(string key) 327 { 328 return gtk_print_settings_get_double(gtkPrintSettings, Str.toStringz(key)); 329 } 330 331 /** 332 * Returns the floating point number represented by 333 * the value that is associated with @key, or @default_val 334 * if the value does not represent a floating point number. 335 * 336 * Floating point numbers are parsed with g_ascii_strtod(). 337 * 338 * Params: 339 * key = a key 340 * def = the default value 341 * 342 * Returns: the floating point number associated with @key 343 * 344 * Since: 2.10 345 */ 346 public double getDoubleWithDefault(string key, double def) 347 { 348 return gtk_print_settings_get_double_with_default(gtkPrintSettings, Str.toStringz(key), def); 349 } 350 351 /** 352 * Gets the value of %GTK_PRINT_SETTINGS_DUPLEX. 353 * 354 * Returns: whether to print the output in duplex. 355 * 356 * Since: 2.10 357 */ 358 public GtkPrintDuplex getDuplex() 359 { 360 return gtk_print_settings_get_duplex(gtkPrintSettings); 361 } 362 363 /** 364 * Gets the value of %GTK_PRINT_SETTINGS_FINISHINGS. 365 * 366 * Returns: the finishings 367 * 368 * Since: 2.10 369 */ 370 public string getFinishings() 371 { 372 return Str.toString(gtk_print_settings_get_finishings(gtkPrintSettings)); 373 } 374 375 /** 376 * Returns the integer value of @key, or 0. 377 * 378 * Params: 379 * key = a key 380 * 381 * Returns: the integer value of @key 382 * 383 * Since: 2.10 384 */ 385 public int getInt(string key) 386 { 387 return gtk_print_settings_get_int(gtkPrintSettings, Str.toStringz(key)); 388 } 389 390 /** 391 * Returns the value of @key, interpreted as 392 * an integer, or the default value. 393 * 394 * Params: 395 * key = a key 396 * def = the default value 397 * 398 * Returns: the integer value of @key 399 * 400 * Since: 2.10 401 */ 402 public int getIntWithDefault(string key, int def) 403 { 404 return gtk_print_settings_get_int_with_default(gtkPrintSettings, Str.toStringz(key), def); 405 } 406 407 /** 408 * Returns the value associated with @key, interpreted 409 * as a length. The returned value is converted to @units. 410 * 411 * Params: 412 * key = a key 413 * unit = the unit of the return value 414 * 415 * Returns: the length value of @key, converted to @unit 416 * 417 * Since: 2.10 418 */ 419 public double getLength(string key, GtkUnit unit) 420 { 421 return gtk_print_settings_get_length(gtkPrintSettings, Str.toStringz(key), unit); 422 } 423 424 /** 425 * Gets the value of %GTK_PRINT_SETTINGS_MEDIA_TYPE. 426 * 427 * The set of media types is defined in PWG 5101.1-2002 PWG. 428 * 429 * Returns: the media type 430 * 431 * Since: 2.10 432 */ 433 public string getMediaType() 434 { 435 return Str.toString(gtk_print_settings_get_media_type(gtkPrintSettings)); 436 } 437 438 /** 439 * Gets the value of %GTK_PRINT_SETTINGS_N_COPIES. 440 * 441 * Returns: the number of copies to print 442 * 443 * Since: 2.10 444 */ 445 public int getNCopies() 446 { 447 return gtk_print_settings_get_n_copies(gtkPrintSettings); 448 } 449 450 /** 451 * Gets the value of %GTK_PRINT_SETTINGS_NUMBER_UP. 452 * 453 * Returns: the number of pages per sheet 454 * 455 * Since: 2.10 456 */ 457 public int getNumberUp() 458 { 459 return gtk_print_settings_get_number_up(gtkPrintSettings); 460 } 461 462 /** 463 * Gets the value of %GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT. 464 * 465 * Returns: layout of page in number-up mode 466 * 467 * Since: 2.14 468 */ 469 public GtkNumberUpLayout getNumberUpLayout() 470 { 471 return gtk_print_settings_get_number_up_layout(gtkPrintSettings); 472 } 473 474 /** 475 * Get the value of %GTK_PRINT_SETTINGS_ORIENTATION, 476 * converted to a #GtkPageOrientation. 477 * 478 * Returns: the orientation 479 * 480 * Since: 2.10 481 */ 482 public GtkPageOrientation getOrientation() 483 { 484 return gtk_print_settings_get_orientation(gtkPrintSettings); 485 } 486 487 /** 488 * Gets the value of %GTK_PRINT_SETTINGS_OUTPUT_BIN. 489 * 490 * Returns: the output bin 491 * 492 * Since: 2.10 493 */ 494 public string getOutputBin() 495 { 496 return Str.toString(gtk_print_settings_get_output_bin(gtkPrintSettings)); 497 } 498 499 /** 500 * Gets the value of %GTK_PRINT_SETTINGS_PAGE_RANGES. 501 * 502 * Returns: an array 503 * of #GtkPageRanges. Use g_free() to free the array when 504 * it is no longer needed. 505 * 506 * Since: 2.10 507 */ 508 public GtkPageRange[] getPageRanges() 509 { 510 int numRanges; 511 512 auto p = gtk_print_settings_get_page_ranges(gtkPrintSettings, &numRanges); 513 514 return p[0 .. numRanges]; 515 } 516 517 /** 518 * Gets the value of %GTK_PRINT_SETTINGS_PAGE_SET. 519 * 520 * Returns: the set of pages to print 521 * 522 * Since: 2.10 523 */ 524 public GtkPageSet getPageSet() 525 { 526 return gtk_print_settings_get_page_set(gtkPrintSettings); 527 } 528 529 /** 530 * Gets the value of %GTK_PRINT_SETTINGS_PAPER_HEIGHT, 531 * converted to @unit. 532 * 533 * Params: 534 * unit = the unit for the return value 535 * 536 * Returns: the paper height, in units of @unit 537 * 538 * Since: 2.10 539 */ 540 public double getPaperHeight(GtkUnit unit) 541 { 542 return gtk_print_settings_get_paper_height(gtkPrintSettings, unit); 543 } 544 545 /** 546 * Gets the value of %GTK_PRINT_SETTINGS_PAPER_FORMAT, 547 * converted to a #GtkPaperSize. 548 * 549 * Returns: the paper size 550 * 551 * Since: 2.10 552 */ 553 public PaperSize getPaperSize() 554 { 555 auto p = gtk_print_settings_get_paper_size(gtkPrintSettings); 556 557 if(p is null) 558 { 559 return null; 560 } 561 562 return ObjectG.getDObject!(PaperSize)(cast(GtkPaperSize*) p, true); 563 } 564 565 /** 566 * Gets the value of %GTK_PRINT_SETTINGS_PAPER_WIDTH, 567 * converted to @unit. 568 * 569 * Params: 570 * unit = the unit for the return value 571 * 572 * Returns: the paper width, in units of @unit 573 * 574 * Since: 2.10 575 */ 576 public double getPaperWidth(GtkUnit unit) 577 { 578 return gtk_print_settings_get_paper_width(gtkPrintSettings, unit); 579 } 580 581 /** 582 * Gets the value of %GTK_PRINT_SETTINGS_PRINT_PAGES. 583 * 584 * Returns: which pages to print 585 * 586 * Since: 2.10 587 */ 588 public GtkPrintPages getPrintPages() 589 { 590 return gtk_print_settings_get_print_pages(gtkPrintSettings); 591 } 592 593 /** 594 * Convenience function to obtain the value of 595 * %GTK_PRINT_SETTINGS_PRINTER. 596 * 597 * Returns: the printer name 598 * 599 * Since: 2.10 600 */ 601 public string getPrinter() 602 { 603 return Str.toString(gtk_print_settings_get_printer(gtkPrintSettings)); 604 } 605 606 /** 607 * Gets the value of %GTK_PRINT_SETTINGS_PRINTER_LPI. 608 * 609 * Returns: the resolution in lpi (lines per inch) 610 * 611 * Since: 2.16 612 */ 613 public double getPrinterLpi() 614 { 615 return gtk_print_settings_get_printer_lpi(gtkPrintSettings); 616 } 617 618 /** 619 * Gets the value of %GTK_PRINT_SETTINGS_QUALITY. 620 * 621 * Returns: the print quality 622 * 623 * Since: 2.10 624 */ 625 public GtkPrintQuality getQuality() 626 { 627 return gtk_print_settings_get_quality(gtkPrintSettings); 628 } 629 630 /** 631 * Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION. 632 * 633 * Returns: the resolution in dpi 634 * 635 * Since: 2.10 636 */ 637 public int getResolution() 638 { 639 return gtk_print_settings_get_resolution(gtkPrintSettings); 640 } 641 642 /** 643 * Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION_X. 644 * 645 * Returns: the horizontal resolution in dpi 646 * 647 * Since: 2.16 648 */ 649 public int getResolutionX() 650 { 651 return gtk_print_settings_get_resolution_x(gtkPrintSettings); 652 } 653 654 /** 655 * Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION_Y. 656 * 657 * Returns: the vertical resolution in dpi 658 * 659 * Since: 2.16 660 */ 661 public int getResolutionY() 662 { 663 return gtk_print_settings_get_resolution_y(gtkPrintSettings); 664 } 665 666 /** 667 * Gets the value of %GTK_PRINT_SETTINGS_REVERSE. 668 * 669 * Returns: whether to reverse the order of the printed pages 670 * 671 * Since: 2.10 672 */ 673 public bool getReverse() 674 { 675 return gtk_print_settings_get_reverse(gtkPrintSettings) != 0; 676 } 677 678 /** 679 * Gets the value of %GTK_PRINT_SETTINGS_SCALE. 680 * 681 * Returns: the scale in percent 682 * 683 * Since: 2.10 684 */ 685 public double getScale() 686 { 687 return gtk_print_settings_get_scale(gtkPrintSettings); 688 } 689 690 /** 691 * Gets the value of %GTK_PRINT_SETTINGS_USE_COLOR. 692 * 693 * Returns: whether to use color 694 * 695 * Since: 2.10 696 */ 697 public bool getUseColor() 698 { 699 return gtk_print_settings_get_use_color(gtkPrintSettings) != 0; 700 } 701 702 /** 703 * Returns %TRUE, if a value is associated with @key. 704 * 705 * Params: 706 * key = a key 707 * 708 * Returns: %TRUE, if @key has a value 709 * 710 * Since: 2.10 711 */ 712 public bool hasKey(string key) 713 { 714 return gtk_print_settings_has_key(gtkPrintSettings, Str.toStringz(key)) != 0; 715 } 716 717 /** 718 * Reads the print settings from @file_name. If the file could not be loaded 719 * then error is set to either a #GFileError or #GKeyFileError. 720 * See gtk_print_settings_to_file(). 721 * 722 * Params: 723 * fileName = the filename to read the settings from 724 * 725 * Returns: %TRUE on success 726 * 727 * Since: 2.14 728 * 729 * Throws: GException on failure. 730 */ 731 public bool loadFile(string fileName) 732 { 733 GError* err = null; 734 735 auto p = gtk_print_settings_load_file(gtkPrintSettings, Str.toStringz(fileName), &err) != 0; 736 737 if (err !is null) 738 { 739 throw new GException( new ErrorG(err) ); 740 } 741 742 return p; 743 } 744 745 /** 746 * Reads the print settings from the group @group_name in @key_file. If the 747 * file could not be loaded then error is set to either a #GFileError or 748 * #GKeyFileError. 749 * 750 * Params: 751 * keyFile = the #GKeyFile to retrieve the settings from 752 * groupName = the name of the group to use, or %NULL to use the default 753 * “Print Settings” 754 * 755 * Returns: %TRUE on success 756 * 757 * Since: 2.14 758 * 759 * Throws: GException on failure. 760 */ 761 public bool loadKeyFile(KeyFile keyFile, string groupName) 762 { 763 GError* err = null; 764 765 auto p = gtk_print_settings_load_key_file(gtkPrintSettings, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err) != 0; 766 767 if (err !is null) 768 { 769 throw new GException( new ErrorG(err) ); 770 } 771 772 return p; 773 } 774 775 /** 776 * Associates @value with @key. 777 * 778 * Params: 779 * key = a key 780 * value = a string value, or %NULL 781 * 782 * Since: 2.10 783 */ 784 public void set(string key, string value) 785 { 786 gtk_print_settings_set(gtkPrintSettings, Str.toStringz(key), Str.toStringz(value)); 787 } 788 789 /** 790 * Sets @key to a boolean value. 791 * 792 * Params: 793 * key = a key 794 * value = a boolean 795 * 796 * Since: 2.10 797 */ 798 public void setBool(string key, bool value) 799 { 800 gtk_print_settings_set_bool(gtkPrintSettings, Str.toStringz(key), value); 801 } 802 803 /** 804 * Sets the value of %GTK_PRINT_SETTINGS_COLLATE. 805 * 806 * Params: 807 * collate = whether to collate the output 808 * 809 * Since: 2.10 810 */ 811 public void setCollate(bool collate) 812 { 813 gtk_print_settings_set_collate(gtkPrintSettings, collate); 814 } 815 816 /** 817 * Sets the value of %GTK_PRINT_SETTINGS_DEFAULT_SOURCE. 818 * 819 * Params: 820 * defaultSource = the default source 821 * 822 * Since: 2.10 823 */ 824 public void setDefaultSource(string defaultSource) 825 { 826 gtk_print_settings_set_default_source(gtkPrintSettings, Str.toStringz(defaultSource)); 827 } 828 829 /** 830 * Sets the value of %GTK_PRINT_SETTINGS_DITHER. 831 * 832 * Params: 833 * dither = the dithering that is used 834 * 835 * Since: 2.10 836 */ 837 public void setDither(string dither) 838 { 839 gtk_print_settings_set_dither(gtkPrintSettings, Str.toStringz(dither)); 840 } 841 842 /** 843 * Sets @key to a double value. 844 * 845 * Params: 846 * key = a key 847 * value = a double value 848 * 849 * Since: 2.10 850 */ 851 public void setDouble(string key, double value) 852 { 853 gtk_print_settings_set_double(gtkPrintSettings, Str.toStringz(key), value); 854 } 855 856 /** 857 * Sets the value of %GTK_PRINT_SETTINGS_DUPLEX. 858 * 859 * Params: 860 * duplex = a #GtkPrintDuplex value 861 * 862 * Since: 2.10 863 */ 864 public void setDuplex(GtkPrintDuplex duplex) 865 { 866 gtk_print_settings_set_duplex(gtkPrintSettings, duplex); 867 } 868 869 /** 870 * Sets the value of %GTK_PRINT_SETTINGS_FINISHINGS. 871 * 872 * Params: 873 * finishings = the finishings 874 * 875 * Since: 2.10 876 */ 877 public void setFinishings(string finishings) 878 { 879 gtk_print_settings_set_finishings(gtkPrintSettings, Str.toStringz(finishings)); 880 } 881 882 /** 883 * Sets @key to an integer value. 884 * 885 * Params: 886 * key = a key 887 * value = an integer 888 * 889 * Since: 2.10 890 */ 891 public void setInt(string key, int value) 892 { 893 gtk_print_settings_set_int(gtkPrintSettings, Str.toStringz(key), value); 894 } 895 896 /** 897 * Associates a length in units of @unit with @key. 898 * 899 * Params: 900 * key = a key 901 * value = a length 902 * unit = the unit of @length 903 * 904 * Since: 2.10 905 */ 906 public void setLength(string key, double value, GtkUnit unit) 907 { 908 gtk_print_settings_set_length(gtkPrintSettings, Str.toStringz(key), value, unit); 909 } 910 911 /** 912 * Sets the value of %GTK_PRINT_SETTINGS_MEDIA_TYPE. 913 * 914 * The set of media types is defined in PWG 5101.1-2002 PWG. 915 * 916 * Params: 917 * mediaType = the media type 918 * 919 * Since: 2.10 920 */ 921 public void setMediaType(string mediaType) 922 { 923 gtk_print_settings_set_media_type(gtkPrintSettings, Str.toStringz(mediaType)); 924 } 925 926 /** 927 * Sets the value of %GTK_PRINT_SETTINGS_N_COPIES. 928 * 929 * Params: 930 * numCopies = the number of copies 931 * 932 * Since: 2.10 933 */ 934 public void setNCopies(int numCopies) 935 { 936 gtk_print_settings_set_n_copies(gtkPrintSettings, numCopies); 937 } 938 939 /** 940 * Sets the value of %GTK_PRINT_SETTINGS_NUMBER_UP. 941 * 942 * Params: 943 * numberUp = the number of pages per sheet 944 * 945 * Since: 2.10 946 */ 947 public void setNumberUp(int numberUp) 948 { 949 gtk_print_settings_set_number_up(gtkPrintSettings, numberUp); 950 } 951 952 /** 953 * Sets the value of %GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT. 954 * 955 * Params: 956 * numberUpLayout = a #GtkNumberUpLayout value 957 * 958 * Since: 2.14 959 */ 960 public void setNumberUpLayout(GtkNumberUpLayout numberUpLayout) 961 { 962 gtk_print_settings_set_number_up_layout(gtkPrintSettings, numberUpLayout); 963 } 964 965 /** 966 * Sets the value of %GTK_PRINT_SETTINGS_ORIENTATION. 967 * 968 * Params: 969 * orientation = a page orientation 970 * 971 * Since: 2.10 972 */ 973 public void setOrientation(GtkPageOrientation orientation) 974 { 975 gtk_print_settings_set_orientation(gtkPrintSettings, orientation); 976 } 977 978 /** 979 * Sets the value of %GTK_PRINT_SETTINGS_OUTPUT_BIN. 980 * 981 * Params: 982 * outputBin = the output bin 983 * 984 * Since: 2.10 985 */ 986 public void setOutputBin(string outputBin) 987 { 988 gtk_print_settings_set_output_bin(gtkPrintSettings, Str.toStringz(outputBin)); 989 } 990 991 /** 992 * Sets the value of %GTK_PRINT_SETTINGS_PAGE_RANGES. 993 * 994 * Params: 995 * pageRanges = an array of #GtkPageRanges 996 * 997 * Since: 2.10 998 */ 999 public void setPageRanges(GtkPageRange[] pageRanges) 1000 { 1001 gtk_print_settings_set_page_ranges(gtkPrintSettings, pageRanges.ptr, cast(int)pageRanges.length); 1002 } 1003 1004 /** 1005 * Sets the value of %GTK_PRINT_SETTINGS_PAGE_SET. 1006 * 1007 * Params: 1008 * pageSet = a #GtkPageSet value 1009 * 1010 * Since: 2.10 1011 */ 1012 public void setPageSet(GtkPageSet pageSet) 1013 { 1014 gtk_print_settings_set_page_set(gtkPrintSettings, pageSet); 1015 } 1016 1017 /** 1018 * Sets the value of %GTK_PRINT_SETTINGS_PAPER_HEIGHT. 1019 * 1020 * Params: 1021 * height = the paper height 1022 * unit = the units of @height 1023 * 1024 * Since: 2.10 1025 */ 1026 public void setPaperHeight(double height, GtkUnit unit) 1027 { 1028 gtk_print_settings_set_paper_height(gtkPrintSettings, height, unit); 1029 } 1030 1031 /** 1032 * Sets the value of %GTK_PRINT_SETTINGS_PAPER_FORMAT, 1033 * %GTK_PRINT_SETTINGS_PAPER_WIDTH and 1034 * %GTK_PRINT_SETTINGS_PAPER_HEIGHT. 1035 * 1036 * Params: 1037 * paperSize = a paper size 1038 * 1039 * Since: 2.10 1040 */ 1041 public void setPaperSize(PaperSize paperSize) 1042 { 1043 gtk_print_settings_set_paper_size(gtkPrintSettings, (paperSize is null) ? null : paperSize.getPaperSizeStruct()); 1044 } 1045 1046 /** 1047 * Sets the value of %GTK_PRINT_SETTINGS_PAPER_WIDTH. 1048 * 1049 * Params: 1050 * width = the paper width 1051 * unit = the units of @width 1052 * 1053 * Since: 2.10 1054 */ 1055 public void setPaperWidth(double width, GtkUnit unit) 1056 { 1057 gtk_print_settings_set_paper_width(gtkPrintSettings, width, unit); 1058 } 1059 1060 /** 1061 * Sets the value of %GTK_PRINT_SETTINGS_PRINT_PAGES. 1062 * 1063 * Params: 1064 * pages = a #GtkPrintPages value 1065 * 1066 * Since: 2.10 1067 */ 1068 public void setPrintPages(GtkPrintPages pages) 1069 { 1070 gtk_print_settings_set_print_pages(gtkPrintSettings, pages); 1071 } 1072 1073 /** 1074 * Convenience function to set %GTK_PRINT_SETTINGS_PRINTER 1075 * to @printer. 1076 * 1077 * Params: 1078 * printer = the printer name 1079 * 1080 * Since: 2.10 1081 */ 1082 public void setPrinter(string printer) 1083 { 1084 gtk_print_settings_set_printer(gtkPrintSettings, Str.toStringz(printer)); 1085 } 1086 1087 /** 1088 * Sets the value of %GTK_PRINT_SETTINGS_PRINTER_LPI. 1089 * 1090 * Params: 1091 * lpi = the resolution in lpi (lines per inch) 1092 * 1093 * Since: 2.16 1094 */ 1095 public void setPrinterLpi(double lpi) 1096 { 1097 gtk_print_settings_set_printer_lpi(gtkPrintSettings, lpi); 1098 } 1099 1100 /** 1101 * Sets the value of %GTK_PRINT_SETTINGS_QUALITY. 1102 * 1103 * Params: 1104 * quality = a #GtkPrintQuality value 1105 * 1106 * Since: 2.10 1107 */ 1108 public void setQuality(GtkPrintQuality quality) 1109 { 1110 gtk_print_settings_set_quality(gtkPrintSettings, quality); 1111 } 1112 1113 /** 1114 * Sets the values of %GTK_PRINT_SETTINGS_RESOLUTION, 1115 * %GTK_PRINT_SETTINGS_RESOLUTION_X and 1116 * %GTK_PRINT_SETTINGS_RESOLUTION_Y. 1117 * 1118 * Params: 1119 * resolution = the resolution in dpi 1120 * 1121 * Since: 2.10 1122 */ 1123 public void setResolution(int resolution) 1124 { 1125 gtk_print_settings_set_resolution(gtkPrintSettings, resolution); 1126 } 1127 1128 /** 1129 * Sets the values of %GTK_PRINT_SETTINGS_RESOLUTION, 1130 * %GTK_PRINT_SETTINGS_RESOLUTION_X and 1131 * %GTK_PRINT_SETTINGS_RESOLUTION_Y. 1132 * 1133 * Params: 1134 * resolutionX = the horizontal resolution in dpi 1135 * resolutionY = the vertical resolution in dpi 1136 * 1137 * Since: 2.16 1138 */ 1139 public void setResolutionXy(int resolutionX, int resolutionY) 1140 { 1141 gtk_print_settings_set_resolution_xy(gtkPrintSettings, resolutionX, resolutionY); 1142 } 1143 1144 /** 1145 * Sets the value of %GTK_PRINT_SETTINGS_REVERSE. 1146 * 1147 * Params: 1148 * reverse = whether to reverse the output 1149 * 1150 * Since: 2.10 1151 */ 1152 public void setReverse(bool reverse) 1153 { 1154 gtk_print_settings_set_reverse(gtkPrintSettings, reverse); 1155 } 1156 1157 /** 1158 * Sets the value of %GTK_PRINT_SETTINGS_SCALE. 1159 * 1160 * Params: 1161 * scale = the scale in percent 1162 * 1163 * Since: 2.10 1164 */ 1165 public void setScale(double scale) 1166 { 1167 gtk_print_settings_set_scale(gtkPrintSettings, scale); 1168 } 1169 1170 /** 1171 * Sets the value of %GTK_PRINT_SETTINGS_USE_COLOR. 1172 * 1173 * Params: 1174 * useColor = whether to use color 1175 * 1176 * Since: 2.10 1177 */ 1178 public void setUseColor(bool useColor) 1179 { 1180 gtk_print_settings_set_use_color(gtkPrintSettings, useColor); 1181 } 1182 1183 /** 1184 * This function saves the print settings from @settings to @file_name. If the 1185 * file could not be loaded then error is set to either a #GFileError or 1186 * #GKeyFileError. 1187 * 1188 * Params: 1189 * fileName = the file to save to 1190 * 1191 * Returns: %TRUE on success 1192 * 1193 * Since: 2.12 1194 * 1195 * Throws: GException on failure. 1196 */ 1197 public bool toFile(string fileName) 1198 { 1199 GError* err = null; 1200 1201 auto p = gtk_print_settings_to_file(gtkPrintSettings, Str.toStringz(fileName), &err) != 0; 1202 1203 if (err !is null) 1204 { 1205 throw new GException( new ErrorG(err) ); 1206 } 1207 1208 return p; 1209 } 1210 1211 /** 1212 * Serialize print settings to an a{sv} variant. 1213 * 1214 * Returns: a new, floating, #GVariant 1215 * 1216 * Since: 3.22 1217 */ 1218 public Variant toGvariant() 1219 { 1220 auto p = gtk_print_settings_to_gvariant(gtkPrintSettings); 1221 1222 if(p is null) 1223 { 1224 return null; 1225 } 1226 1227 return new Variant(cast(GVariant*) p); 1228 } 1229 1230 /** 1231 * This function adds the print settings from @settings to @key_file. 1232 * 1233 * Params: 1234 * keyFile = the #GKeyFile to save the print settings to 1235 * groupName = the group to add the settings to in @key_file, or 1236 * %NULL to use the default “Print Settings” 1237 * 1238 * Since: 2.12 1239 */ 1240 public void toKeyFile(KeyFile keyFile, string groupName) 1241 { 1242 gtk_print_settings_to_key_file(gtkPrintSettings, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName)); 1243 } 1244 1245 /** 1246 * Removes any value associated with @key. 1247 * This has the same effect as setting the value to %NULL. 1248 * 1249 * Params: 1250 * key = a key 1251 * 1252 * Since: 2.10 1253 */ 1254 public void unset(string key) 1255 { 1256 gtk_print_settings_unset(gtkPrintSettings, Str.toStringz(key)); 1257 } 1258 }