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. --  Gtk_Recent_Chooser is an interface that can be implemented by widgets 
  31. --  displaying the list of recently used files. In GTK+, the main objects that 
  32. --  implement this interface are Gtk_Recent_Chooser_Widget, 
  33. --  Gtk_Recent_Chooser_Dialog and Gtk_Recent_Chooser_Menu. 
  34. --  </description> 
  35. --  <c_version>2.16.6</c_version> 
  36.  
  37. with GNAT.Strings; 
  38.  
  39. with Glib.Error; 
  40. with Glib.Properties; 
  41. with Glib.Types; 
  42. with Gtk.Recent_Filter; 
  43. with Gtk.Recent_Manager; 
  44.  
  45. package Gtk.Recent_Chooser is 
  46.  
  47.    type Gtk_Recent_Chooser is new Glib.Types.GType_Interface; 
  48.  
  49.    function Error_Quark return GQuark; 
  50.  
  51.    function Get_Type return GType; 
  52.  
  53.    -------------------- 
  54.    -- Items and URIs -- 
  55.    -------------------- 
  56.  
  57.    function Get_Current_Item 
  58.      (Chooser : Gtk_Recent_Chooser) return Gtk.Recent_Manager.Gtk_Recent_Info; 
  59.    --  Gets the Gtk_Recent_Info currently selected by Chooser. 
  60.    --  Use Gtk.Recent_Manager.Unref when you have finished using it. 
  61.  
  62.    function Get_Current_Uri (Chooser : Gtk_Recent_Chooser) return String; 
  63.    function Set_Current_Uri 
  64.      (Chooser : Gtk_Recent_Chooser; 
  65.       Uri     : String; 
  66.       Error   : Glib.Error.GError := null) 
  67.       return Boolean; 
  68.    --  Gets/Sets Uri as the current URI for Chooser.  Set_Current_Uri returns 
  69.    --  whether the URI was found. 
  70.  
  71.    function Get_Items 
  72.      (Chooser : Gtk_Recent_Chooser) 
  73.       return Gtk.Recent_Manager.Gtk_Recent_Info_List.Glist; 
  74.    --  Gets the list of recently used resources in form of Gtk_Recent_Info 
  75.    --  objects. 
  76.    -- 
  77.    --  The return value of this function is affected by the "sort-type" and 
  78.    --  "limit" properties of Chooser. 
  79.    -- 
  80.    --  You should Gtk.Recent_Manager.Unref on every item of the list, and then 
  81.    --  free the list itself using Gtk_Recent_Info_List.Free. 
  82.  
  83.    function Get_Uris 
  84.      (Chooser : Gtk_Recent_Chooser) return GNAT.Strings.String_List; 
  85.    --  Gets the URIs of the recently used resources. 
  86.    -- 
  87.    --  The return value of this function is affected by the "sort-type" and 
  88.    --  "limit" properties of Chooser. 
  89.  
  90.    function Get_Limit (Chooser : Gtk_Recent_Chooser) return Gint; 
  91.    procedure Set_Limit 
  92.      (Chooser : Gtk_Recent_Chooser; 
  93.       Limit   : Gint); 
  94.    --  Gets/Sets the number of items that should be returned by 
  95.    --  Get_Items and Get_Uris.  Use -1 to specify all items. 
  96.  
  97.    --------------------- 
  98.    -- Display Options -- 
  99.    --------------------- 
  100.  
  101.    function Get_Local_Only (Chooser : Gtk_Recent_Chooser) return Boolean; 
  102.    procedure Set_Local_Only 
  103.      (Chooser    : Gtk_Recent_Chooser; 
  104.       Local_Only : Boolean); 
  105.    --  Whether only local resources, that is resources using the file:// URI 
  106.    --  scheme, should be shown in the recently used resources selector.  If 
  107.    --  Local_Only is True (the default) then the shown resources are guaranteed 
  108.    --  to be accessible through the operating system native file system. 
  109.  
  110.    function Get_Show_Icons (Chooser : Gtk_Recent_Chooser) return Boolean; 
  111.    procedure Set_Show_Icons 
  112.      (Chooser    : Gtk_Recent_Chooser; 
  113.       Show_Icons : Boolean); 
  114.    --  Whether Chooser should show an icon near the resource. 
  115.  
  116.    function Get_Show_Not_Found (Chooser : Gtk_Recent_Chooser) return Boolean; 
  117.    procedure Set_Show_Not_Found 
  118.      (Chooser        : Gtk_Recent_Chooser; 
  119.       Show_Not_Found : Boolean); 
  120.    --  Whether Chooser should display the recently used resources that 
  121.    --  it didn't find.  This only applies to local resources. 
  122.  
  123.    function Get_Show_Private (Chooser : Gtk_Recent_Chooser) return Boolean; 
  124.    procedure Set_Show_Private 
  125.      (Chooser      : Gtk_Recent_Chooser; 
  126.       Show_Private : Boolean); 
  127.    --  Whether to show recently used resources marked registered as private. 
  128.  
  129.    function Get_Show_Tips (Chooser : Gtk_Recent_Chooser) return Boolean; 
  130.    procedure Set_Show_Tips 
  131.      (Chooser   : Gtk_Recent_Chooser; 
  132.       Show_Tips : Boolean); 
  133.    --  Whether to show a tooltip containing the full path of each 
  134.    --  recently used resource in a Gtk_Recent_Chooser widget. 
  135.  
  136.    ------------- 
  137.    -- Filters -- 
  138.    ------------- 
  139.  
  140.    procedure Add_Filter 
  141.      (Chooser : Gtk_Recent_Chooser; 
  142.       Filter  : access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  143.    --  Adds Filter to the list of Gtk_Recent_Filter objects held by Chooser. 
  144.    -- 
  145.    --  If no previous filter objects were defined, this function will call 
  146.    --  Set_Filter. 
  147.  
  148.    procedure Remove_Filter 
  149.      (Chooser : Gtk_Recent_Chooser; 
  150.       Filter  : access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  151.    --  Removes Filter from the list of Gtk_Recent_Filter objects held by 
  152.    --  Chooser. 
  153.  
  154.    function Get_Filter 
  155.      (Chooser : Gtk_Recent_Chooser) 
  156.       return Gtk.Recent_Filter.Gtk_Recent_Filter; 
  157.    procedure Set_Filter 
  158.      (Chooser : Gtk_Recent_Chooser; 
  159.       Filter  : access Gtk.Recent_Filter.Gtk_Recent_Filter_Record'Class); 
  160.    --  Gets/Sets Filter as the current Gtk_Recent_Filter object used by Chooser 
  161.    --  to affect the displayed recently used resources. 
  162.  
  163.    function List_Filters 
  164.      (Chooser : Gtk_Recent_Chooser) 
  165.       return Gtk.Recent_Filter.Gtk_Recent_Filter_List.GSlist; 
  166.    --  Gets the Gtk_Recent_Filter objects held by Chooser. 
  167.    --  You should free the returned list using 
  168.    --  Gtk.Recent_Filter.Gtk_Recent_Filter_List.Free. 
  169.  
  170.    --------------- 
  171.    -- Selection -- 
  172.    --------------- 
  173.  
  174.    function Get_Select_Multiple (Chooser : Gtk_Recent_Chooser) return Boolean; 
  175.    procedure Set_Select_Multiple 
  176.      (Chooser         : Gtk_Recent_Chooser; 
  177.       Select_Multiple : Boolean); 
  178.    --  Whether Chooser can select multiple items. 
  179.  
  180.    procedure Select_All   (Chooser : Gtk_Recent_Chooser); 
  181.    procedure Unselect_All (Chooser : Gtk_Recent_Chooser); 
  182.    --  Selects/Unselects all the items inside Chooser, if the Chooser supports 
  183.    --  multiple selection. 
  184.  
  185.    function Select_Uri 
  186.      (Chooser : Gtk_Recent_Chooser; 
  187.       Uri     : String; 
  188.       Error   : Glib.Error.GError := null) 
  189.       return Boolean; 
  190.    procedure Unselect_Uri 
  191.      (Chooser : Gtk_Recent_Chooser; 
  192.       Uri     : String); 
  193.    --  Selects/Unselects Uri inside Chooser.  Select_Uri returns whether the 
  194.    --  URI was found. 
  195.  
  196.    ------------- 
  197.    -- Sorting -- 
  198.    ------------- 
  199.  
  200.    type Gtk_Recent_Sort_Type is 
  201.      (Gtk_Recent_Sort_None, 
  202.       Gtk_Recent_Sort_Mru, 
  203.       Gtk_Recent_Sort_Lru, 
  204.       Gtk_Recent_Sort_Custom); 
  205.    pragma Convention (C, Gtk_Recent_Sort_Type); 
  206.  
  207.    function Get_Sort_Type 
  208.      (Chooser : Gtk_Recent_Chooser) return Gtk_Recent_Sort_Type; 
  209.    procedure Set_Sort_Type 
  210.      (Chooser   : Gtk_Recent_Chooser; 
  211.       Sort_Type : Gtk_Recent_Sort_Type); 
  212.    --  Changes the sorting order of the recently used resources list displayed 
  213.    --  by Chooser. 
  214.  
  215.    generic 
  216.       type Data_Type is private; 
  217.    package User_Sort_Func is 
  218.       type Data_Type_Access is access Data_Type; 
  219.  
  220.       type Comparison is (Before, Equal, After); 
  221.  
  222.       type Gtk_Recent_Sort_Func is access function 
  223.         (Left, Right : Gtk.Recent_Manager.Gtk_Recent_Info; 
  224.          User_Data   : Data_Type_Access) 
  225.          return Comparison; 
  226.       --  Return whether the Left comes Before, After, or is Equal to, 
  227.       --  the right. 
  228.  
  229.       type Destroy_Notify is access procedure (User_Data : in out Data_Type); 
  230.       --  This procedure will be called just prior to the destruction of 
  231.       --  Sort_Data. 
  232.  
  233.       procedure Set_Sort_Func 
  234.         (Chooser      : Gtk_Recent_Chooser; 
  235.          Sort_Func    : Gtk_Recent_Sort_Func; 
  236.          Sort_Data    : Data_Type_Access := null; 
  237.          Data_Destroy : Destroy_Notify := null); 
  238.       --  Sets the comparison function used when sorting to be Sort_Func.  If 
  239.       --  the Chooser has the sort type set to Gtk_Recent_Sort_Custom then 
  240.       --  the chooser will sort using this function. 
  241.    end User_Sort_Func; 
  242.  
  243.    ----------------- 
  244.    -- Obsolescent -- 
  245.    ----------------- 
  246.  
  247.    function Get_Show_Numbers 
  248.      (Chooser : Gtk_Recent_Chooser) 
  249.       return Boolean; 
  250.    pragma Obsolescent; --  Get_Show_Numbers 
  251.    procedure Set_Show_Numbers 
  252.      (Chooser      : Gtk_Recent_Chooser; 
  253.       Show_Numbers : Boolean); 
  254.    pragma Obsolescent; --  Set_Show_Numbers 
  255.    --  Whether to show recently used resources prepended by a unique number. 
  256.    -- 
  257.    --  Deprecated: 2.12: Use Gtk.Recent_Chooser_Menu.Get_Show_Numbers and 
  258.    --  Gtk.Recent_Chooser_Menu.Set_Show_Numbers instead. 
  259.  
  260.    ---------------- 
  261.    -- Properties -- 
  262.    ---------------- 
  263.  
  264.    --  <properties> 
  265.    --  Name:  Filter_Property 
  266.    --  Type:  Object 
  267.    --  Descr: The current filter for selecting which resources are displayed 
  268.    -- 
  269.    --  Name:  Limit_Property 
  270.    --  Type:  Int 
  271.    --  Descr: The maximum number of items to be displayed 
  272.    -- 
  273.    --  Name:  Local_Only_Property 
  274.    --  Type:  Boolean 
  275.    --  Descr: Whether the selected resource(s) should be limited to local 
  276.    --         file: URIs 
  277.    -- 
  278.    --  Name:  Recent_Manager_Property 
  279.    --  Type:  Object 
  280.    --  Descr: The RecentManager object to use 
  281.    -- 
  282.    --  Name:  Select_Multiple_Property 
  283.    --  Type:  Boolean 
  284.    --  Descr: Whether to allow multiple items to be selected 
  285.    -- 
  286.    --  Name:  Show_Icons_Property 
  287.    --  Type:  Boolean 
  288.    --  Descr: Whether there should be an icon near the item 
  289.    -- 
  290.    --  Name:  Show_Not_Found_Property 
  291.    --  Type:  Boolean 
  292.    --  Descr: Whether the items pointing to unavailable resources should be 
  293.    --         displayed 
  294.    -- 
  295.    --  Name:  Show_Private_Property 
  296.    --  Type:  Boolean 
  297.    --  Descr: Whether the private items should be displayed 
  298.    -- 
  299.    --  Name:  Show_Tips_Property 
  300.    --  Type:  Boolean 
  301.    --  Descr: Whether there should be a tooltip on the item 
  302.    -- 
  303.    --  Name:  Sort_Type_Property 
  304.    --  Type:  Enum 
  305.    --  Descr: The sorting order of the items displayed 
  306.    -- 
  307.    --  </properties> 
  308.  
  309.    Filter_Property          : constant Glib.Properties.Property_Object; 
  310.    Limit_Property           : constant Glib.Properties.Property_Int; 
  311.    Local_Only_Property      : constant Glib.Properties.Property_Boolean; 
  312.    Recent_Manager_Property  : constant Glib.Properties.Property_Object; 
  313.    Select_Multiple_Property : constant Glib.Properties.Property_Boolean; 
  314.    Show_Icons_Property      : constant Glib.Properties.Property_Boolean; 
  315.    Show_Not_Found_Property  : constant Glib.Properties.Property_Boolean; 
  316.    Show_Private_Property    : constant Glib.Properties.Property_Boolean; 
  317.    Show_Tips_Property       : constant Glib.Properties.Property_Boolean; 
  318.    Sort_Type_Property       : constant Glib.Properties.Property_Enum; 
  319.  
  320. private 
  321.  
  322.    Filter_Property : constant Glib.Properties.Property_Object := 
  323.      Glib.Properties.Build ("filter"); 
  324.    Limit_Property : constant Glib.Properties.Property_Int := 
  325.      Glib.Properties.Build ("limit"); 
  326.    Local_Only_Property : constant Glib.Properties.Property_Boolean := 
  327.      Glib.Properties.Build ("local-only"); 
  328.    Recent_Manager_Property : constant Glib.Properties.Property_Object := 
  329.      Glib.Properties.Build ("recent-manager"); 
  330.    Select_Multiple_Property : constant Glib.Properties.Property_Boolean := 
  331.      Glib.Properties.Build ("select-multiple"); 
  332.    Show_Icons_Property : constant Glib.Properties.Property_Boolean := 
  333.      Glib.Properties.Build ("show-icons"); 
  334.    Show_Not_Found_Property : constant Glib.Properties.Property_Boolean := 
  335.      Glib.Properties.Build ("show-not-found"); 
  336.    Show_Private_Property : constant Glib.Properties.Property_Boolean := 
  337.      Glib.Properties.Build ("show-private"); 
  338.    Show_Tips_Property : constant Glib.Properties.Property_Boolean := 
  339.      Glib.Properties.Build ("show-tips"); 
  340.    Sort_Type_Property : constant Glib.Properties.Property_Enum := 
  341.      Glib.Properties.Build ("sort-type"); 
  342.  
  343.    pragma Import (C, Get_Type, "gtk_recent_chooser_get_type"); 
  344.    pragma Import (C, Error_Quark, "gtk_recent_chooser_error_quark"); 
  345.  
  346. end Gtk.Recent_Chooser;