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. --  The Gtk.List_Store.Gtk_List_Store object is a list model for use with a 
  26. --  Gtk.Tree_View.Gtk_Tree_View widget. It implements the 
  27. --  Gtk.Tree_Model.Gtk_Tree_Model interface, and consequentialy, can use all of 
  28. --  the methods available there. It also implements the 
  29. --  Gtk.Tree_Sortable.Gtk_Tree_Sortable interface so it can be sorted by the 
  30. --  view. Finally, it also implements the tree <link linkend="gtktreednd">drag 
  31. --  and drop</link> interfaces. 
  32. -- 
  33. --  The Gtk.List_Store.Gtk_List_Store can accept most GObject types as a 
  34. --  column type, though it can't accept all custom types. Internally, it will 
  35. --  keep a copy of data passed in (such as a string or a boxed pointer). 
  36. --  Columns that accept Glib.Object.GObject<!-- -->s are handled a little 
  37. --  differently. The Gtk.List_Store.Gtk_List_Store will keep a reference to the 
  38. --  object instead of copying the value. As a result, if the object is 
  39. --  modified, it is up to the application writer to call 
  40. --  Gtk.Tree_Model.Row_Changed to emit the 
  41. --  Gtk.Tree_Model.Gtk_Tree_Model::row_changed signal. This most commonly 
  42. --  affects lists with Gdk.Pixbuf.Gdk_Pixbuf<!-- -->s stored. 
  43. -- 
  44. --  == Creating a simple list store. == 
  45. -- 
  46. --    enum { 
  47. --       COLUMN_STRING, 
  48. --       COLUMN_INT, 
  49. --       COLUMN_BOOLEAN, 
  50. --       N_COLUMNS 
  51. --    }; 
  52. --    { 
  53. --       GtkListStore *list_store; 
  54. --       GtkTreePath *path; 
  55. --       GtkTreeIter iter; 
  56. --       gint i; 
  57. --       list_store = gtk_list_store_new (N_COLUMNS, 
  58. --          G_TYPE_STRING, 
  59. --          G_TYPE_INT, 
  60. --          G_TYPE_BOOLEAN); 
  61. --       for (i = 0; i < 10; i++) 
  62. --       { 
  63. --          gchar *some_data; 
  64. --          some_data = get_some_data (i); 
  65. --          // Add a new row to the model 
  66. --          gtk_list_store_append (list_store, &iter); 
  67. --          gtk_list_store_set (list_store, &iter, 
  68. --             COLUMN_STRING, some_data, 
  69. --             COLUMN_INT, i, 
  70. --             COLUMN_BOOLEAN,  FALSE, 
  71. --             -1); 
  72. --          /<!---->* As the store will keep a copy of the string internally, we 
  73. --          * free some_data. 
  74. --          *<!---->/ 
  75. --          g_free (some_data); 
  76. --       } 
  77. --       // Modify a particular row 
  78. --       path = gtk_tree_path_new_from_string ("4"); 
  79. --       gtk_tree_model_get_iter (GTK_TREE_MODEL (list_store), 
  80. --          &iter, 
  81. --          path); 
  82. --       gtk_tree_path_free (path); 
  83. --       gtk_list_store_set (list_store, &iter, 
  84. --          COLUMN_BOOLEAN, TRUE, 
  85. --          -1); 
  86. --    } 
  87. -- 
  88. --  == Performance Considerations == 
  89. -- 
  90. --  Internally, the Gtk.List_Store.Gtk_List_Store was implemented with a 
  91. --  linked list with a tail pointer prior to GTK+ 2.6. As a result, it was fast 
  92. --  at data insertion and deletion, and not fast at random data access. The 
  93. --  Gtk.List_Store.Gtk_List_Store sets the GTK_TREE_MODEL_ITERS_PERSIST flag, 
  94. --  which means that Gtk.Tree_Model.Gtk_Tree_Iter<!-- -->s can be cached while 
  95. --  the row exists. Thus, if access to a particular row is needed often and 
  96. --  your code is expected to run on older versions of GTK+, it is worth keeping 
  97. --  the iter around. 
  98. -- 
  99. --  == Atomic Operations == 
  100. -- 
  101. --  It is important to note that only the methods 
  102. --  gtk_list_store_insert_with_values and gtk_list_store_insert_with_valuesv 
  103. --  are atomic, in the sense that the row is being appended to the store and 
  104. --  the values filled in in a single operation with regard to 
  105. --  Gtk.Tree_Model.Gtk_Tree_Model signaling. In contrast, using e.g. 
  106. --  Gtk.List_Store.Append and then gtk_list_store_set will first create a row, 
  107. --  which triggers the Gtk.Tree_Model.Gtk_Tree_Model::row-inserted signal on 
  108. --  Gtk.List_Store.Gtk_List_Store. The row, however, is still empty, and any 
  109. --  signal handler connecting to Gtk.Tree_Model.Gtk_Tree_Model::row-inserted on 
  110. --  this particular store should be prepared for the situation that the row 
  111. --  might be empty. This is especially important if you are wrapping the 
  112. --  Gtk.List_Store.Gtk_List_Store inside a 
  113. --  Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter and are using a 
  114. --  Gtk_Tree_Model_Filter_Visible_Func. Using any of the non-atomic operations 
  115. --  to append rows to the Gtk.List_Store.Gtk_List_Store will cause the 
  116. --  Gtk_Tree_Model_Filter_Visible_Func to be visited with an empty row first; 
  117. --  the function must be prepared for that. 
  118. -- 
  119. --  == GtkListStore as GtkBuildable == 
  120. -- 
  121. --  The GtkListStore implementation of the GtkBuildable interface allows to 
  122. --  specify the model columns with a <columns> element that may contain 
  123. --  multiple <column> elements, each specifying one model column. The "type" 
  124. --  attribute specifies the data type for the column. 
  125. -- 
  126. --  Additionally, it is possible to specify content for the list store in the 
  127. --  UI definition, with the <data> element. It can contain multiple <row> 
  128. --  elements, each specifying to content for one row of the list model. Inside 
  129. --  a <row>, the <col> elements specify the content for individual cells. 
  130. -- 
  131. --  Note that it is probably more common to define your models in the code, 
  132. --  and one might consider it a layering violation to specify the content of a 
  133. --  list store in a UI definition, *data*, not *presentation*, and common 
  134. --  wisdom is to separate the two, as far as possible. <!-- FIXME a bit 
  135. --  inconclusive --> 
  136. -- 
  137. --  == A UI Definition fragment for a list store == 
  138. -- 
  139. --    <object class="GtkListStore"> 
  140. --    <columns> 
  141. --    <column type="gchararray"/> 
  142. --    <column type="gchararray"/> 
  143. --    <column type="gint"/> 
  144. --    </columns> 
  145. --    <data> 
  146. --    <col id="0">John</col> 
  147. --    <col id="1">Doe</col> 
  148. --    <col id="2">25</col> 
  149. --    <col id="0">Johan</col> 
  150. --    <col id="1">Dahlin</col> 
  151. --    <col id="2">50</col> 
  152. --    </data> 
  153. --    </object> 
  154. --  </description> 
  155. pragma Ada_2005; 
  156.  
  157. pragma Warnings (Off, "*is already use-visible*"); 
  158. with Gdk.Pixbuf;           use Gdk.Pixbuf; 
  159. with Glib;                 use Glib; 
  160. with Glib.Types;           use Glib.Types; 
  161. with Glib.Values;          use Glib.Values; 
  162. with Gtk.Buildable;        use Gtk.Buildable; 
  163. with Gtk.Enums;            use Gtk.Enums; 
  164. with Gtk.Selection_Data;   use Gtk.Selection_Data; 
  165. with Gtk.Tree_Drag_Dest;   use Gtk.Tree_Drag_Dest; 
  166. with Gtk.Tree_Drag_Source; use Gtk.Tree_Drag_Source; 
  167. with Gtk.Tree_Model;       use Gtk.Tree_Model; 
  168. with Gtk.Tree_Sortable;    use Gtk.Tree_Sortable; 
  169.  
  170. package Gtk.List_Store is 
  171.  
  172.    type Gtk_List_Store_Record is new Gtk_Root_Tree_Model_Record with null record; 
  173.    type Gtk_List_Store is access all Gtk_List_Store_Record'Class; 
  174.  
  175.    --------------- 
  176.    -- Callbacks -- 
  177.    --------------- 
  178.  
  179.    type Gtk_Tree_Model_Foreach_Func is access function 
  180.      (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  181.       Path  : Gtk.Tree_Model.Gtk_Tree_Path; 
  182.       Iter  : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  183.    --  Type of the callback passed to Gtk.Tree_Model.Foreach to iterate over 
  184.    --  the rows in a tree model. 
  185.    --  "model": the Gtk.Tree_Model.Gtk_Tree_Model being iterated 
  186.    --  "path": the current Gtk.Tree_Model.Gtk_Tree_Path 
  187.    --  "iter": the current Gtk.Tree_Model.Gtk_Tree_Iter 
  188.  
  189.    type Gtk_Tree_Iter_Compare_Func is access function 
  190.      (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  191.       A     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  192.       B     : Gtk.Tree_Model.Gtk_Tree_Iter) return Gint; 
  193.    --  A GtkTreeIterCompareFunc should return a negative integer, zero, or a 
  194.    --  positive integer if A sorts before B, A sorts with B, or A sorts after B 
  195.    --  respectively. If two iters compare as equal, their order in the sorted 
  196.    --  model is undefined. In order to ensure that the 
  197.    --  Gtk.Tree_Sortable.Gtk_Tree_Sortable behaves as expected, the 
  198.    --  GtkTreeIterCompareFunc must define a partial order on the model, i.e. it 
  199.    --  must be reflexive, antisymmetric and transitive. 
  200.    --  For example, if Model is a product catalogue, then a compare function 
  201.    --  for the "price" column could be one which returns 'price_of(A) - 
  202.    --  price_of(B)'. 
  203.    --  "model": The Gtk.Tree_Model.Gtk_Tree_Model the comparison is within 
  204.    --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  205.    --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  206.  
  207.    ------------------ 
  208.    -- Constructors -- 
  209.    ------------------ 
  210.  
  211.    procedure Gtk_New (List_Store : out Gtk_List_Store; Types : GType_Array); 
  212.    procedure Initialize 
  213.       (List_Store : not null access Gtk_List_Store_Record'Class; 
  214.        Types      : GType_Array); 
  215.    --  Non-vararg creation function. Used primarily by language bindings. 
  216.    --  "types": an array of GType types for the columns, from first to last 
  217.  
  218.    function Gtk_List_Store_Newv (Types : GType_Array) return Gtk_List_Store; 
  219.    --  Non-vararg creation function. Used primarily by language bindings. 
  220.    --  "types": an array of GType types for the columns, from first to last 
  221.  
  222.    function Get_Type return Glib.GType; 
  223.    pragma Import (C, Get_Type, "gtk_list_store_get_type"); 
  224.  
  225.    ------------- 
  226.    -- Methods -- 
  227.    ------------- 
  228.  
  229.    procedure Append 
  230.       (List_Store : not null access Gtk_List_Store_Record; 
  231.        Iter       : out Gtk.Tree_Model.Gtk_Tree_Iter); 
  232.    --  Appends a new row to List_Store. Iter will be changed to point to this 
  233.    --  new row. The row will be empty after this function is called. To fill in 
  234.    --  values, you need to call gtk_list_store_set or Gtk.List_Store.Set_Value. 
  235.    --  "iter": An unset Gtk.Tree_Model.Gtk_Tree_Iter to set to the appended 
  236.    --  row 
  237.  
  238.    procedure Clear (List_Store : not null access Gtk_List_Store_Record); 
  239.    --  Removes all rows from the list store. 
  240.  
  241.    procedure Insert 
  242.       (List_Store : not null access Gtk_List_Store_Record; 
  243.        Iter       : out Gtk.Tree_Model.Gtk_Tree_Iter; 
  244.        Position   : Gint); 
  245.    --  Creates a new row at Position. Iter will be changed to point to this 
  246.    --  new row. If Position is -1 or is larger than the number of rows on the 
  247.    --  list, then the new row will be appended to the list. The row will be 
  248.    --  empty after this function is called. To fill in values, you need to call 
  249.    --  gtk_list_store_set or Gtk.List_Store.Set_Value. 
  250.    --  "iter": An unset Gtk.Tree_Model.Gtk_Tree_Iter to set to the new row 
  251.    --  "position": position to insert the new row, or -1 for last 
  252.  
  253.    procedure Insert_After 
  254.       (List_Store : not null access Gtk_List_Store_Record; 
  255.        Iter       : out Gtk.Tree_Model.Gtk_Tree_Iter; 
  256.        Sibling    : Gtk.Tree_Model.Gtk_Tree_Iter); 
  257.    --  Inserts a new row after Sibling. If Sibling is null, then the row will 
  258.    --  be prepended to the beginning of the list. Iter will be changed to point 
  259.    --  to this new row. The row will be empty after this function is called. To 
  260.    --  fill in values, you need to call gtk_list_store_set or 
  261.    --  Gtk.List_Store.Set_Value. 
  262.    --  "iter": An unset Gtk.Tree_Model.Gtk_Tree_Iter to set to the new row 
  263.    --  "sibling": A valid Gtk.Tree_Model.Gtk_Tree_Iter, or null 
  264.  
  265.    procedure Insert_Before 
  266.       (List_Store : not null access Gtk_List_Store_Record; 
  267.        Iter       : out Gtk.Tree_Model.Gtk_Tree_Iter; 
  268.        Sibling    : Gtk.Tree_Model.Gtk_Tree_Iter); 
  269.    --  Inserts a new row before Sibling. If Sibling is null, then the row will 
  270.    --  be appended to the end of the list. Iter will be changed to point to 
  271.    --  this new row. The row will be empty after this function is called. To 
  272.    --  fill in values, you need to call gtk_list_store_set or 
  273.    --  Gtk.List_Store.Set_Value. 
  274.    --  "iter": An unset Gtk.Tree_Model.Gtk_Tree_Iter to set to the new row 
  275.    --  "sibling": A valid Gtk.Tree_Model.Gtk_Tree_Iter, or null 
  276.  
  277.    function Iter_Is_Valid 
  278.       (List_Store : not null access Gtk_List_Store_Record; 
  279.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  280.    --  <warning>This function is slow. Only use it for debugging and/or 
  281.    --  testing purposes.</warning> 
  282.    --  Checks if the given iter is a valid iter for this 
  283.    --  Gtk.List_Store.Gtk_List_Store. 
  284.    --  Since: gtk+ 2.2 
  285.    --  "iter": A Gtk.Tree_Model.Gtk_Tree_Iter. 
  286.  
  287.    procedure Move_After 
  288.       (List_Store : not null access Gtk_List_Store_Record; 
  289.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  290.        Position   : Gtk.Tree_Model.Gtk_Tree_Iter); 
  291.    --  Moves Iter in Store to the position after Position. Note that this 
  292.    --  function only works with unsorted stores. If Position is null, Iter will 
  293.    --  be moved to the start of the list. 
  294.    --  Since: gtk+ 2.2 
  295.    --  "iter": A Gtk.Tree_Model.Gtk_Tree_Iter. 
  296.    --  "position": A Gtk.Tree_Model.Gtk_Tree_Iter or null. 
  297.  
  298.    procedure Move_Before 
  299.       (List_Store : not null access Gtk_List_Store_Record; 
  300.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  301.        Position   : Gtk.Tree_Model.Gtk_Tree_Iter); 
  302.    --  Moves Iter in Store to the position before Position. Note that this 
  303.    --  function only works with unsorted stores. If Position is null, Iter will 
  304.    --  be moved to the end of the list. 
  305.    --  Since: gtk+ 2.2 
  306.    --  "iter": A Gtk.Tree_Model.Gtk_Tree_Iter. 
  307.    --  "position": A Gtk.Tree_Model.Gtk_Tree_Iter, or null. 
  308.  
  309.    procedure Prepend 
  310.       (List_Store : not null access Gtk_List_Store_Record; 
  311.        Iter       : out Gtk.Tree_Model.Gtk_Tree_Iter); 
  312.    --  Prepends a new row to List_Store. Iter will be changed to point to this 
  313.    --  new row. The row will be empty after this function is called. To fill in 
  314.    --  values, you need to call gtk_list_store_set or Gtk.List_Store.Set_Value. 
  315.    --  "iter": An unset Gtk.Tree_Model.Gtk_Tree_Iter to set to the prepend row 
  316.  
  317.    procedure Remove 
  318.       (List_Store : not null access Gtk_List_Store_Record; 
  319.        Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  320.    --  Removes the given row from the list store. After being removed, Iter is 
  321.    --  set to be the next valid row, or invalidated if it pointed to the last 
  322.    --  row in List_Store. 
  323.    --  "iter": A valid Gtk.Tree_Model.Gtk_Tree_Iter 
  324.  
  325.    procedure Reorder 
  326.       (List_Store : not null access Gtk_List_Store_Record; 
  327.        New_Order  : Gint_Array); 
  328.    --  Reorders Store to follow the order indicated by New_Order. Note that 
  329.    --  this function only works with unsorted stores. 
  330.    --  Since: gtk+ 2.2 
  331.    --  "new_order": an array of integers mapping the new position of each 
  332.    --  child to its old position before the re-ordering, i.e. 
  333.    --  New_Order'[newpos] = oldpos'. It must have exactly as many items as the 
  334.    --  list store's length. 
  335.  
  336.    procedure Set_Column_Types 
  337.       (List_Store : not null access Gtk_List_Store_Record; 
  338.        Types      : GType_Array); 
  339.    --  This function is meant primarily for GObjects that inherit from 
  340.    --  Gtk.List_Store.Gtk_List_Store, and should only be used when constructing 
  341.    --  a new Gtk.List_Store.Gtk_List_Store. It will not function after a row 
  342.    --  has been added, or a method on the Gtk.Tree_Model.Gtk_Tree_Model 
  343.    --  interface is called. 
  344.    --  "types": An array length n of GTypes 
  345.  
  346.    procedure Set_Value 
  347.       (List_Store : not null access Gtk_List_Store_Record; 
  348.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  349.        Column     : Gint; 
  350.        Value      : Glib.Values.GValue); 
  351.    --  Sets the data in the cell specified by Iter and Column. The type of 
  352.    --  Value must be convertible to the type of the column. 
  353.    --  "iter": A valid Gtk.Tree_Model.Gtk_Tree_Iter for the row being modified 
  354.    --  "column": column number to modify 
  355.    --  "value": new value for the cell 
  356.  
  357.    procedure Swap 
  358.       (List_Store : not null access Gtk_List_Store_Record; 
  359.        A          : Gtk.Tree_Model.Gtk_Tree_Iter; 
  360.        B          : Gtk.Tree_Model.Gtk_Tree_Iter); 
  361.    --  Swaps A and B in Store. Note that this function only works with 
  362.    --  unsorted stores. 
  363.    --  Since: gtk+ 2.2 
  364.    --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter. 
  365.    --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter. 
  366.  
  367.    procedure Foreach 
  368.       (Tree_Model : not null access Gtk_List_Store_Record; 
  369.        Func       : Gtk_Tree_Model_Foreach_Func); 
  370.    --  Calls func on each node in model in a depth-first fashion. 
  371.    --  If Func returns True, then the tree ceases to be walked, and 
  372.    --  Gtk.Tree_Model.Foreach returns. 
  373.    --  "func": a function to be called on each row 
  374.  
  375.    generic 
  376.       type User_Data_Type (<>) is private; 
  377.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  378.    package Foreach_User_Data is 
  379.  
  380.       type Gtk_Tree_Model_Foreach_Func is access function 
  381.         (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  382.          Path  : Gtk.Tree_Model.Gtk_Tree_Path; 
  383.          Iter  : Gtk.Tree_Model.Gtk_Tree_Iter; 
  384.          Data  : User_Data_Type) return Boolean; 
  385.       --  Type of the callback passed to Gtk.Tree_Model.Foreach to iterate over 
  386.       --  the rows in a tree model. 
  387.       --  "model": the Gtk.Tree_Model.Gtk_Tree_Model being iterated 
  388.       --  "path": the current Gtk.Tree_Model.Gtk_Tree_Path 
  389.       --  "iter": the current Gtk.Tree_Model.Gtk_Tree_Iter 
  390.       --  "data": The user data passed to Gtk.Tree_Model.Foreach 
  391.  
  392.       procedure Foreach 
  393.          (Tree_Model : not null access Gtk.List_Store.Gtk_List_Store_Record'Class; 
  394.           Func       : Gtk_Tree_Model_Foreach_Func; 
  395.           User_Data  : User_Data_Type); 
  396.       --  Calls func on each node in model in a depth-first fashion. 
  397.       --  If Func returns True, then the tree ceases to be walked, and 
  398.       --  Gtk.Tree_Model.Foreach returns. 
  399.       --  "func": a function to be called on each row 
  400.       --  "user_data": user data to passed to Func 
  401.  
  402.    end Foreach_User_Data; 
  403.  
  404.    procedure Set_Default_Sort_Func 
  405.       (Sortable  : not null access Gtk_List_Store_Record; 
  406.        Sort_Func : Gtk_Tree_Iter_Compare_Func); 
  407.    --  Sets the default comparison function used when sorting to be Sort_Func. 
  408.    --  If the current sort column id of Sortable is 
  409.    --  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using 
  410.    --  this function. 
  411.    --  If Sort_Func is null, then there will be no default comparison 
  412.    --  function. This means that once the model has been sorted, it can't go 
  413.    --  back to the default state. In this case, when the current sort column id 
  414.    --  of Sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will 
  415.    --  be unsorted. 
  416.    --  "sort_func": The comparison function 
  417.  
  418.    generic 
  419.       type User_Data_Type (<>) is private; 
  420.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  421.    package Set_Default_Sort_Func_User_Data is 
  422.  
  423.       type Gtk_Tree_Iter_Compare_Func is access function 
  424.         (Model     : Gtk.Tree_Model.Gtk_Tree_Model; 
  425.          A         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  426.          B         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  427.          User_Data : User_Data_Type) return Gint; 
  428.       --  A GtkTreeIterCompareFunc should return a negative integer, zero, or a 
  429.       --  positive integer if A sorts before B, A sorts with B, or A sorts after B 
  430.       --  respectively. If two iters compare as equal, their order in the sorted 
  431.       --  model is undefined. In order to ensure that the 
  432.       --  Gtk.Tree_Sortable.Gtk_Tree_Sortable behaves as expected, the 
  433.       --  GtkTreeIterCompareFunc must define a partial order on the model, i.e. it 
  434.       --  must be reflexive, antisymmetric and transitive. 
  435.       --  For example, if Model is a product catalogue, then a compare function 
  436.       --  for the "price" column could be one which returns 'price_of(A) - 
  437.       --  price_of(B)'. 
  438.       --  "model": The Gtk.Tree_Model.Gtk_Tree_Model the comparison is within 
  439.       --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  440.       --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  441.       --  "user_data": Data passed when the compare func is assigned e.g. by 
  442.       --  Gtk.Tree_Sortable.Set_Sort_Func 
  443.  
  444.       procedure Set_Default_Sort_Func 
  445.          (Sortable  : not null access Gtk.List_Store.Gtk_List_Store_Record'Class; 
  446.           Sort_Func : Gtk_Tree_Iter_Compare_Func; 
  447.           User_Data : User_Data_Type); 
  448.       --  Sets the default comparison function used when sorting to be 
  449.       --  Sort_Func. If the current sort column id of Sortable is 
  450.       --  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort 
  451.       --  using this function. 
  452.       --  If Sort_Func is null, then there will be no default comparison 
  453.       --  function. This means that once the model has been sorted, it can't go 
  454.       --  back to the default state. In this case, when the current sort column 
  455.       --  id of Sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model 
  456.       --  will be unsorted. 
  457.       --  "sort_func": The comparison function 
  458.       --  "user_data": User data to pass to Sort_Func, or null 
  459.  
  460.    end Set_Default_Sort_Func_User_Data; 
  461.  
  462.    procedure Set_Sort_Func 
  463.       (Sortable       : not null access Gtk_List_Store_Record; 
  464.        Sort_Column_Id : Gint; 
  465.        Sort_Func      : Gtk_Tree_Iter_Compare_Func); 
  466.    --  Sets the comparison function used when sorting to be Sort_Func. If the 
  467.    --  current sort column id of Sortable is the same as Sort_Column_Id, then 
  468.    --  the model will sort using this function. 
  469.    --  "sort_column_id": the sort column id to set the function for 
  470.    --  "sort_func": The comparison function 
  471.  
  472.    generic 
  473.       type User_Data_Type (<>) is private; 
  474.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  475.    package Set_Sort_Func_User_Data is 
  476.  
  477.       type Gtk_Tree_Iter_Compare_Func is access function 
  478.         (Model     : Gtk.Tree_Model.Gtk_Tree_Model; 
  479.          A         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  480.          B         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  481.          User_Data : User_Data_Type) return Gint; 
  482.       --  A GtkTreeIterCompareFunc should return a negative integer, zero, or a 
  483.       --  positive integer if A sorts before B, A sorts with B, or A sorts after B 
  484.       --  respectively. If two iters compare as equal, their order in the sorted 
  485.       --  model is undefined. In order to ensure that the 
  486.       --  Gtk.Tree_Sortable.Gtk_Tree_Sortable behaves as expected, the 
  487.       --  GtkTreeIterCompareFunc must define a partial order on the model, i.e. it 
  488.       --  must be reflexive, antisymmetric and transitive. 
  489.       --  For example, if Model is a product catalogue, then a compare function 
  490.       --  for the "price" column could be one which returns 'price_of(A) - 
  491.       --  price_of(B)'. 
  492.       --  "model": The Gtk.Tree_Model.Gtk_Tree_Model the comparison is within 
  493.       --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  494.       --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  495.       --  "user_data": Data passed when the compare func is assigned e.g. by 
  496.       --  Gtk.Tree_Sortable.Set_Sort_Func 
  497.  
  498.       procedure Set_Sort_Func 
  499.          (Sortable       : not null access Gtk.List_Store.Gtk_List_Store_Record'Class; 
  500.           Sort_Column_Id : Gint; 
  501.           Sort_Func      : Gtk_Tree_Iter_Compare_Func; 
  502.           User_Data      : User_Data_Type); 
  503.       --  Sets the comparison function used when sorting to be Sort_Func. If 
  504.       --  the current sort column id of Sortable is the same as Sort_Column_Id, 
  505.       --  then the model will sort using this function. 
  506.       --  "sort_column_id": the sort column id to set the function for 
  507.       --  "sort_func": The comparison function 
  508.       --  "user_data": User data to pass to Sort_Func, or null 
  509.  
  510.    end Set_Sort_Func_User_Data; 
  511.  
  512.    ---------------------- 
  513.    -- GtkAda additions -- 
  514.    ---------------------- 
  515.  
  516.    procedure Set 
  517.      (Tree_Store : access Gtk_List_Store_Record; 
  518.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  519.       Column     : Gint; 
  520.       Value      : UTF8_String); 
  521.    procedure Set 
  522.      (Tree_Store : access Gtk_List_Store_Record; 
  523.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  524.       Column     : Gint; 
  525.       Value      : Boolean); 
  526.    procedure Set 
  527.      (Tree_Store : access Gtk_List_Store_Record; 
  528.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  529.       Column     : Gint; 
  530.       Value      : Gint); 
  531.    procedure Set 
  532.      (Tree_Store : access Gtk_List_Store_Record; 
  533.       Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  534.       Column     : Gint; 
  535.       Value      : Gdk.Pixbuf.Gdk_Pixbuf); 
  536.  
  537.    --------------------------------------------- 
  538.    -- Inherited subprograms (from interfaces) -- 
  539.    --------------------------------------------- 
  540.    --  Methods inherited from the Buildable interface are not duplicated here 
  541.    --  since they are meant to be used by tools, mostly. If you need to call 
  542.    --  them, use an explicit cast through the "-" operator below. 
  543.  
  544.    function Drag_Data_Received 
  545.       (Self           : not null access Gtk_List_Store_Record; 
  546.        Dest           : Gtk.Tree_Model.Gtk_Tree_Path; 
  547.        Selection_Data : Gtk.Selection_Data.Gtk_Selection_Data) 
  548.        return Boolean; 
  549.  
  550.    function Row_Drop_Possible 
  551.       (Self           : not null access Gtk_List_Store_Record; 
  552.        Dest_Path      : Gtk.Tree_Model.Gtk_Tree_Path; 
  553.        Selection_Data : Gtk.Selection_Data.Gtk_Selection_Data) 
  554.        return Boolean; 
  555.  
  556.    function Drag_Data_Delete 
  557.       (Self : not null access Gtk_List_Store_Record; 
  558.        Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean; 
  559.  
  560.    function Drag_Data_Get 
  561.       (Self           : not null access Gtk_List_Store_Record; 
  562.        Path           : Gtk.Tree_Model.Gtk_Tree_Path; 
  563.        Selection_Data : Gtk.Selection_Data.Gtk_Selection_Data) 
  564.        return Boolean; 
  565.  
  566.    function Row_Draggable 
  567.       (Self : not null access Gtk_List_Store_Record; 
  568.        Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean; 
  569.  
  570.    function Get_Column_Type 
  571.       (Tree_Model : not null access Gtk_List_Store_Record; 
  572.        Index      : Gint) return GType; 
  573.  
  574.    function Get_Flags 
  575.       (Tree_Model : not null access Gtk_List_Store_Record) 
  576.        return Gtk.Tree_Model.Tree_Model_Flags; 
  577.  
  578.    function Get_Iter 
  579.       (Tree_Model : not null access Gtk_List_Store_Record; 
  580.        Path       : Gtk.Tree_Model.Gtk_Tree_Path) 
  581.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  582.  
  583.    function Get_Iter_First 
  584.       (Tree_Model : not null access Gtk_List_Store_Record) 
  585.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  586.  
  587.    function Get_Iter_From_String 
  588.       (Tree_Model  : not null access Gtk_List_Store_Record; 
  589.        Path_String : UTF8_String) return Gtk.Tree_Model.Gtk_Tree_Iter; 
  590.  
  591.    function Get_N_Columns 
  592.       (Tree_Model : not null access Gtk_List_Store_Record) return Gint; 
  593.  
  594.    function Get_Path 
  595.       (Tree_Model : not null access Gtk_List_Store_Record; 
  596.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) 
  597.        return Gtk.Tree_Model.Gtk_Tree_Path; 
  598.  
  599.    function Get_String_From_Iter 
  600.       (Tree_Model : not null access Gtk_List_Store_Record; 
  601.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) return UTF8_String; 
  602.  
  603.    procedure Get_Value 
  604.       (Tree_Model : not null access Gtk_List_Store_Record; 
  605.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  606.        Column     : Gint; 
  607.        Value      : out Glib.Values.GValue); 
  608.  
  609.    function Children 
  610.       (Tree_Model : not null access Gtk_List_Store_Record; 
  611.        Parent     : Gtk.Tree_Model.Gtk_Tree_Iter) 
  612.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  613.  
  614.    function Has_Child 
  615.       (Tree_Model : not null access Gtk_List_Store_Record; 
  616.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  617.  
  618.    function N_Children 
  619.       (Tree_Model : not null access Gtk_List_Store_Record; 
  620.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter := Gtk.Tree_Model.Null_Iter) 
  621.        return Gint; 
  622.  
  623.    procedure Next 
  624.       (Tree_Model : not null access Gtk_List_Store_Record; 
  625.        Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  626.  
  627.    function Nth_Child 
  628.       (Tree_Model : not null access Gtk_List_Store_Record; 
  629.        Parent     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  630.        N          : Gint) return Gtk.Tree_Model.Gtk_Tree_Iter; 
  631.  
  632.    function Parent 
  633.       (Tree_Model : not null access Gtk_List_Store_Record; 
  634.        Child      : Gtk.Tree_Model.Gtk_Tree_Iter) 
  635.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  636.  
  637.    procedure Previous 
  638.       (Tree_Model : not null access Gtk_List_Store_Record; 
  639.        Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  640.  
  641.    procedure Ref_Node 
  642.       (Tree_Model : not null access Gtk_List_Store_Record; 
  643.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  644.  
  645.    procedure Row_Changed 
  646.       (Tree_Model : not null access Gtk_List_Store_Record; 
  647.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  648.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  649.  
  650.    procedure Row_Deleted 
  651.       (Tree_Model : not null access Gtk_List_Store_Record; 
  652.        Path       : Gtk.Tree_Model.Gtk_Tree_Path); 
  653.  
  654.    procedure Row_Has_Child_Toggled 
  655.       (Tree_Model : not null access Gtk_List_Store_Record; 
  656.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  657.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  658.  
  659.    procedure Row_Inserted 
  660.       (Tree_Model : not null access Gtk_List_Store_Record; 
  661.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  662.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  663.  
  664.    procedure Rows_Reordered 
  665.       (Tree_Model : not null access Gtk_List_Store_Record; 
  666.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  667.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  668.        New_Order  : Gint_Array); 
  669.  
  670.    procedure Unref_Node 
  671.       (Tree_Model : not null access Gtk_List_Store_Record; 
  672.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  673.  
  674.    procedure Get_Sort_Column_Id 
  675.       (Sortable       : not null access Gtk_List_Store_Record; 
  676.        Sort_Column_Id : out Gint; 
  677.        Order          : out Gtk.Enums.Gtk_Sort_Type); 
  678.  
  679.    procedure Set_Sort_Column_Id 
  680.       (Sortable       : not null access Gtk_List_Store_Record; 
  681.        Sort_Column_Id : Gint; 
  682.        Order          : Gtk.Enums.Gtk_Sort_Type); 
  683.  
  684.    function Has_Default_Sort_Func 
  685.       (Sortable : not null access Gtk_List_Store_Record) return Boolean; 
  686.  
  687.    procedure Sort_Column_Changed 
  688.       (Sortable : not null access Gtk_List_Store_Record); 
  689.  
  690.    ---------------- 
  691.    -- Interfaces -- 
  692.    ---------------- 
  693.    --  This class implements several interfaces. See Glib.Types 
  694.    -- 
  695.    --  - "Buildable" 
  696.    -- 
  697.    --  - "TreeDragDest" 
  698.    -- 
  699.    --  - "TreeDragSource" 
  700.    -- 
  701.    --  - "TreeModel" 
  702.    -- 
  703.    --  - "TreeSortable" 
  704.  
  705.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  706.      (Gtk.Buildable.Gtk_Buildable, Gtk_List_Store_Record, Gtk_List_Store); 
  707.    function "+" 
  708.      (Widget : access Gtk_List_Store_Record'Class) 
  709.    return Gtk.Buildable.Gtk_Buildable 
  710.    renames Implements_Gtk_Buildable.To_Interface; 
  711.    function "-" 
  712.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  713.    return Gtk_List_Store 
  714.    renames Implements_Gtk_Buildable.To_Object; 
  715.  
  716.    package Implements_Gtk_Tree_Drag_Dest is new Glib.Types.Implements 
  717.      (Gtk.Tree_Drag_Dest.Gtk_Tree_Drag_Dest, Gtk_List_Store_Record, Gtk_List_Store); 
  718.    function "+" 
  719.      (Widget : access Gtk_List_Store_Record'Class) 
  720.    return Gtk.Tree_Drag_Dest.Gtk_Tree_Drag_Dest 
  721.    renames Implements_Gtk_Tree_Drag_Dest.To_Interface; 
  722.    function "-" 
  723.      (Interf : Gtk.Tree_Drag_Dest.Gtk_Tree_Drag_Dest) 
  724.    return Gtk_List_Store 
  725.    renames Implements_Gtk_Tree_Drag_Dest.To_Object; 
  726.  
  727.    package Implements_Gtk_Tree_Drag_Source is new Glib.Types.Implements 
  728.      (Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source, Gtk_List_Store_Record, Gtk_List_Store); 
  729.    function "+" 
  730.      (Widget : access Gtk_List_Store_Record'Class) 
  731.    return Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source 
  732.    renames Implements_Gtk_Tree_Drag_Source.To_Interface; 
  733.    function "-" 
  734.      (Interf : Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source) 
  735.    return Gtk_List_Store 
  736.    renames Implements_Gtk_Tree_Drag_Source.To_Object; 
  737.  
  738.    package Implements_Gtk_Tree_Model is new Glib.Types.Implements 
  739.      (Gtk.Tree_Model.Gtk_Tree_Model, Gtk_List_Store_Record, Gtk_List_Store); 
  740.    function "+" 
  741.      (Widget : access Gtk_List_Store_Record'Class) 
  742.    return Gtk.Tree_Model.Gtk_Tree_Model 
  743.    renames Implements_Gtk_Tree_Model.To_Interface; 
  744.    function "-" 
  745.      (Interf : Gtk.Tree_Model.Gtk_Tree_Model) 
  746.    return Gtk_List_Store 
  747.    renames Implements_Gtk_Tree_Model.To_Object; 
  748.  
  749.    package Implements_Gtk_Tree_Sortable is new Glib.Types.Implements 
  750.      (Gtk.Tree_Sortable.Gtk_Tree_Sortable, Gtk_List_Store_Record, Gtk_List_Store); 
  751.    function "+" 
  752.      (Widget : access Gtk_List_Store_Record'Class) 
  753.    return Gtk.Tree_Sortable.Gtk_Tree_Sortable 
  754.    renames Implements_Gtk_Tree_Sortable.To_Interface; 
  755.    function "-" 
  756.      (Interf : Gtk.Tree_Sortable.Gtk_Tree_Sortable) 
  757.    return Gtk_List_Store 
  758.    renames Implements_Gtk_Tree_Sortable.To_Object; 
  759.  
  760. end Gtk.List_Store;