1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  Gtk.Recent_Chooser_Dialog.Gtk_Recent_Chooser_Dialog is a dialog box 
  26. --  suitable for displaying the recently used documents. This widgets works by 
  27. --  putting a Gtk.Recent_Chooser_Widget.Gtk_Recent_Chooser_Widget inside a 
  28. --  Gtk.Dialog.Gtk_Dialog. It exposes the Gtk_Recent_Chooser_Iface interface, 
  29. --  so you can use all the Gtk.Recent_Chooser.Gtk_Recent_Chooser functions on 
  30. --  the recent chooser dialog as well as those for Gtk.Dialog.Gtk_Dialog. 
  31. -- 
  32. --  Note that Gtk.Recent_Chooser_Dialog.Gtk_Recent_Chooser_Dialog does not 
  33. --  have any methods of its own. Instead, you should use the functions that 
  34. --  work on a Gtk.Recent_Chooser.Gtk_Recent_Chooser. 
  35. -- 
  36. --  <example id="gtkrecentchooser-typical-usage"> 
  37. --  == Typical usage == 
  38. -- 
  39. --  In the simplest of cases, you can use the following code to use a 
  40. --  Gtk.Recent_Chooser_Dialog.Gtk_Recent_Chooser_Dialog to select a recently 
  41. --  used file: 
  42. -- 
  43. --    GtkWidget *dialog; 
  44. --    dialog = gtk_recent_chooser_dialog_new ("Recent Documents", 
  45. --       parent_window, 
  46. --       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 
  47. --       GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 
  48. --       NULL); 
  49. --    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) 
  50. --    { 
  51. --       GtkRecentInfo *info; 
  52. --       info = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (dialog)); 
  53. --       open_file (gtk_recent_info_get_uri (info)); 
  54. --       gtk_recent_info_unref (info); 
  55. --    } 
  56. --    gtk_widget_destroy (dialog); 
  57. -- 
  58. --  Recently used files are supported since GTK+ 2.10. 
  59. -- 
  60. --  </description> 
  61. pragma Ada_2005; 
  62.  
  63. pragma Warnings (Off, "*is already use-visible*"); 
  64. with Glib;               use Glib; 
  65. with Glib.Types;         use Glib.Types; 
  66. with Gtk.Buildable;      use Gtk.Buildable; 
  67. with Gtk.Dialog;         use Gtk.Dialog; 
  68. with Gtk.Recent_Chooser; use Gtk.Recent_Chooser; 
  69. with Gtk.Recent_Filter;  use Gtk.Recent_Filter; 
  70. with Gtk.Recent_Info;    use Gtk.Recent_Info; 
  71. with Gtk.Recent_Manager; use Gtk.Recent_Manager; 
  72. with Gtk.Window;         use Gtk.Window; 
  73.  
  74. package Gtk.Recent_Chooser_Dialog is 
  75.  
  76.    type Gtk_Recent_Chooser_Dialog_Record is new Gtk_Dialog_Record with null record; 
  77.    type Gtk_Recent_Chooser_Dialog is access all Gtk_Recent_Chooser_Dialog_Record'Class; 
  78.  
  79.    --------------- 
  80.    -- Callbacks -- 
  81.    --------------- 
  82.  
  83.    type Gtk_Recent_Sort_Func is access function 
  84.      (A : Gtk.Recent_Info.Gtk_Recent_Info; 
  85.       B : Gtk.Recent_Info.Gtk_Recent_Info) return Gint; 
  86.  
  87.    ------------------ 
  88.    -- Constructors -- 
  89.    ------------------ 
  90.  
  91.    procedure Gtk_New 
  92.       (Widget : out Gtk_Recent_Chooser_Dialog; 
  93.        Title  : UTF8_String := ""; 
  94.        Parent : access Gtk.Window.Gtk_Window_Record'Class); 
  95.    procedure Initialize 
  96.       (Widget : not null access Gtk_Recent_Chooser_Dialog_Record'Class; 
  97.        Title  : UTF8_String := ""; 
  98.        Parent : access Gtk.Window.Gtk_Window_Record'Class); 
  99.  
  100.    function Gtk_Recent_Chooser_Dialog_New 
  101.       (Title  : UTF8_String := ""; 
  102.        Parent : access Gtk.Window.Gtk_Window_Record'Class) 
  103.        return Gtk_Recent_Chooser_Dialog; 
  104.  
  105.    procedure Gtk_New_For_Manager 
  106.       (Widget  : out Gtk_Recent_Chooser_Dialog; 
  107.        Title   : UTF8_String := ""; 
  108.        Parent  : access Gtk.Window.Gtk_Window_Record'Class; 
  109.        Manager : access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class); 
  110.    procedure Initialize_For_Manager 
  111.       (Widget  : not null access Gtk_Recent_Chooser_Dialog_Record'Class; 
  112.        Title   : UTF8_String := ""; 
  113.        Parent  : access Gtk.Window.Gtk_Window_Record'Class; 
  114.        Manager : access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class); 
  115.  
  116.    function Gtk_Recent_Chooser_Dialog_New_For_Manager 
  117.       (Title   : UTF8_String := ""; 
  118.        Parent  : access Gtk.Window.Gtk_Window_Record'Class; 
  119.        Manager : access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class) 
  120.        return Gtk_Recent_Chooser_Dialog; 
  121.  
  122.    function Get_Type return Glib.GType; 
  123.    pragma Import (C, Get_Type, "gtk_recent_chooser_dialog_get_type"); 
  124.  
  125.    ------------- 
  126.    -- Methods -- 
  127.    ------------- 
  128.  
  129.    procedure Set_Sort_Func 
  130.       (Chooser      : not null access Gtk_Recent_Chooser_Dialog_Record; 
  131.        Sort_Func    : Gtk_Recent_Sort_Func; 
  132.        Data_Destroy : Glib.G_Destroy_Notify_Address); 
  133.    --  Sets the comparison function used when sorting to be Sort_Func. If the 
  134.    --  Chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then the chooser 
  135.    --  will sort using this function. 
  136.    --  To the comparison function will be passed two 
  137.    --  Gtk.Recent_Info.Gtk_Recent_Info structs and Sort_Data; Sort_Func should 
  138.    --  return a positive integer if the first item comes before the second, 
  139.    --  zero if the two items are equal and a negative integer if the first item 
  140.    --  comes after the second. 
  141.    --  Since: gtk+ 2.10 
  142.    --  "sort_func": the comparison function 
  143.    --  "data_destroy": destroy notifier for Sort_Data, or null 
  144.  
  145.    generic 
  146.       type User_Data_Type (<>) is private; 
  147.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  148.    package Set_Sort_Func_User_Data is 
  149.  
  150.       type Gtk_Recent_Sort_Func is access function 
  151.         (A         : Gtk.Recent_Info.Gtk_Recent_Info; 
  152.          B         : Gtk.Recent_Info.Gtk_Recent_Info; 
  153.          User_Data : User_Data_Type) return Gint; 
  154.  
  155.       procedure Set_Sort_Func 
  156.          (Chooser      : not null access Gtk.Recent_Chooser_Dialog.Gtk_Recent_Chooser_Dialog_Record'Class; 
  157.           Sort_Func    : Gtk_Recent_Sort_Func; 
  158.           Sort_Data    : User_Data_Type; 
  159.           Data_Destroy : Glib.G_Destroy_Notify_Address); 
  160.       --  Sets the comparison function used when sorting to be Sort_Func. If 
  161.       --  the Chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then the 
  162.       --  chooser will sort using this function. 
  163.       --  To the comparison function will be passed two 
  164.       --  Gtk.Recent_Info.Gtk_Recent_Info structs and Sort_Data; Sort_Func 
  165.       --  should return a positive integer if the first item comes before the 
  166.       --  second, zero if the two items are equal and a negative integer if the 
  167.       --  first item comes after the second. 
  168.       --  Since: gtk+ 2.10 
  169.       --  "sort_func": the comparison function 
  170.       --  "sort_data": user data to pass to Sort_Func, or null 
  171.       --  "data_destroy": destroy notifier for Sort_Data, or null 
  172.  
  173.    end Set_Sort_Func_User_Data; 
  174.  
  175.    --------------------------------------------- 
  176.    -- Inherited subprograms (from interfaces) -- 
  177.    --------------------------------------------- 
  178.    --  Methods inherited from the Buildable interface are not duplicated here 
  179.    --  since they are meant to be used by tools, mostly. If you need to call 
  180.    --  them, use an explicit cast through the "-" operator below. 
  181.  
  182.    procedure Add_Filter 
  183.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  184.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  185.  
  186.    function Get_Current_Item 
  187.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  188.        return Gtk.Recent_Info.Gtk_Recent_Info; 
  189.  
  190.    function Get_Current_Uri 
  191.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  192.        return UTF8_String; 
  193.  
  194.    function Set_Current_Uri 
  195.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  196.        URI     : UTF8_String) return Boolean; 
  197.  
  198.    function Get_Filter 
  199.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  200.        return Gtk.Recent_Filter.Gtk_Recent_Filter; 
  201.  
  202.    procedure Set_Filter 
  203.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  204.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  205.  
  206.    function Get_Items 
  207.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  208.        return Gtk.Recent_Manager.Gtk_Recent_Info_List.Glist; 
  209.  
  210.    function Get_Limit 
  211.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  212.        return Gint; 
  213.  
  214.    procedure Set_Limit 
  215.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  216.        Limit   : Gint); 
  217.  
  218.    function Get_Local_Only 
  219.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  220.        return Boolean; 
  221.  
  222.    procedure Set_Local_Only 
  223.       (Chooser    : not null access Gtk_Recent_Chooser_Dialog_Record; 
  224.        Local_Only : Boolean); 
  225.  
  226.    function Get_Select_Multiple 
  227.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  228.        return Boolean; 
  229.  
  230.    procedure Set_Select_Multiple 
  231.       (Chooser         : not null access Gtk_Recent_Chooser_Dialog_Record; 
  232.        Select_Multiple : Boolean); 
  233.  
  234.    function Get_Show_Icons 
  235.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  236.        return Boolean; 
  237.  
  238.    procedure Set_Show_Icons 
  239.       (Chooser    : not null access Gtk_Recent_Chooser_Dialog_Record; 
  240.        Show_Icons : Boolean); 
  241.  
  242.    function Get_Show_Not_Found 
  243.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  244.        return Boolean; 
  245.  
  246.    procedure Set_Show_Not_Found 
  247.       (Chooser        : not null access Gtk_Recent_Chooser_Dialog_Record; 
  248.        Show_Not_Found : Boolean); 
  249.  
  250.    function Get_Show_Private 
  251.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  252.        return Boolean; 
  253.  
  254.    procedure Set_Show_Private 
  255.       (Chooser      : not null access Gtk_Recent_Chooser_Dialog_Record; 
  256.        Show_Private : Boolean); 
  257.  
  258.    function Get_Show_Tips 
  259.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  260.        return Boolean; 
  261.  
  262.    procedure Set_Show_Tips 
  263.       (Chooser   : not null access Gtk_Recent_Chooser_Dialog_Record; 
  264.        Show_Tips : Boolean); 
  265.  
  266.    function Get_Sort_Type 
  267.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  268.        return Gtk.Recent_Chooser.Gtk_Recent_Sort_Type; 
  269.  
  270.    procedure Set_Sort_Type 
  271.       (Chooser   : not null access Gtk_Recent_Chooser_Dialog_Record; 
  272.        Sort_Type : Gtk.Recent_Chooser.Gtk_Recent_Sort_Type); 
  273.  
  274.    function List_Filters 
  275.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record) 
  276.        return Gtk.Recent_Filter.Gtk_Recent_Filter_List.GSlist; 
  277.  
  278.    procedure Remove_Filter 
  279.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  280.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  281.  
  282.    procedure Select_All 
  283.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record); 
  284.  
  285.    function Select_Uri 
  286.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  287.        URI     : UTF8_String) return Boolean; 
  288.  
  289.    procedure Unselect_All 
  290.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record); 
  291.  
  292.    procedure Unselect_Uri 
  293.       (Chooser : not null access Gtk_Recent_Chooser_Dialog_Record; 
  294.        URI     : UTF8_String); 
  295.  
  296.    ---------------- 
  297.    -- Interfaces -- 
  298.    ---------------- 
  299.    --  This class implements several interfaces. See Glib.Types 
  300.    -- 
  301.    --  - "Buildable" 
  302.    -- 
  303.    --  - "RecentChooser" 
  304.  
  305.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  306.      (Gtk.Buildable.Gtk_Buildable, Gtk_Recent_Chooser_Dialog_Record, Gtk_Recent_Chooser_Dialog); 
  307.    function "+" 
  308.      (Widget : access Gtk_Recent_Chooser_Dialog_Record'Class) 
  309.    return Gtk.Buildable.Gtk_Buildable 
  310.    renames Implements_Gtk_Buildable.To_Interface; 
  311.    function "-" 
  312.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  313.    return Gtk_Recent_Chooser_Dialog 
  314.    renames Implements_Gtk_Buildable.To_Object; 
  315.  
  316.    package Implements_Gtk_Recent_Chooser is new Glib.Types.Implements 
  317.      (Gtk.Recent_Chooser.Gtk_Recent_Chooser, Gtk_Recent_Chooser_Dialog_Record, Gtk_Recent_Chooser_Dialog); 
  318.    function "+" 
  319.      (Widget : access Gtk_Recent_Chooser_Dialog_Record'Class) 
  320.    return Gtk.Recent_Chooser.Gtk_Recent_Chooser 
  321.    renames Implements_Gtk_Recent_Chooser.To_Interface; 
  322.    function "-" 
  323.      (Interf : Gtk.Recent_Chooser.Gtk_Recent_Chooser) 
  324.    return Gtk_Recent_Chooser_Dialog 
  325.    renames Implements_Gtk_Recent_Chooser.To_Object; 
  326.  
  327. end Gtk.Recent_Chooser_Dialog;