1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                      Copyright (C) 2001-2006                      -- 
  5. --                               AdaCore                             -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  This package implements a specific model to store your data in. Each 
  27. --  item in the list will correspond to one line in the tree view. Multiple 
  28. --  columns can be displayed for each line. 
  29. --  </description> 
  30. --  <c_version>2.8.17</c_version> 
  31. --  <group>Trees and Lists</group> 
  32.  
  33. with Gdk.Pixbuf; 
  34. with Glib.Types; 
  35. with Glib.Values; 
  36. with Gtk; 
  37. with Gtk.Tree_Dnd; 
  38. with Gtk.Tree_Model; 
  39. with Gtk.Tree_Sortable; 
  40.  
  41. package Gtk.List_Store is 
  42.  
  43.    type Gtk_List_Store_Record is 
  44.      new Gtk.Tree_Model.Gtk_Tree_Model_Record with null record; 
  45.    type Gtk_List_Store is access all Gtk_List_Store_Record'Class; 
  46.  
  47.    procedure Gtk_New 
  48.      (List_Store : out Gtk_List_Store; 
  49.       Types      : GType_Array); 
  50.    --  Creates a new list store using Types to fill the columns. 
  51.  
  52.    procedure Initialize 
  53.      (List_Store : access Gtk_List_Store_Record'Class; 
  54.       Types      : GType_Array); 
  55.    --  Internal initialization function. 
  56.    --  See the section "Creating your own widgets" in the documentation. 
  57.  
  58.    function Get_Type return Gtk.Gtk_Type; 
  59.    --  Return the internal value associated with this widget. 
  60.  
  61.    procedure Set_Column_Types 
  62.      (List_Store : access Gtk_List_Store_Record; 
  63.       Types      : GType_Array); 
  64.  
  65.    procedure Set_Value 
  66.      (List_Store : access Gtk_List_Store_Record; 
  67.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  68.       Column     : Gint; 
  69.       Value      : Glib.Values.GValue); 
  70.    --  Set the data in the cell specified by Iter and Column. 
  71.    --  The type of Value must be convertible to the type of the column. 
  72.  
  73.    procedure Set 
  74.      (Tree_Store : access Gtk_List_Store_Record; 
  75.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  76.       Column     : Gint; 
  77.       Value      : UTF8_String); 
  78.    --  Same as above, for an UTF8 string. 
  79.  
  80.    procedure Set 
  81.      (Tree_Store : access Gtk_List_Store_Record; 
  82.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  83.       Column     : Gint; 
  84.       Value      : Gint); 
  85.    --  Same as above, for a Gint. 
  86.  
  87.    procedure Set 
  88.      (Tree_Store : access Gtk_List_Store_Record; 
  89.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  90.       Column     : Gint; 
  91.       Value      : Gdk.Pixbuf.Gdk_Pixbuf); 
  92.    --  Same as above for a pixbuf 
  93.  
  94.    procedure Set 
  95.      (Tree_Store : access Gtk_List_Store_Record; 
  96.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  97.       Column     : Gint; 
  98.       Value      : Boolean); 
  99.    --  Same as above for a boolean 
  100.  
  101.    procedure Remove 
  102.      (List_Store : access Gtk_List_Store_Record; 
  103.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  104.    --  Remove the given row from the list store. 
  105.    --  After being removed, Iter is set to be the next valid row, or 
  106.    --  invalidated if it pointed to the last row in List_Store. 
  107.  
  108.    procedure Insert 
  109.      (List_Store : access Gtk_List_Store_Record; 
  110.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter; 
  111.       Position   : Gint); 
  112.    --  Create a new row at Position. 
  113.    --  Iter will be changed to point to this new row. 
  114.    --  If Position is larger than the number of rows on the list, then the new 
  115.    --  row will be appended to the list. The row will be empty before this 
  116.    --  function is called. To fill in values, you need to call Set_Value. 
  117.  
  118.    procedure Insert_Before 
  119.      (List_Store : access Gtk_List_Store_Record; 
  120.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter; 
  121.       Sibling    : Gtk.Tree_Model.Gtk_Tree_Iter); 
  122.    --  Insert a new row before Sibling. 
  123.    --  If Sibling is Null_Iter, then the row will be appended to the end of the 
  124.    --  list. Iter will be changed to point to this new row. The row will be 
  125.    --  empty before this function is called. To fill in values, you need to 
  126.    --  call Set_Value. 
  127.  
  128.    procedure Insert_After 
  129.      (List_Store : access Gtk_List_Store_Record; 
  130.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter; 
  131.       Sibling    : Gtk.Tree_Model.Gtk_Tree_Iter); 
  132.    --  Insert a new row after Sibling. 
  133.    --  If Sibling is Null_Iter, then the row will be prepended to the beginning 
  134.    --  of the list. Iter will be changed to point to this new row. The row will 
  135.    --  be empty after this function is called. To fill in values, you need to 
  136.    --  call Set_Value. 
  137.  
  138.    procedure Insert_With_Valuesv 
  139.      (List_Store : access Gtk_List_Store_Record; 
  140.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter; 
  141.       Position   : Glib.Gint; 
  142.       Columns    : Glib.Gint_Array; 
  143.       Values     : Glib.Values.GValue_Array); 
  144.    --  Creates a new row at Position. Iter will be changed to point to this new 
  145.    --  row. If Position is larger than the number of rows on the list, then the 
  146.    --  new row will be appended to the list. The row will be filled with the 
  147.    --  values given to this function. 
  148.    --  Using this function is more efficient that calling Insert and then 
  149.    --  Set for each column, since that will not emit the rows_reordered signal 
  150.    --  when the model is sorted. 
  151.  
  152.    procedure Prepend 
  153.      (List_Store : access Gtk_List_Store_Record; 
  154.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  155.    --  Prepend a new row to List_Store. 
  156.    --  Iter will be changed to point to this new row. The row will be empty 
  157.    --  after this function is called. To fill in values, you need to call 
  158.    --  Set_Value. 
  159.  
  160.    procedure Append 
  161.      (List_Store : access Gtk_List_Store_Record; 
  162.       Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  163.    --  Append a new row to List_Store. 
  164.    --  Iter will be changed to point to this new row. The row will be empty 
  165.    --  after this function is called. To fill in values, you need to call 
  166.    --  Set_Value. 
  167.  
  168.    procedure Clear (List_Store : access Gtk_List_Store_Record); 
  169.    --  Remove all the rows in List_Store. 
  170.  
  171.    function Iter_Is_Valid 
  172.      (List_Store : access Gtk_List_Store_Record; 
  173.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) 
  174.       return Boolean; 
  175.    --  WARNING: This function is slow. Only use it for debugging and/or testing 
  176.    --  purposes. 
  177.    --  Checks if the given iter is a valid iter for List_Store. 
  178.  
  179.    procedure Move_After 
  180.      (Store    : access Gtk_List_Store_Record; 
  181.       Iter     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  182.       Position : Gtk.Tree_Model.Gtk_Tree_Iter); 
  183.    --  Moves the row pointed to by Iter to the position after Position. Note 
  184.    --  that this function only works with unsorted stores. If Position is 
  185.    --  Null_Iter, Iter will be moved to the start of the list. 
  186.  
  187.    procedure Move_Before 
  188.      (Store    : access Gtk_List_Store_Record; 
  189.       Iter     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  190.       Position : Gtk.Tree_Model.Gtk_Tree_Iter); 
  191.    --  Moves the row pointed to by Iter to the position before Position. Note 
  192.    --  that this function only works with unsorted stores. If Position is 
  193.    --  Null_Iter, Iter will be moved to the end of the list. 
  194.  
  195.    procedure Reorder 
  196.      (Store     : access Gtk_List_Store_Record; 
  197.       New_Order : Glib.Gint_Array); 
  198.    --  Reorders Store to follow the order indicated by New_order. Note that 
  199.    --  this function only works with unsorted stores. 
  200.    --  New_Order is an array of integers mapping the new position of each child 
  201.    --  to its old position before the re-ordering, 
  202.    --  i.e. New_Order[newpos] = oldpos 
  203.  
  204.    procedure Swap 
  205.      (Store : access Gtk_List_Store_Record; 
  206.       A     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  207.       B     : Gtk.Tree_Model.Gtk_Tree_Iter); 
  208.    --  Swaps the rwos pointed to by A and B. Note that this function only works 
  209.    --  with unsorted stores. 
  210.  
  211.    ---------------- 
  212.    -- Interfaces -- 
  213.    ---------------- 
  214.    --  This class implements several interfaces. See Glib.Types 
  215.    -- 
  216.    --  - "Gtk_Tree_Sortable" 
  217.    --    This interface allows you to specify your own sort function 
  218.    -- 
  219.    --  - "Gtk_Tree_Drag_Source" 
  220.    --    This interface allows this widget to act as a dnd source 
  221.    -- 
  222.    --  - "Gtk_Tree_Drag_Dest" 
  223.    --    This interface allows this widget to act as a dnd destination 
  224.  
  225.    package Implements_Tree_Sortable is new Glib.Types.Implements 
  226.      (Gtk.Tree_Sortable.Gtk_Tree_Sortable, 
  227.       Gtk_List_Store_Record, 
  228.       Gtk_List_Store); 
  229.    function "+" 
  230.      (Model : access Gtk_List_Store_Record'Class) 
  231.       return Gtk.Tree_Sortable.Gtk_Tree_Sortable 
  232.       renames Implements_Tree_Sortable.To_Interface; 
  233.    function "-" 
  234.      (Sortable : Gtk.Tree_Sortable.Gtk_Tree_Sortable) 
  235.       return Gtk_List_Store 
  236.       renames Implements_Tree_Sortable.To_Object; 
  237.    --  Converts to and from the Gtk_Tree_Sortable interface 
  238.  
  239.    package Implements_Drag_Source is new Glib.Types.Implements 
  240.      (Gtk.Tree_Dnd.Gtk_Tree_Drag_Source, 
  241.       Gtk_List_Store_Record, 
  242.       Gtk_List_Store); 
  243.    function "+" 
  244.      (Model : access Gtk_List_Store_Record'Class) 
  245.       return Gtk.Tree_Dnd.Gtk_Tree_Drag_Source 
  246.       renames Implements_Drag_Source.To_Interface; 
  247.    function "-" 
  248.      (Drag_Source : Gtk.Tree_Dnd.Gtk_Tree_Drag_Source) 
  249.       return Gtk_List_Store 
  250.       renames Implements_Drag_Source.To_Object; 
  251.    --  Converts to and from the Gtk_Tree_Drag_Source interface 
  252.  
  253.    package Implements_Drag_Dest is new Glib.Types.Implements 
  254.      (Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest, 
  255.       Gtk_List_Store_Record, 
  256.       Gtk_List_Store); 
  257.    function "+" 
  258.      (Model : access Gtk_List_Store_Record'Class) 
  259.       return Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest 
  260.       renames Implements_Drag_Dest.To_Interface; 
  261.    function "-" 
  262.      (Drag_Dest : Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest) 
  263.       return Gtk_List_Store 
  264.       renames Implements_Drag_Dest.To_Object; 
  265.    --  Converts to and from the Gtk_Tree_Drag_Source interface 
  266.  
  267. private 
  268.  
  269.    pragma Import (C, Get_Type, "gtk_list_store_get_type"); 
  270. end Gtk.List_Store; 
  271.  
  272. --  No binding: gtk_list_store_new 
  273. --  No binding: gtk_list_store_set 
  274. --  No binding: gtk_list_store_set_valist 
  275. --  No binding: gtk_list_store_insert_with_values