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