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_Menu.Gtk_Recent_Chooser_Menu is a widget suitable for 
  26. --  displaying recently used files inside a menu. It can be used to set a 
  27. --  sub-menu of a Gtk.Menu_Item.Gtk_Menu_Item using Gtk.Menu_Item.Set_Submenu, 
  28. --  or as the menu of a Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. 
  29. -- 
  30. --  Note that Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu does not have 
  31. --  any methods of its own. Instead, you should use the functions that work on 
  32. --  a Gtk.Recent_Chooser.Gtk_Recent_Chooser. 
  33. -- 
  34. --  Note also that Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu does not 
  35. --  support multiple filters, as it has no way to let the user choose between 
  36. --  them as the Gtk.Recent_Chooser_Widget.Gtk_Recent_Chooser_Widget and 
  37. --  Gtk.Recent_Chooser_Dialog.Gtk_Recent_Chooser_Dialog widgets do. Thus using 
  38. --  Gtk.Recent_Chooser.Add_Filter on a 
  39. --  Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu widget will yield the same 
  40. --  effects as using Gtk.Recent_Chooser.Set_Filter, replacing any currently set 
  41. --  filter with the supplied filter; Gtk.Recent_Chooser.Remove_Filter will 
  42. --  remove any currently set Gtk.Recent_Filter.Gtk_Recent_Filter object and 
  43. --  will unset the current filter; Gtk.Recent_Chooser.List_Filters will return 
  44. --  a list containing a single Gtk.Recent_Filter.Gtk_Recent_Filter object. 
  45. -- 
  46. --  Recently used files are supported since GTK+ 2.10. 
  47. -- 
  48. --  </description> 
  49. pragma Ada_2005; 
  50.  
  51. pragma Warnings (Off, "*is already use-visible*"); 
  52. with Glib;               use Glib; 
  53. with Glib.Properties;    use Glib.Properties; 
  54. with Glib.Types;         use Glib.Types; 
  55. with Gtk.Action;         use Gtk.Action; 
  56. with Gtk.Activatable;    use Gtk.Activatable; 
  57. with Gtk.Buildable;      use Gtk.Buildable; 
  58. with Gtk.Menu;           use Gtk.Menu; 
  59. with Gtk.Recent_Chooser; use Gtk.Recent_Chooser; 
  60. with Gtk.Recent_Filter;  use Gtk.Recent_Filter; 
  61. with Gtk.Recent_Info;    use Gtk.Recent_Info; 
  62. with Gtk.Recent_Manager; use Gtk.Recent_Manager; 
  63.  
  64. package Gtk.Recent_Chooser_Menu is 
  65.  
  66.    type Gtk_Recent_Chooser_Menu_Record is new Gtk_Menu_Record with null record; 
  67.    type Gtk_Recent_Chooser_Menu is access all Gtk_Recent_Chooser_Menu_Record'Class; 
  68.  
  69.    --------------- 
  70.    -- Callbacks -- 
  71.    --------------- 
  72.  
  73.    type Gtk_Recent_Sort_Func is access function 
  74.      (A : Gtk.Recent_Info.Gtk_Recent_Info; 
  75.       B : Gtk.Recent_Info.Gtk_Recent_Info) return Gint; 
  76.  
  77.    ------------------ 
  78.    -- Constructors -- 
  79.    ------------------ 
  80.  
  81.    procedure Gtk_New (Self : out Gtk_Recent_Chooser_Menu); 
  82.    procedure Initialize 
  83.       (Self : not null access Gtk_Recent_Chooser_Menu_Record'Class); 
  84.    --  Creates a new Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu widget. 
  85.    --  This kind of widget shows the list of recently used resources as a 
  86.    --  menu, each item as a menu item. Each item inside the menu might have an 
  87.    --  icon, representing its MIME type, and a number, for mnemonic access. 
  88.    --  This widget implements the Gtk.Recent_Chooser.Gtk_Recent_Chooser 
  89.    --  interface. 
  90.    --  This widget creates its own Gtk.Recent_Manager.Gtk_Recent_Manager 
  91.    --  object. See the Gtk.Recent_Chooser_Menu.Gtk_New_For_Manager function to 
  92.    --  know how to create a Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu 
  93.    --  widget bound to another Gtk.Recent_Manager.Gtk_Recent_Manager object. 
  94.    --  Since: gtk+ 2.10 
  95.  
  96.    function Gtk_Recent_Chooser_Menu_New return Gtk_Recent_Chooser_Menu; 
  97.    --  Creates a new Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu widget. 
  98.    --  This kind of widget shows the list of recently used resources as a 
  99.    --  menu, each item as a menu item. Each item inside the menu might have an 
  100.    --  icon, representing its MIME type, and a number, for mnemonic access. 
  101.    --  This widget implements the Gtk.Recent_Chooser.Gtk_Recent_Chooser 
  102.    --  interface. 
  103.    --  This widget creates its own Gtk.Recent_Manager.Gtk_Recent_Manager 
  104.    --  object. See the Gtk.Recent_Chooser_Menu.Gtk_New_For_Manager function to 
  105.    --  know how to create a Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu 
  106.    --  widget bound to another Gtk.Recent_Manager.Gtk_Recent_Manager object. 
  107.    --  Since: gtk+ 2.10 
  108.  
  109.    procedure Gtk_New_For_Manager 
  110.       (Self    : out Gtk_Recent_Chooser_Menu; 
  111.        Manager : not null access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class); 
  112.    procedure Initialize_For_Manager 
  113.       (Self    : not null access Gtk_Recent_Chooser_Menu_Record'Class; 
  114.        Manager : not null access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class); 
  115.    --  Creates a new Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu widget 
  116.    --  using Manager as the underlying recently used resources manager. 
  117.    --  This is useful if you have implemented your own recent manager, or if 
  118.    --  you have a customized instance of a 
  119.    --  Gtk.Recent_Manager.Gtk_Recent_Manager object or if you wish to share a 
  120.    --  common Gtk.Recent_Manager.Gtk_Recent_Manager object among multiple 
  121.    --  Gtk.Recent_Chooser.Gtk_Recent_Chooser widgets. 
  122.    --  Since: gtk+ 2.10 
  123.    --  "manager": a Gtk.Recent_Manager.Gtk_Recent_Manager 
  124.  
  125.    function Gtk_Recent_Chooser_Menu_New_For_Manager 
  126.       (Manager : not null access Gtk.Recent_Manager.Gtk_Recent_Manager_Record'Class) 
  127.        return Gtk_Recent_Chooser_Menu; 
  128.    --  Creates a new Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu widget 
  129.    --  using Manager as the underlying recently used resources manager. 
  130.    --  This is useful if you have implemented your own recent manager, or if 
  131.    --  you have a customized instance of a 
  132.    --  Gtk.Recent_Manager.Gtk_Recent_Manager object or if you wish to share a 
  133.    --  common Gtk.Recent_Manager.Gtk_Recent_Manager object among multiple 
  134.    --  Gtk.Recent_Chooser.Gtk_Recent_Chooser widgets. 
  135.    --  Since: gtk+ 2.10 
  136.    --  "manager": a Gtk.Recent_Manager.Gtk_Recent_Manager 
  137.  
  138.    function Get_Type return Glib.GType; 
  139.    pragma Import (C, Get_Type, "gtk_recent_chooser_menu_get_type"); 
  140.  
  141.    ------------- 
  142.    -- Methods -- 
  143.    ------------- 
  144.  
  145.    function Get_Show_Numbers 
  146.       (Self : not null access Gtk_Recent_Chooser_Menu_Record) return Boolean; 
  147.    --  Returns the value set by Gtk.Recent_Chooser_Menu.Set_Show_Numbers. 
  148.    --  Since: gtk+ 2.10 
  149.  
  150.    procedure Set_Show_Numbers 
  151.       (Self         : not null access Gtk_Recent_Chooser_Menu_Record; 
  152.        Show_Numbers : Boolean); 
  153.    --  Sets whether a number should be added to the items of Menu. The numbers 
  154.    --  are shown to provide a unique character for a mnemonic to be used inside 
  155.    --  ten menu item's label. Only the first the items get a number to avoid 
  156.    --  clashes. 
  157.    --  Since: gtk+ 2.10 
  158.    --  "show_numbers": whether to show numbers 
  159.  
  160.    procedure Set_Sort_Func 
  161.       (Chooser      : not null access Gtk_Recent_Chooser_Menu_Record; 
  162.        Sort_Func    : Gtk_Recent_Sort_Func; 
  163.        Data_Destroy : Glib.G_Destroy_Notify_Address); 
  164.    --  Sets the comparison function used when sorting to be Sort_Func. If the 
  165.    --  Chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then the chooser 
  166.    --  will sort using this function. 
  167.    --  To the comparison function will be passed two 
  168.    --  Gtk.Recent_Info.Gtk_Recent_Info structs and Sort_Data; Sort_Func should 
  169.    --  return a positive integer if the first item comes before the second, 
  170.    --  zero if the two items are equal and a negative integer if the first item 
  171.    --  comes after the second. 
  172.    --  Since: gtk+ 2.10 
  173.    --  "sort_func": the comparison function 
  174.    --  "data_destroy": destroy notifier for Sort_Data, or null 
  175.  
  176.    generic 
  177.       type User_Data_Type (<>) is private; 
  178.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  179.    package Set_Sort_Func_User_Data is 
  180.  
  181.       type Gtk_Recent_Sort_Func is access function 
  182.         (A         : Gtk.Recent_Info.Gtk_Recent_Info; 
  183.          B         : Gtk.Recent_Info.Gtk_Recent_Info; 
  184.          User_Data : User_Data_Type) return Gint; 
  185.  
  186.       procedure Set_Sort_Func 
  187.          (Chooser      : not null access Gtk.Recent_Chooser_Menu.Gtk_Recent_Chooser_Menu_Record'Class; 
  188.           Sort_Func    : Gtk_Recent_Sort_Func; 
  189.           Sort_Data    : User_Data_Type; 
  190.           Data_Destroy : Glib.G_Destroy_Notify_Address); 
  191.       --  Sets the comparison function used when sorting to be Sort_Func. If 
  192.       --  the Chooser has the sort type set to GTK_RECENT_SORT_CUSTOM then the 
  193.       --  chooser will sort using this function. 
  194.       --  To the comparison function will be passed two 
  195.       --  Gtk.Recent_Info.Gtk_Recent_Info structs and Sort_Data; Sort_Func 
  196.       --  should return a positive integer if the first item comes before the 
  197.       --  second, zero if the two items are equal and a negative integer if the 
  198.       --  first item comes after the second. 
  199.       --  Since: gtk+ 2.10 
  200.       --  "sort_func": the comparison function 
  201.       --  "sort_data": user data to pass to Sort_Func, or null 
  202.       --  "data_destroy": destroy notifier for Sort_Data, or null 
  203.  
  204.    end Set_Sort_Func_User_Data; 
  205.  
  206.    --------------------------------------------- 
  207.    -- Inherited subprograms (from interfaces) -- 
  208.    --------------------------------------------- 
  209.    --  Methods inherited from the Buildable interface are not duplicated here 
  210.    --  since they are meant to be used by tools, mostly. If you need to call 
  211.    --  them, use an explicit cast through the "-" operator below. 
  212.  
  213.    procedure Do_Set_Related_Action 
  214.       (Self   : not null access Gtk_Recent_Chooser_Menu_Record; 
  215.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  216.  
  217.    function Get_Related_Action 
  218.       (Self : not null access Gtk_Recent_Chooser_Menu_Record) 
  219.        return Gtk.Action.Gtk_Action; 
  220.  
  221.    procedure Set_Related_Action 
  222.       (Self   : not null access Gtk_Recent_Chooser_Menu_Record; 
  223.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  224.  
  225.    function Get_Use_Action_Appearance 
  226.       (Self : not null access Gtk_Recent_Chooser_Menu_Record) return Boolean; 
  227.  
  228.    procedure Set_Use_Action_Appearance 
  229.       (Self           : not null access Gtk_Recent_Chooser_Menu_Record; 
  230.        Use_Appearance : Boolean); 
  231.  
  232.    procedure Sync_Action_Properties 
  233.       (Self   : not null access Gtk_Recent_Chooser_Menu_Record; 
  234.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  235.  
  236.    procedure Add_Filter 
  237.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  238.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  239.  
  240.    function Get_Current_Item 
  241.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  242.        return Gtk.Recent_Info.Gtk_Recent_Info; 
  243.  
  244.    function Get_Current_Uri 
  245.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  246.        return UTF8_String; 
  247.  
  248.    function Set_Current_Uri 
  249.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  250.        URI     : UTF8_String) return Boolean; 
  251.  
  252.    function Get_Filter 
  253.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  254.        return Gtk.Recent_Filter.Gtk_Recent_Filter; 
  255.  
  256.    procedure Set_Filter 
  257.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  258.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  259.  
  260.    function Get_Items 
  261.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  262.        return Gtk.Recent_Manager.Gtk_Recent_Info_List.Glist; 
  263.  
  264.    function Get_Limit 
  265.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) return Gint; 
  266.  
  267.    procedure Set_Limit 
  268.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  269.        Limit   : Gint); 
  270.  
  271.    function Get_Local_Only 
  272.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  273.        return Boolean; 
  274.  
  275.    procedure Set_Local_Only 
  276.       (Chooser    : not null access Gtk_Recent_Chooser_Menu_Record; 
  277.        Local_Only : Boolean); 
  278.  
  279.    function Get_Select_Multiple 
  280.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  281.        return Boolean; 
  282.  
  283.    procedure Set_Select_Multiple 
  284.       (Chooser         : not null access Gtk_Recent_Chooser_Menu_Record; 
  285.        Select_Multiple : Boolean); 
  286.  
  287.    function Get_Show_Icons 
  288.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  289.        return Boolean; 
  290.  
  291.    procedure Set_Show_Icons 
  292.       (Chooser    : not null access Gtk_Recent_Chooser_Menu_Record; 
  293.        Show_Icons : Boolean); 
  294.  
  295.    function Get_Show_Not_Found 
  296.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  297.        return Boolean; 
  298.  
  299.    procedure Set_Show_Not_Found 
  300.       (Chooser        : not null access Gtk_Recent_Chooser_Menu_Record; 
  301.        Show_Not_Found : Boolean); 
  302.  
  303.    function Get_Show_Private 
  304.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  305.        return Boolean; 
  306.  
  307.    procedure Set_Show_Private 
  308.       (Chooser      : not null access Gtk_Recent_Chooser_Menu_Record; 
  309.        Show_Private : Boolean); 
  310.  
  311.    function Get_Show_Tips 
  312.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  313.        return Boolean; 
  314.  
  315.    procedure Set_Show_Tips 
  316.       (Chooser   : not null access Gtk_Recent_Chooser_Menu_Record; 
  317.        Show_Tips : Boolean); 
  318.  
  319.    function Get_Sort_Type 
  320.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  321.        return Gtk.Recent_Chooser.Gtk_Recent_Sort_Type; 
  322.  
  323.    procedure Set_Sort_Type 
  324.       (Chooser   : not null access Gtk_Recent_Chooser_Menu_Record; 
  325.        Sort_Type : Gtk.Recent_Chooser.Gtk_Recent_Sort_Type); 
  326.  
  327.    function List_Filters 
  328.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record) 
  329.        return Gtk.Recent_Filter.Gtk_Recent_Filter_List.GSlist; 
  330.  
  331.    procedure Remove_Filter 
  332.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  333.        Filter  : not null access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  334.  
  335.    procedure Select_All 
  336.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record); 
  337.  
  338.    function Select_Uri 
  339.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  340.        URI     : UTF8_String) return Boolean; 
  341.  
  342.    procedure Unselect_All 
  343.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record); 
  344.  
  345.    procedure Unselect_Uri 
  346.       (Chooser : not null access Gtk_Recent_Chooser_Menu_Record; 
  347.        URI     : UTF8_String); 
  348.  
  349.    ---------------- 
  350.    -- Properties -- 
  351.    ---------------- 
  352.    --  The following properties are defined for this widget. See 
  353.    --  Glib.Properties for more information on properties) 
  354.  
  355.    Show_Numbers_Property : constant Glib.Properties.Property_Boolean; 
  356.    --  Whether the first ten items in the menu should be prepended by a number 
  357.    --  acting as a unique mnemonic. 
  358.  
  359.    ---------------- 
  360.    -- Interfaces -- 
  361.    ---------------- 
  362.    --  This class implements several interfaces. See Glib.Types 
  363.    -- 
  364.    --  - "Activatable" 
  365.    -- 
  366.    --  - "Buildable" 
  367.    -- 
  368.    --  - "RecentChooser" 
  369.  
  370.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  371.      (Gtk.Activatable.Gtk_Activatable, Gtk_Recent_Chooser_Menu_Record, Gtk_Recent_Chooser_Menu); 
  372.    function "+" 
  373.      (Widget : access Gtk_Recent_Chooser_Menu_Record'Class) 
  374.    return Gtk.Activatable.Gtk_Activatable 
  375.    renames Implements_Gtk_Activatable.To_Interface; 
  376.    function "-" 
  377.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  378.    return Gtk_Recent_Chooser_Menu 
  379.    renames Implements_Gtk_Activatable.To_Object; 
  380.  
  381.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  382.      (Gtk.Buildable.Gtk_Buildable, Gtk_Recent_Chooser_Menu_Record, Gtk_Recent_Chooser_Menu); 
  383.    function "+" 
  384.      (Widget : access Gtk_Recent_Chooser_Menu_Record'Class) 
  385.    return Gtk.Buildable.Gtk_Buildable 
  386.    renames Implements_Gtk_Buildable.To_Interface; 
  387.    function "-" 
  388.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  389.    return Gtk_Recent_Chooser_Menu 
  390.    renames Implements_Gtk_Buildable.To_Object; 
  391.  
  392.    package Implements_Gtk_Recent_Chooser is new Glib.Types.Implements 
  393.      (Gtk.Recent_Chooser.Gtk_Recent_Chooser, Gtk_Recent_Chooser_Menu_Record, Gtk_Recent_Chooser_Menu); 
  394.    function "+" 
  395.      (Widget : access Gtk_Recent_Chooser_Menu_Record'Class) 
  396.    return Gtk.Recent_Chooser.Gtk_Recent_Chooser 
  397.    renames Implements_Gtk_Recent_Chooser.To_Interface; 
  398.    function "-" 
  399.      (Interf : Gtk.Recent_Chooser.Gtk_Recent_Chooser) 
  400.    return Gtk_Recent_Chooser_Menu 
  401.    renames Implements_Gtk_Recent_Chooser.To_Object; 
  402.  
  403. private 
  404.    Show_Numbers_Property : constant Glib.Properties.Property_Boolean := 
  405.      Glib.Properties.Build ("show-numbers"); 
  406. end Gtk.Recent_Chooser_Menu;