1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2001-2007 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. --  The Gtk_Tree_Selection object is a helper object to manage the selection 
  26. --  for a Gtk_Tree_View widget. The Gtk_Tree_Selection object is automatically 
  27. --  created when a new Gtk_Tree_View widget is created, and cannot exist 
  28. --  independentally of this widget. The primary reason the Gtk_Tree_Selection 
  29. --  objects exists is for cleanliness of code and API. That is, there is no 
  30. --  conceptual reason all these functions could not be methods on the 
  31. --  Gtk_Tree_View widget instead of separate function. 
  32. -- 
  33. --  The Gtk_Tree_Selection object is gotten from a Gtk_Tree_View by calling 
  34. --  Gtk.Tree_View.Get_Selection. It can be manipulated to check the selection 
  35. --  status of the tree, as well as select and deselect individual rows. 
  36. --  Selection is done completely view side. As a result, multiple views of the 
  37. --  same model can have completely different selections. Additionally, you 
  38. --  cannot change the selection of a row on the model that is not currently 
  39. --  displayed by the view without expanding its parents first. 
  40. -- 
  41. --  One of the important things to remember when monitoring the selection of a 
  42. --  view is that the "changed" signal is mostly a hint. That is, it may only 
  43. --  emit one signal when a range of rows is selected. Additionally, it may on 
  44. --  occasion emit a "changed" signal when nothing has happened (mostly as a 
  45. --  result of programmers calling select_row on an already selected row). 
  46. --  </description> 
  47. --  <c_version>2.8.17</c_version> 
  48. --  <group>Trees and Lists</group> 
  49.  
  50. with Glib.Object; 
  51. with Gtk; 
  52. with Gtk.Enums;      use Gtk.Enums; 
  53. with Gtk.Tree_Model; 
  54. with Gtk.Widget;     use Gtk.Widget; 
  55.  
  56. package Gtk.Tree_Selection is 
  57.  
  58.    type Gtk_Tree_Selection_Record is 
  59.      new Glib.Object.GObject_Record with private; 
  60.    type Gtk_Tree_Selection is access all Gtk_Tree_Selection_Record'Class; 
  61.  
  62.    function Get_Type return Glib.GType; 
  63.    --  Return the internal type associated with Gtk_Tree_Selection. 
  64.  
  65.    procedure Set_Mode 
  66.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  67.       The_Type  : Gtk_Selection_Mode); 
  68.    function Get_Mode 
  69.      (Selection : access Gtk_Tree_Selection_Record'Class) 
  70.       return Gtk_Selection_Mode; 
  71.    --  Set the selection mode of the Selection. 
  72.    --  If the previous type was Gtk_Selection_Multiple, 
  73.    --  then the anchor is kept selected, if it was  previously selected. 
  74.  
  75.    function Get_Tree_View 
  76.      (Selection : access Gtk_Tree_Selection_Record'Class) 
  77.       return Gtk.Widget.Gtk_Widget; 
  78.    --  Return the tree view associated with Selection. 
  79.  
  80.    function Count_Selected_Rows 
  81.      (Selection : access Gtk_Tree_Selection_Record) return Gint; 
  82.    --  Returns the number of rows that have been selected. 
  83.  
  84.    procedure Get_Selected 
  85.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  86.       Model     : out Gtk.Tree_Model.Gtk_Tree_Model; 
  87.       Iter      : out Gtk.Tree_Model.Gtk_Tree_Iter); 
  88.    --  Set Iter to the currently selected node if Selection 
  89.    --  is set to Gtk_Selection_Single or Gtk_Selection_Browse. 
  90.    --  Iter is set to Null_Iter if no node is currently selected. 
  91.    --  Model is filled with the current model as a convenience. This function 
  92.    --  will not work if Selection is set to Gtk_Selection_Multiple. 
  93.  
  94.    procedure Get_Selected_Rows 
  95.      (Selection : access Gtk_Tree_Selection_Record; 
  96.       Model     : out Gtk.Tree_Model.Gtk_Tree_Model; 
  97.       Path_List : out Gtk.Tree_Model.Gtk_Tree_Path_List.Glist); 
  98.    --  Creates a list of path of all selected rows. Additionally, if you are 
  99.    --  planning on modifying the model after calling this function, you may 
  100.    --  want to convert the returned list into a list of Gtk_Tree_Row_Reference. 
  101.    -- 
  102.    --  You must free the resulting list by calling Path_Free on each item, and 
  103.    --  then freeing the list itself. 
  104.  
  105.    generic 
  106.       type Data_Type is private; 
  107.    package Selection_Foreach is 
  108.  
  109.       type Data_Type_Access is access all Data_Type; 
  110.  
  111.       type Foreach_Func is access procedure 
  112.         (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  113.          Path  : Gtk.Tree_Model.Gtk_Tree_Path; 
  114.          Iter  : Gtk.Tree_Model.Gtk_Tree_Iter; 
  115.          Data  : Data_Type_Access); 
  116.  
  117.       procedure Selected_Foreach 
  118.         (Selection : access Gtk_Tree_Selection_Record'Class; 
  119.          Func      : Foreach_Func; 
  120.          Data      : Data_Type_Access); 
  121.       --  Call Func for each selected node. 
  122.  
  123.    end Selection_Foreach; 
  124.  
  125.    procedure Select_Path 
  126.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  127.       Path      : Gtk.Tree_Model.Gtk_Tree_Path); 
  128.    procedure Unselect_Path 
  129.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  130.       Path      : Gtk.Tree_Model.Gtk_Tree_Path); 
  131.    --  Selects or unselects the row at path. 
  132.  
  133.    function Path_Is_Selected 
  134.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  135.       Path      : Gtk.Tree_Model.Gtk_Tree_Path) 
  136.       return Boolean; 
  137.    --  Return True if the row pointed to by path is currently selected. 
  138.    --  If path does not point to a valid location, False is returned 
  139.  
  140.    procedure Select_Iter 
  141.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  142.       Iter      : Gtk.Tree_Model.Gtk_Tree_Iter); 
  143.    procedure Unselect_Iter 
  144.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  145.       Iter      : Gtk.Tree_Model.Gtk_Tree_Iter); 
  146.    --  Selects or unselects the row pointed to by the specified iterator. 
  147.  
  148.    function Iter_Is_Selected 
  149.      (Selection : access Gtk_Tree_Selection_Record'Class; 
  150.       Iter      : Gtk.Tree_Model.Gtk_Tree_Iter) 
  151.       return Boolean; 
  152.    --  Return True if the row pointed to by path is currently selected. 
  153.  
  154.    procedure Select_All (Selection : access Gtk_Tree_Selection_Record'Class); 
  155.    procedure Unselect_All (Selection : access Gtk_Tree_Selection_Record'Class); 
  156.    --  Selects or unselects all the nodes. 
  157.    --  Selection must be set to Gtk_Selection_Multiple mode. 
  158.  
  159.    procedure Select_Range 
  160.      (Selection  : access Gtk_Tree_Selection_Record'Class; 
  161.       Start_Path : Gtk.Tree_Model.Gtk_Tree_Path; 
  162.       End_Path   : Gtk.Tree_Model.Gtk_Tree_Path); 
  163.    procedure Unselect_Range 
  164.      (Selection  : access Gtk_Tree_Selection_Record; 
  165.       Start_Path : Gtk.Tree_Model.Gtk_Tree_Path; 
  166.       End_Path   : Gtk.Tree_Model.Gtk_Tree_Path); 
  167.    --  Selects or unselects a range of nodes, determined by Start_Path and 
  168.    --  End_Path inclusive 
  169.  
  170.    ------------- 
  171.    -- Signals -- 
  172.    ------------- 
  173.  
  174.    --  <signals> 
  175.    --  The following new signals are defined for this widget: 
  176.    -- 
  177.    --  - "changed" 
  178.    --    procedure Handler 
  179.    --      (Widget : access Gtk_Tree_Selection_Record'Class'Class); 
  180.    --    Emitted whenever the selection has (possibly) changed. Please note 
  181.    --    that this signal is mostly a hint. It may only be emitted once when a 
  182.    --    range of rows are selected, and it may occasionally be emitted when 
  183.    --    nothing has happened. 
  184.    -- 
  185.    --  </signals> 
  186.  
  187.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  188.  
  189. private 
  190.    type Gtk_Tree_Selection_Record is 
  191.      new Glib.Object.GObject_Record with null record; 
  192.  
  193.    pragma Import (C, Get_Type, "gtk_tree_selection_get_type"); 
  194.  
  195. end Gtk.Tree_Selection; 
  196.  
  197. --   missing: 
  198. -- 
  199. --    procedure Set_Select_Function 
  200. --      (Selection : access Gtk_Tree_Selection_Record'Class; 
  201. --       Func      : Gtk_Tree_Selection_Func; 
  202. --       Data      : gpointer; 
  203. --       Destroy   : Gtk_Destroy_Notify); 
  204. -- 
  205. --    function Get_User_Data 
  206. --      (Selection : access Gtk_Tree_Selection_Record'Class) return gpointer;