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. --  A Gtk.Recent_Action.Gtk_Recent_Action represents a list of recently used 
  26. --  files, which can be shown by widgets such as 
  27. --  Gtk.Recent_Chooser_Dialog.Gtk_Recent_Chooser_Dialog or 
  28. --  Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu. 
  29. -- 
  30. --  To construct a submenu showing recently used files, use a 
  31. --  Gtk.Recent_Action.Gtk_Recent_Action as the action for a <menuitem>. To 
  32. --  construct a menu toolbutton showing the recently used files in the popup 
  33. --  menu, use a Gtk.Recent_Action.Gtk_Recent_Action as the action for a 
  34. --  <toolitem> element. 
  35. -- 
  36. --  </description> 
  37. pragma Ada_2005; 
  38.  
  39. pragma Warnings (Off, "*is already use-visible*"); 
  40. with Glib;               use Glib; 
  41. with Glib.Properties;    use Glib.Properties; 
  42. with Glib.Types;         use Glib.Types; 
  43. with Gtk.Action;         use Gtk.Action; 
  44. with Gtk.Buildable;      use Gtk.Buildable; 
  45. with Gtk.Recent_Chooser; use Gtk.Recent_Chooser; 
  46. with Gtk.Recent_Filter;  use Gtk.Recent_Filter; 
  47. with Gtk.Recent_Info;    use Gtk.Recent_Info; 
  48. with Gtk.Recent_Manager; use Gtk.Recent_Manager; 
  49.  
  50. package Gtk.Recent_Action is 
  51.  
  52.    type Gtk_Recent_Action_Record is new Gtk_Action_Record with null record; 
  53.    type Gtk_Recent_Action is access all Gtk_Recent_Action_Record'Class; 
  54.  
  55.    --------------- 
  56.    -- Callbacks -- 
  57.    --------------- 
  58.  
  59.    type Gtk_Recent_Sort_Func is access function 
  60.      (A : Gtk.Recent_Info.Gtk_Recent_Info; 
  61.       B : Gtk.Recent_Info.Gtk_Recent_Info) return Gint; 
  62.  
  63.    ------------------ 
  64.    -- Constructors -- 
  65.    ------------------ 
  66.  
  67.    procedure Gtk_New 
  68.       (Widget   : out Gtk_Recent_Action; 
  69.        Name     : UTF8_String; 
  70.        Label    : UTF8_String := ""; 
  71.        Tooltip  : UTF8_String := ""; 
  72.        Stock_Id : UTF8_String := ""); 
  73.    procedure Initialize 
  74.       (Widget   : not null access Gtk_Recent_Action_Record'Class; 
  75.        Name     : UTF8_String; 
  76.        Label    : UTF8_String := ""; 
  77.        Tooltip  : UTF8_String := ""; 
  78.        Stock_Id : UTF8_String := ""); 
  79.    --  Creates a new Gtk.Recent_Action.Gtk_Recent_Action object. To add the 
  80.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  81.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  82.    --  Since: gtk+ 2.12 
  83.    --  "name": a unique name for the action 
  84.    --  "label": the label displayed in menu items and on buttons, or null 
  85.    --  "tooltip": a tooltip for the action, or null 
  86.    --  "stock_id": the stock icon to display in widgets representing the 
  87.    --  action, or null 
  88.  
  89.    function Gtk_Recent_Action_New 
  90.       (Name     : UTF8_String; 
  91.        Label    : UTF8_String := ""; 
  92.        Tooltip  : UTF8_String := ""; 
  93.        Stock_Id : UTF8_String := "") return Gtk_Recent_Action; 
  94.    --  Creates a new Gtk.Recent_Action.Gtk_Recent_Action object. To add the 
  95.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  96.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  97.    --  Since: gtk+ 2.12 
  98.    --  "name": a unique name for the action 
  99.    --  "label": the label displayed in menu items and on buttons, or null 
  100.    --  "tooltip": a tooltip for the action, or null 
  101.    --  "stock_id": the stock icon to display in widgets representing the 
  102.    --  action, or null 
  103.  
  104.    procedure Gtk_New_For_Manager 
  105.       (Widget   : out Gtk_Recent_Action; 
  106.        Name     : UTF8_String; 
  107.        Label    : UTF8_String := ""; 
  108.        Tooltip  : UTF8_String := ""; 
  109.        Stock_Id : UTF8_String := ""; 
  110.        Manager  : access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class := Gtk.Recent_Manager.Get_Default); 
  111.    procedure Initialize_For_Manager 
  112.       (Widget   : not null access Gtk_Recent_Action_Record'Class; 
  113.        Name     : UTF8_String; 
  114.        Label    : UTF8_String := ""; 
  115.        Tooltip  : UTF8_String := ""; 
  116.        Stock_Id : UTF8_String := ""; 
  117.        Manager  : access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class := Gtk.Recent_Manager.Get_Default); 
  118.    --  Creates a new Gtk.Recent_Action.Gtk_Recent_Action object. To add the 
  119.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  120.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  121.    --  Since: gtk+ 2.12 
  122.    --  "name": a unique name for the action 
  123.    --  "label": the label displayed in menu items and on buttons, or null 
  124.    --  "tooltip": a tooltip for the action, or null 
  125.    --  "stock_id": the stock icon to display in widgets representing the 
  126.    --  action, or null 
  127.    --  "manager": a Gtk.Recent_Manager.Gtk_Recent_Manager, or null for using 
  128.    --  the default Gtk.Recent_Manager.Gtk_Recent_Manager 
  129.  
  130.    function Gtk_Recent_Action_New_For_Manager 
  131.       (Name     : UTF8_String; 
  132.        Label    : UTF8_String := ""; 
  133.        Tooltip  : UTF8_String := ""; 
  134.        Stock_Id : UTF8_String := ""; 
  135.        Manager  : access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class := Gtk.Recent_Manager.Get_Default) 
  136.        return Gtk_Recent_Action; 
  137.    --  Creates a new Gtk.Recent_Action.Gtk_Recent_Action object. To add the 
  138.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  139.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  140.    --  Since: gtk+ 2.12 
  141.    --  "name": a unique name for the action 
  142.    --  "label": the label displayed in menu items and on buttons, or null 
  143.    --  "tooltip": a tooltip for the action, or null 
  144.    --  "stock_id": the stock icon to display in widgets representing the 
  145.    --  action, or null 
  146.    --  "manager": a Gtk.Recent_Manager.Gtk_Recent_Manager, or null for using 
  147.    --  the default Gtk.Recent_Manager.Gtk_Recent_Manager 
  148.  
  149.    function Get_Type return Glib.GType; 
  150.    pragma Import (C, Get_Type, "gtk_recent_action_get_type"); 
  151.  
  152.    ------------- 
  153.    -- Methods -- 
  154.    ------------- 
  155.  
  156.    function Get_Show_Numbers 
  157.       (Widget : not null access Gtk_Recent_Action_Record) return Boolean; 
  158.    --  Returns the value set by Gtk.Recent_Chooser_Menu.Set_Show_Numbers. 
  159.    --  Since: gtk+ 2.12 
  160.  
  161.    procedure Set_Show_Numbers 
  162.       (Widget       : not null access Gtk_Recent_Action_Record; 
  163.        Show_Numbers : Boolean); 
  164.    --  Sets whether a number should be added to the items shown by the widgets 
  165.    --  representing Action. The numbers are shown to provide a unique character 
  166.    --  for a mnemonic to be used inside the menu item's label. Only the first 
  167.    --  ten items get a number to avoid clashes. 
  168.    --  Since: gtk+ 2.12 
  169.    --  "show_numbers": True if the shown items should be numbered 
  170.  
  171.    procedure Set_Sort_Func 
  172.       (Chooser      : not null access Gtk_Recent_Action_Record; 
  173.        Sort_Func    : Gtk_Recent_Sort_Func; 
  174.        Data_Destroy : Glib.G_Destroy_Notify_Address); 
  175.    --  Sets the comparison function used when sorting to be Sort_Func. If the 
  176.    --  Chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then the chooser 
  177.    --  will sort using this function. 
  178.    --  To the comparison function will be passed two 
  179.    --  Gtk.Recent_Info.Gtk_Recent_Info structs and Sort_Data; Sort_Func should 
  180.    --  return a positive integer if the first item comes before the second, 
  181.    --  zero if the two items are equal and a negative integer if the first item 
  182.    --  comes after the second. 
  183.    --  Since: gtk+ 2.10 
  184.    --  "sort_func": the comparison function 
  185.    --  "data_destroy": destroy notifier for Sort_Data, or null 
  186.  
  187.    generic 
  188.       type User_Data_Type (<>) is private; 
  189.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  190.    package Set_Sort_Func_User_Data is 
  191.  
  192.       type Gtk_Recent_Sort_Func is access function 
  193.         (A         : Gtk.Recent_Info.Gtk_Recent_Info; 
  194.          B         : Gtk.Recent_Info.Gtk_Recent_Info; 
  195.          User_Data : User_Data_Type) return Gint; 
  196.  
  197.       procedure Set_Sort_Func 
  198.          (Chooser      : not null access Gtk.Recent_Action.Gtk_Recent_Action_Record'Class; 
  199.           Sort_Func    : Gtk_Recent_Sort_Func; 
  200.           Sort_Data    : User_Data_Type; 
  201.           Data_Destroy : Glib.G_Destroy_Notify_Address); 
  202.       --  Sets the comparison function used when sorting to be Sort_Func. If 
  203.       --  the Chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then the 
  204.       --  chooser will sort using this function. 
  205.       --  To the comparison function will be passed two 
  206.       --  Gtk.Recent_Info.Gtk_Recent_Info structs and Sort_Data; Sort_Func 
  207.       --  should return a positive integer if the first item comes before the 
  208.       --  second, zero if the two items are equal and a negative integer if the 
  209.       --  first item comes after the second. 
  210.       --  Since: gtk+ 2.10 
  211.       --  "sort_func": the comparison function 
  212.       --  "sort_data": user data to pass to Sort_Func, or null 
  213.       --  "data_destroy": destroy notifier for Sort_Data, or null 
  214.  
  215.    end Set_Sort_Func_User_Data; 
  216.  
  217.    --------------------------------------------- 
  218.    -- Inherited subprograms (from interfaces) -- 
  219.    --------------------------------------------- 
  220.    --  Methods inherited from the Buildable interface are not duplicated here 
  221.    --  since they are meant to be used by tools, mostly. If you need to call 
  222.    --  them, use an explicit cast through the "-" operator below. 
  223.  
  224.    procedure Add_Filter 
  225.       (Chooser : not null access Gtk_Recent_Action_Record; 
  226.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  227.  
  228.    function Get_Current_Item 
  229.       (Chooser : not null access Gtk_Recent_Action_Record) 
  230.        return Gtk.Recent_Info.Gtk_Recent_Info; 
  231.  
  232.    function Get_Current_Uri 
  233.       (Chooser : not null access Gtk_Recent_Action_Record) 
  234.        return UTF8_String; 
  235.  
  236.    function Set_Current_Uri 
  237.       (Chooser : not null access Gtk_Recent_Action_Record; 
  238.        URI     : UTF8_String) return Boolean; 
  239.  
  240.    function Get_Filter 
  241.       (Chooser : not null access Gtk_Recent_Action_Record) 
  242.        return Gtk.Recent_Filter.Gtk_Recent_Filter; 
  243.  
  244.    procedure Set_Filter 
  245.       (Chooser : not null access Gtk_Recent_Action_Record; 
  246.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  247.  
  248.    function Get_Items 
  249.       (Chooser : not null access Gtk_Recent_Action_Record) 
  250.        return Gtk.Recent_Manager.Gtk_Recent_Info_List.Glist; 
  251.  
  252.    function Get_Limit 
  253.       (Chooser : not null access Gtk_Recent_Action_Record) return Gint; 
  254.  
  255.    procedure Set_Limit 
  256.       (Chooser : not null access Gtk_Recent_Action_Record; 
  257.        Limit   : Gint); 
  258.  
  259.    function Get_Local_Only 
  260.       (Chooser : not null access Gtk_Recent_Action_Record) return Boolean; 
  261.  
  262.    procedure Set_Local_Only 
  263.       (Chooser    : not null access Gtk_Recent_Action_Record; 
  264.        Local_Only : Boolean); 
  265.  
  266.    function Get_Select_Multiple 
  267.       (Chooser : not null access Gtk_Recent_Action_Record) return Boolean; 
  268.  
  269.    procedure Set_Select_Multiple 
  270.       (Chooser         : not null access Gtk_Recent_Action_Record; 
  271.        Select_Multiple : Boolean); 
  272.  
  273.    function Get_Show_Icons 
  274.       (Chooser : not null access Gtk_Recent_Action_Record) return Boolean; 
  275.  
  276.    procedure Set_Show_Icons 
  277.       (Chooser    : not null access Gtk_Recent_Action_Record; 
  278.        Show_Icons : Boolean); 
  279.  
  280.    function Get_Show_Not_Found 
  281.       (Chooser : not null access Gtk_Recent_Action_Record) return Boolean; 
  282.  
  283.    procedure Set_Show_Not_Found 
  284.       (Chooser        : not null access Gtk_Recent_Action_Record; 
  285.        Show_Not_Found : Boolean); 
  286.  
  287.    function Get_Show_Private 
  288.       (Chooser : not null access Gtk_Recent_Action_Record) return Boolean; 
  289.  
  290.    procedure Set_Show_Private 
  291.       (Chooser      : not null access Gtk_Recent_Action_Record; 
  292.        Show_Private : Boolean); 
  293.  
  294.    function Get_Show_Tips 
  295.       (Chooser : not null access Gtk_Recent_Action_Record) return Boolean; 
  296.  
  297.    procedure Set_Show_Tips 
  298.       (Chooser   : not null access Gtk_Recent_Action_Record; 
  299.        Show_Tips : Boolean); 
  300.  
  301.    function Get_Sort_Type 
  302.       (Chooser : not null access Gtk_Recent_Action_Record) 
  303.        return Gtk.Recent_Chooser.Gtk_Recent_Sort_Type; 
  304.  
  305.    procedure Set_Sort_Type 
  306.       (Chooser   : not null access Gtk_Recent_Action_Record; 
  307.        Sort_Type : Gtk.Recent_Chooser.Gtk_Recent_Sort_Type); 
  308.  
  309.    function List_Filters 
  310.       (Chooser : not null access Gtk_Recent_Action_Record) 
  311.        return Gtk.Recent_Filter.Gtk_Recent_Filter_List.GSlist; 
  312.  
  313.    procedure Remove_Filter 
  314.       (Chooser : not null access Gtk_Recent_Action_Record; 
  315.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  316.  
  317.    procedure Select_All (Chooser : not null access Gtk_Recent_Action_Record); 
  318.  
  319.    function Select_Uri 
  320.       (Chooser : not null access Gtk_Recent_Action_Record; 
  321.        URI     : UTF8_String) return Boolean; 
  322.  
  323.    procedure Unselect_All 
  324.       (Chooser : not null access Gtk_Recent_Action_Record); 
  325.  
  326.    procedure Unselect_Uri 
  327.       (Chooser : not null access Gtk_Recent_Action_Record; 
  328.        URI     : UTF8_String); 
  329.  
  330.    ---------------- 
  331.    -- Properties -- 
  332.    ---------------- 
  333.    --  The following properties are defined for this widget. See 
  334.    --  Glib.Properties for more information on properties) 
  335.  
  336.    Show_Numbers_Property : constant Glib.Properties.Property_Boolean; 
  337.  
  338.    ---------------- 
  339.    -- Interfaces -- 
  340.    ---------------- 
  341.    --  This class implements several interfaces. See Glib.Types 
  342.    -- 
  343.    --  - "Buildable" 
  344.    -- 
  345.    --  - "RecentChooser" 
  346.  
  347.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  348.      (Gtk.Buildable.Gtk_Buildable, Gtk_Recent_Action_Record, Gtk_Recent_Action); 
  349.    function "+" 
  350.      (Widget : access Gtk_Recent_Action_Record'Class) 
  351.    return Gtk.Buildable.Gtk_Buildable 
  352.    renames Implements_Gtk_Buildable.To_Interface; 
  353.    function "-" 
  354.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  355.    return Gtk_Recent_Action 
  356.    renames Implements_Gtk_Buildable.To_Object; 
  357.  
  358.    package Implements_Gtk_Recent_Chooser is new Glib.Types.Implements 
  359.      (Gtk.Recent_Chooser.Gtk_Recent_Chooser, Gtk_Recent_Action_Record, Gtk_Recent_Action); 
  360.    function "+" 
  361.      (Widget : access Gtk_Recent_Action_Record'Class) 
  362.    return Gtk.Recent_Chooser.Gtk_Recent_Chooser 
  363.    renames Implements_Gtk_Recent_Chooser.To_Interface; 
  364.    function "-" 
  365.      (Interf : Gtk.Recent_Chooser.Gtk_Recent_Chooser) 
  366.    return Gtk_Recent_Action 
  367.    renames Implements_Gtk_Recent_Chooser.To_Object; 
  368.  
  369. private 
  370.    Show_Numbers_Property : constant Glib.Properties.Property_Boolean := 
  371.      Glib.Properties.Build ("show-numbers"); 
  372. end Gtk.Recent_Action;