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