1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2010, AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  A Gtk_Print_Settings object represents the settings of a print dialog in a 
  26. --  system-independent way. The main use for this object is that once you've 
  27. --  printed you can get a settings object that represents the settings the user 
  28. --  chose, and the next time you print you can pass that object in so that the 
  29. --  user doesn't have to re-set all his settings. 
  30. -- 
  31. --  It's also possible to enumerate the settings so that you can easily save 
  32. --  the settings for the next time your app runs, or even store them in a 
  33. --  document. The predefined keys try to use shared values as much as possible 
  34. --  so that moving such a document between systems still works. 
  35. --  </description> 
  36. --  <c_version>2.16.6</c_version> 
  37.  
  38. with Glib.Error; 
  39. with Glib.Key_File; 
  40. with Glib.Object; 
  41. with Gtk.Enums; 
  42. with Gtk.Paper_Size; 
  43.  
  44. package Gtk.Print_Settings is 
  45.  
  46.    type Gtk_Print_Settings_Record is 
  47.       new Glib.Object.GObject_Record with private; 
  48.    type Gtk_Print_Settings is access all Gtk_Print_Settings_Record'Class; 
  49.  
  50.    function Get_Type return GType; 
  51.  
  52.    procedure Gtk_New (Widget : out Gtk_Print_Settings); 
  53.    procedure Initialize (Widget : access Gtk_Print_Settings_Record'Class); 
  54.    --  Creates a new Gtk_Print_Settings object. 
  55.  
  56.    procedure Gtk_New_From_File 
  57.      (Widget    : out Gtk_Print_Settings; 
  58.       File_Name : String; 
  59.       Error     : Glib.Error.GError := null); 
  60.    procedure Initialize_From_File 
  61.      (Widget    : access Gtk_Print_Settings_Record'Class; 
  62.       File_Name : String; 
  63.       Error     : Glib.Error.GError := null); 
  64.    --  Reads the print settings from File_Name. Returns a new 
  65.    --  Gtk_Print_Settings object with the restored settings, or null if an 
  66.    --  error occurred.  See To_File. 
  67.  
  68.    procedure Gtk_New_From_Key_File 
  69.      (Widget     : out Gtk_Print_Settings; 
  70.       Key_File   : Glib.Key_File.G_Key_File; 
  71.       Group_Name : String := ""; 
  72.       Error      : Glib.Error.GError := null); 
  73.    procedure Initialize_From_Key_File 
  74.      (Widget     : access Gtk_Print_Settings_Record'Class; 
  75.       Key_File   : Glib.Key_File.G_Key_File; 
  76.       Group_Name : String := ""; 
  77.       Error      : Glib.Error.GError := null); 
  78.    --  Reads the print settings from the group Group_Name in Key_File. 
  79.    --  Returns a new Gtk_Print_Settings object with the restored settings, 
  80.    --  or null if an error occurred. 
  81.  
  82.    function Copy 
  83.      (Other : access Gtk_Print_Settings_Record) 
  84.       return Gtk_Print_Settings; 
  85.    --  Copies a Gtk_Print_Settings object. 
  86.  
  87.    ----------------- 
  88.    -- Basic Types -- 
  89.    ----------------- 
  90.  
  91.    function Has_Key 
  92.      (Settings : access Gtk_Print_Settings_Record; 
  93.       Key      : String) 
  94.       return Boolean; 
  95.    --  Returns True, if a value is associated with Key. 
  96.  
  97.    function Get 
  98.      (Settings : access Gtk_Print_Settings_Record; 
  99.       Key      : String) 
  100.       return String; 
  101.    procedure Set 
  102.      (Settings : access Gtk_Print_Settings_Record; 
  103.       Key      : String; 
  104.       Value    : String := ""); 
  105.    --  Manipulate string value associated with Key. 
  106.  
  107.    procedure Unset 
  108.      (Settings : access Gtk_Print_Settings_Record; 
  109.       Key      : String); 
  110.    --  Removes any value associated with Key. 
  111.    --  This has the same effect as setting the value to null. 
  112.  
  113.    function Get_Bool 
  114.      (Settings : access Gtk_Print_Settings_Record; 
  115.       Key      : String) 
  116.       return Boolean; 
  117.    procedure Set_Bool 
  118.      (Settings : access Gtk_Print_Settings_Record; 
  119.       Key      : String; 
  120.       Value    : Boolean); 
  121.    --  Gets/Sets the boolean represented by the value 
  122.    --  that is associated with Key. 
  123.  
  124.    function Get_Double 
  125.      (Settings : access Gtk_Print_Settings_Record; 
  126.       Key      : String; 
  127.       Def      : Gdouble := 0.0) 
  128.       return Gdouble; 
  129.    procedure Set_Double 
  130.      (Settings : access Gtk_Print_Settings_Record; 
  131.       Key      : String; 
  132.       Value    : Gdouble); 
  133.    --  Gets/Sets the floating point number represented by 
  134.    --  the value that is associated with Key, or Def 
  135.    --  if the value does not represent a floating point number. 
  136.    -- 
  137.    --  Floating point numbers are parsed with g_ascii_strtod(). 
  138.  
  139.    function Get_Int 
  140.      (Settings : access Gtk_Print_Settings_Record; 
  141.       Key      : String; 
  142.       Def      : Gint := 0) 
  143.       return Gint; 
  144.    procedure Set_Int 
  145.      (Settings : access Gtk_Print_Settings_Record; 
  146.       Key      : String; 
  147.       Value    : Gint); 
  148.    --  Gets/Sets the value of Key. Get_Int interprets the value as 
  149.    --  an integer, or else returns the default value. 
  150.  
  151.    function Get_Length 
  152.      (Settings : access Gtk_Print_Settings_Record; 
  153.       Key      : String; 
  154.       Unit     : Gtk.Enums.Gtk_Unit) 
  155.       return Gdouble; 
  156.    procedure Set_Length 
  157.      (Settings : access Gtk_Print_Settings_Record; 
  158.       Key      : String; 
  159.       Value    : Gdouble; 
  160.       Unit     : Gtk.Enums.Gtk_Unit); 
  161.    --  Gets/Sets the value associated with Key, interpreted 
  162.    --  as a length. The returned value is converted to Units. 
  163.  
  164.    -------------------- 
  165.    -- Print Settings -- 
  166.    -------------------- 
  167.  
  168.    function Get_Collate 
  169.      (Settings : access Gtk_Print_Settings_Record) 
  170.       return Boolean; 
  171.    procedure Set_Collate 
  172.      (Settings : access Gtk_Print_Settings_Record; 
  173.       Collate  : Boolean); 
  174.    --  Whether to collate the printed pages 
  175.  
  176.    function Get_Default_Source 
  177.      (Settings : access Gtk_Print_Settings_Record) 
  178.       return String; 
  179.    procedure Set_Default_Source 
  180.      (Settings       : access Gtk_Print_Settings_Record; 
  181.       Default_Source : String); 
  182.    --  The default source 
  183.  
  184.    function Get_Dither 
  185.      (Settings : access Gtk_Print_Settings_Record) 
  186.       return String; 
  187.    procedure Set_Dither 
  188.      (Settings : access Gtk_Print_Settings_Record; 
  189.       Dither   : String); 
  190.    --  Gets/Sets the dithering that is used 
  191.  
  192.    function Get_Duplex 
  193.      (Settings : access Gtk_Print_Settings_Record) 
  194.       return Gtk.Enums.Gtk_Print_Duplex; 
  195.    procedure Set_Duplex 
  196.      (Settings : access Gtk_Print_Settings_Record; 
  197.       Duplex   : Gtk.Enums.Gtk_Print_Duplex); 
  198.    --  Whether to print the output in duplex. 
  199.  
  200.    function Get_Finishings 
  201.      (Settings : access Gtk_Print_Settings_Record) 
  202.       return String; 
  203.    procedure Set_Finishings 
  204.      (Settings   : access Gtk_Print_Settings_Record; 
  205.       Finishings : String); 
  206.    --  The finishings 
  207.  
  208.    function Get_Media_Type 
  209.      (Settings : access Gtk_Print_Settings_Record) 
  210.       return String; 
  211.    procedure Set_Media_Type 
  212.      (Settings   : access Gtk_Print_Settings_Record; 
  213.       Media_Type : String); 
  214.    --  Gets/Sets the media type. 
  215.    --  The set of media types is defined in PWG 5101.1-2002 PWG. 
  216.  
  217.    function Get_N_Copies 
  218.      (Settings : access Gtk_Print_Settings_Record) 
  219.       return Gint; 
  220.    procedure Set_N_Copies 
  221.      (Settings   : access Gtk_Print_Settings_Record; 
  222.       Num_Copies : Gint); 
  223.    --  Gets/Sets the number of copies to print 
  224.  
  225.    function Get_Number_Up 
  226.      (Settings : access Gtk_Print_Settings_Record) 
  227.       return Gint; 
  228.    procedure Set_Number_Up 
  229.      (Settings  : access Gtk_Print_Settings_Record; 
  230.       Number_Up : Gint); 
  231.    --  Gets/Sets the number of pages per sheet 
  232.  
  233.    function Get_Number_Up_Layout 
  234.      (Settings : access Gtk_Print_Settings_Record) 
  235.       return Gtk.Enums.Gtk_Number_Up_Layout; 
  236.    procedure Set_Number_Up_Layout 
  237.      (Settings         : access Gtk_Print_Settings_Record; 
  238.       Number_Up_Layout : Gtk.Enums.Gtk_Number_Up_Layout); 
  239.    --  Gets/Sets layout of page in number-up mode 
  240.  
  241.    function Get_Orientation 
  242.      (Settings : access Gtk_Print_Settings_Record) 
  243.       return Gtk.Enums.Gtk_Page_Orientation; 
  244.    procedure Set_Orientation 
  245.      (Settings    : access Gtk_Print_Settings_Record; 
  246.       Orientation : Gtk.Enums.Gtk_Page_Orientation); 
  247.    --  Get the orientation. 
  248.  
  249.    function Get_Output_Bin 
  250.      (Settings : access Gtk_Print_Settings_Record) 
  251.       return String; 
  252.    procedure Set_Output_Bin 
  253.      (Settings   : access Gtk_Print_Settings_Record; 
  254.       Output_Bin : String); 
  255.    --  Gets/Sets the output bin. 
  256.  
  257.    type Gtk_Page_Range_Record is record 
  258.       Range_Start : Gint; 
  259.       Range_End   : Gint; 
  260.    end record; 
  261.    pragma Convention (C, Gtk_Page_Range_Record); 
  262.    type Gtk_Page_Range_Array is 
  263.      array (Integer range <>) of Gtk_Page_Range_Record; 
  264.    pragma Convention (C, Gtk_Page_Range_Array); 
  265.    --  Page range specification(s). 
  266.  
  267.    function Get_Page_Ranges 
  268.      (Settings   : access Gtk_Print_Settings_Record) 
  269.       return Gtk_Page_Range_Array; 
  270.    procedure Set_Page_Ranges 
  271.      (Settings    : access Gtk_Print_Settings_Record; 
  272.       Page_Ranges : access Gtk_Page_Range_Array); 
  273.    --  Gets/Sets an array of Gtk_Page_Range_Records. 
  274.  
  275.    function Get_Page_Set 
  276.      (Settings : access Gtk_Print_Settings_Record) 
  277.       return Gtk.Enums.Gtk_Page_Set; 
  278.    procedure Set_Page_Set 
  279.      (Settings : access Gtk_Print_Settings_Record; 
  280.       Page_Set : Gtk.Enums.Gtk_Page_Set); 
  281.    --  Gets/Sets the set of pages to print 
  282.  
  283.    function Get_Paper_Height 
  284.      (Settings : access Gtk_Print_Settings_Record; 
  285.       Unit     : Gtk.Enums.Gtk_Unit) 
  286.       return Gdouble; 
  287.    function Get_Paper_Width 
  288.      (Settings : access Gtk_Print_Settings_Record; 
  289.       Unit     : Gtk.Enums.Gtk_Unit) 
  290.       return Gdouble; 
  291.    procedure Set_Paper_Height 
  292.      (Settings : access Gtk_Print_Settings_Record; 
  293.       Height   : Gdouble; 
  294.       Unit     : Gtk.Enums.Gtk_Unit); 
  295.    procedure Set_Paper_Width 
  296.      (Settings : access Gtk_Print_Settings_Record; 
  297.       Width    : Gdouble; 
  298.       Unit     : Gtk.Enums.Gtk_Unit); 
  299.    --  Get/Set the paper height/width, in units of Unit 
  300.  
  301.    function Get_Paper_Size 
  302.      (Settings : access Gtk_Print_Settings_Record) 
  303.       return Gtk.Paper_Size.Gtk_Paper_Size; 
  304.    procedure Set_Paper_Size 
  305.      (Settings   : access Gtk_Print_Settings_Record; 
  306.       Paper_Size : Gtk.Paper_Size.Gtk_Paper_Size); 
  307.    --  Sets/Gets the paper size. 
  308.  
  309.    function Get_Print_Pages 
  310.      (Settings : access Gtk_Print_Settings_Record) 
  311.       return Gtk.Enums.Gtk_Print_Pages; 
  312.    procedure Set_Print_Pages 
  313.      (Settings : access Gtk_Print_Settings_Record; 
  314.       Pages    : Gtk.Enums.Gtk_Print_Pages); 
  315.    --  Gets/Sets which pages to print 
  316.  
  317.    function Get_Printer 
  318.      (Settings : access Gtk_Print_Settings_Record) 
  319.       return String; 
  320.    procedure Set_Printer 
  321.      (Settings : access Gtk_Print_Settings_Record; 
  322.       Printer  : String); 
  323.    --  Gets/Sets the printer name 
  324.  
  325.    function Get_Printer_Lpi 
  326.      (Settings : access Gtk_Print_Settings_Record) 
  327.       return Gdouble; 
  328.    procedure Set_Printer_Lpi 
  329.      (Settings : access Gtk_Print_Settings_Record; 
  330.       Lpi      : Gdouble); 
  331.    --  Gets/Sets the resolution in lpi (lines per inch) 
  332.  
  333.    function Get_Quality 
  334.      (Settings : access Gtk_Print_Settings_Record) 
  335.       return Gtk.Enums.Gtk_Print_Quality; 
  336.    procedure Set_Quality 
  337.      (Settings : access Gtk_Print_Settings_Record; 
  338.       Quality  : Gtk.Enums.Gtk_Print_Quality); 
  339.    --  Gets/Sets the print quality 
  340.  
  341.    function Get_Resolution 
  342.      (Settings : access Gtk_Print_Settings_Record) 
  343.       return Gint; 
  344.    procedure Set_Resolution 
  345.      (Settings   : access Gtk_Print_Settings_Record; 
  346.       Resolution : Gint); 
  347.    --  Gets/Sets the resolution in dpi. 
  348.  
  349.    function Get_Resolution_X 
  350.      (Settings : access Gtk_Print_Settings_Record) 
  351.       return Gint; 
  352.    function Get_Resolution_Y 
  353.      (Settings : access Gtk_Print_Settings_Record) 
  354.       return Gint; 
  355.    procedure Set_Resolution_XY 
  356.      (Settings     : access Gtk_Print_Settings_Record; 
  357.       Resolution_X : Gint; 
  358.       Resolution_Y : Gint); 
  359.    --  Gets/Sets the horizontal/vertical resolution, in dpi. 
  360.  
  361.    function Get_Reverse 
  362.      (Settings : access Gtk_Print_Settings_Record) 
  363.       return Boolean; 
  364.    procedure Set_Reverse 
  365.      (Settings : access Gtk_Print_Settings_Record; 
  366.       Rev      : Boolean); 
  367.    --  Returns whether to reverse the order of the printed pages 
  368.  
  369.    function Get_Scale 
  370.      (Settings : access Gtk_Print_Settings_Record) 
  371.       return Gdouble; 
  372.    procedure Set_Scale 
  373.      (Settings : access Gtk_Print_Settings_Record; 
  374.       Scale    : Gdouble); 
  375.    --  Returns the scale in percent 
  376.  
  377.    function Get_Use_Color 
  378.      (Settings : access Gtk_Print_Settings_Record) 
  379.       return Boolean; 
  380.    procedure Set_Use_Color 
  381.      (Settings  : access Gtk_Print_Settings_Record; 
  382.       Use_Color : Boolean); 
  383.    --  Returns whether to use color 
  384.  
  385.    ----------------------------------- 
  386.    -- Saving and Restoring Settings -- 
  387.    ----------------------------------- 
  388.  
  389.    function Load_File 
  390.      (Settings  : access Gtk_Print_Settings_Record; 
  391.       File_Name : String; 
  392.       Error     : Glib.Error.GError := null) 
  393.       return Boolean; 
  394.    --  Reads the print settings from File_Name.  See To_File. 
  395.    --  Returns True on success. 
  396.  
  397.    function Load_Key_File 
  398.      (Settings   : access Gtk_Print_Settings_Record; 
  399.       Key_File   : Glib.Key_File.G_Key_File; 
  400.       Group_Name : String := ""; 
  401.       Error      : Glib.Error.GError := null) 
  402.       return Boolean; 
  403.    --  Reads the print settings from the group Group_Name 
  404.    --  ("Print Settings" by default) in Key_File. 
  405.    --  Returns True on success 
  406.  
  407.    function To_File 
  408.      (Settings  : access Gtk_Print_Settings_Record; 
  409.       File_Name : String; 
  410.       Error     : Glib.Error.GError := null) 
  411.       return Boolean; 
  412.    --  This function saves the print settings from Settings to File_Name. 
  413.    --  Returns True on success 
  414.  
  415.    procedure To_Key_File 
  416.      (Settings   : access Gtk_Print_Settings_Record; 
  417.       Key_File   : Glib.Key_File.G_Key_File; 
  418.       Group_Name : String := ""); 
  419.    --  This function adds the print settings from Settings to Key_File. 
  420.    --  if Group_Name is not specified, it defaults to "Print Settings". 
  421.  
  422. private 
  423.  
  424.    type Gtk_Print_Settings_Record is 
  425.       new Glib.Object.GObject_Record with null record; 
  426.  
  427.    pragma Import (C, Get_Type, "gtk_print_settings_get_type"); 
  428.  
  429. end Gtk.Print_Settings;