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.Tree_Model_Sort.Gtk_Tree_Model_Sort is a model which implements 
  26. --  the Gtk.Tree_Sortable.Gtk_Tree_Sortable interface. It does not hold any 
  27. --  data itself, but rather is created with a child model and proxies its data. 
  28. --  It has identical column types to this child model, and the changes in the 
  29. --  child are propagated. The primary purpose of this model is to provide a way 
  30. --  to sort a different model without modifying it. Note that the sort function 
  31. --  used by Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort is not guaranteed to be 
  32. --  stable. 
  33. -- 
  34. --  The use of this is best demonstrated through an example. In the following 
  35. --  sample code we create two Gtk.Tree_View.Gtk_Tree_View widgets each with a 
  36. --  view of the same data. As the model is wrapped here by a 
  37. --  Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort, the two 
  38. --  Gtk.Tree_View.Gtk_Tree_View<!-- -->s can each sort their view of the data 
  39. --  without affecting the other. By contrast, if we simply put the same model 
  40. --  in each widget, then sorting the first would sort the second. 
  41. -- 
  42. --  == Using a <structname>GtkTreeModelSort</structname> == 
  43. -- 
  44. --    { 
  45. --       GtkTreeView *tree_view1; 
  46. --       GtkTreeView *tree_view2; 
  47. --       GtkTreeModel *sort_model1; 
  48. --       GtkTreeModel *sort_model2; 
  49. --       GtkTreeModel *child_model; 
  50. --       // get the child model 
  51. --       child_model = get_my_model (); 
  52. --       // Create the first tree 
  53. --       sort_model1 = gtk_tree_model_sort_new_with_model (child_model); 
  54. --       tree_view1 = gtk_tree_view_new_with_model (sort_model1); 
  55. --       // Create the second tree 
  56. --       sort_model2 = gtk_tree_model_sort_new_with_model (child_model); 
  57. --       tree_view2 = gtk_tree_view_new_with_model (sort_model2); 
  58. --       // Now we can sort the two models independently 
  59. --       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model1), 
  60. --          COLUMN_1, GTK_SORT_ASCENDING); 
  61. --       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model2), 
  62. --          COLUMN_1, GTK_SORT_DESCENDING); 
  63. --    } 
  64. -- 
  65. --  To demonstrate how to access the underlying child model from the sort 
  66. --  model, the next example will be a callback for the 
  67. --  Gtk.Tree_Selection.Gtk_Tree_Selection 
  68. --  Gtk.Tree_Selection.Gtk_Tree_Selection::changed signal. In this callback, we 
  69. --  get a string from COLUMN_1 of the model. We then modify the string, find 
  70. --  the same selected row on the child model, and change the row there. 
  71. -- 
  72. --  == Accessing the child model of in a selection changed callback == 
  73. -- 
  74. --    void 
  75. --    selection_changed (GtkTreeSelection *selection, gpointer data) 
  76. --    { 
  77. --       GtkTreeModel *sort_model = NULL; 
  78. --       GtkTreeModel *child_model; 
  79. --       GtkTreeIter sort_iter; 
  80. --       GtkTreeIter child_iter; 
  81. --       char *some_data = NULL; 
  82. --       char *modified_data; 
  83. --       // Get the current selected row and the model. 
  84. --       if (! gtk_tree_selection_get_selected (selection, 
  85. --             &sort_model, 
  86. --             &sort_iter)) 
  87. --       return; 
  88. --       /<!---->* Look up the current value on the selected row and get a new value 
  89. --       * to change it to. 
  90. --       *<!---->/ 
  91. --       gtk_tree_model_get (GTK_TREE_MODEL (sort_model), &sort_iter, 
  92. --          COLUMN_1, &some_data, 
  93. --          -1); 
  94. --       modified_data = change_the_data (some_data); 
  95. --       g_free (some_data); 
  96. --       // Get an iterator on the child model, instead of the sort model. 
  97. --       gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (sort_model), 
  98. --          &child_iter, 
  99. --          &sort_iter); 
  100. --       /<!---->* Get the child model and change the value of the row.  In this 
  101. --       * example, the child model is a GtkListStore.  It could be any other 
  102. --       * type of model, though. 
  103. --       *<!---->/ 
  104. --       child_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model)); 
  105. --       gtk_list_store_set (GTK_LIST_STORE (child_model), &child_iter, 
  106. --          COLUMN_1, &modified_data, 
  107. --          -1); 
  108. --       g_free (modified_data); 
  109. --    } 
  110. -- 
  111. -- 
  112. --  </description> 
  113. pragma Ada_2005; 
  114.  
  115. pragma Warnings (Off, "*is already use-visible*"); 
  116. with Glib;                 use Glib; 
  117. with Glib.Properties;      use Glib.Properties; 
  118. with Glib.Types;           use Glib.Types; 
  119. with Glib.Values;          use Glib.Values; 
  120. with Gtk.Enums;            use Gtk.Enums; 
  121. with Gtk.Selection_Data;   use Gtk.Selection_Data; 
  122. with Gtk.Tree_Drag_Source; use Gtk.Tree_Drag_Source; 
  123. with Gtk.Tree_Model;       use Gtk.Tree_Model; 
  124. with Gtk.Tree_Sortable;    use Gtk.Tree_Sortable; 
  125.  
  126. package Gtk.Tree_Model_Sort is 
  127.  
  128.    type Gtk_Tree_Model_Sort_Record is new Gtk_Root_Tree_Model_Record with null record; 
  129.    type Gtk_Tree_Model_Sort is access all Gtk_Tree_Model_Sort_Record'Class; 
  130.  
  131.    --------------- 
  132.    -- Callbacks -- 
  133.    --------------- 
  134.  
  135.    type Gtk_Tree_Model_Foreach_Func is access function 
  136.      (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  137.       Path  : Gtk.Tree_Model.Gtk_Tree_Path; 
  138.       Iter  : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  139.    --  Type of the callback passed to Gtk.Tree_Model.Foreach to iterate over 
  140.    --  the rows in a tree model. 
  141.    --  "model": the Gtk.Tree_Model.Gtk_Tree_Model being iterated 
  142.    --  "path": the current Gtk.Tree_Model.Gtk_Tree_Path 
  143.    --  "iter": the current Gtk.Tree_Model.Gtk_Tree_Iter 
  144.  
  145.    type Gtk_Tree_Iter_Compare_Func is access function 
  146.      (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  147.       A     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  148.       B     : Gtk.Tree_Model.Gtk_Tree_Iter) return Gint; 
  149.    --  A GtkTreeIterCompareFunc should return a negative integer, zero, or a 
  150.    --  positive integer if A sorts before B, A sorts with B, or A sorts after B 
  151.    --  respectively. If two iters compare as equal, their order in the sorted 
  152.    --  model is undefined. In order to ensure that the 
  153.    --  Gtk.Tree_Sortable.Gtk_Tree_Sortable behaves as expected, the 
  154.    --  GtkTreeIterCompareFunc must define a partial order on the model, i.e. it 
  155.    --  must be reflexive, antisymmetric and transitive. 
  156.    --  For example, if Model is a product catalogue, then a compare function 
  157.    --  for the "price" column could be one which returns 'price_of(A) - 
  158.    --  price_of(B)'. 
  159.    --  "model": The Gtk.Tree_Model.Gtk_Tree_Model the comparison is within 
  160.    --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  161.    --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  162.  
  163.    ------------------ 
  164.    -- Constructors -- 
  165.    ------------------ 
  166.  
  167.    procedure Gtk_New_With_Model 
  168.       (Self        : out Gtk_Tree_Model_Sort; 
  169.        Child_Model : Gtk.Tree_Model.Gtk_Tree_Model); 
  170.    procedure Initialize_With_Model 
  171.       (Self        : not null access Gtk_Tree_Model_Sort_Record'Class; 
  172.        Child_Model : Gtk.Tree_Model.Gtk_Tree_Model); 
  173.    --  Creates a new Gtk.Tree_Model.Gtk_Tree_Model, with Child_Model as the 
  174.    --  child model. 
  175.    --  "child_model": A Gtk.Tree_Model.Gtk_Tree_Model 
  176.  
  177.    function Gtk_Tree_Model_Sort_Sort_New_With_Model 
  178.       (Child_Model : Gtk.Tree_Model.Gtk_Tree_Model) 
  179.        return Gtk_Tree_Model_Sort; 
  180.    --  Creates a new Gtk.Tree_Model.Gtk_Tree_Model, with Child_Model as the 
  181.    --  child model. 
  182.    --  "child_model": A Gtk.Tree_Model.Gtk_Tree_Model 
  183.  
  184.    function Get_Type return Glib.GType; 
  185.    pragma Import (C, Get_Type, "gtk_tree_model_sort_get_type"); 
  186.  
  187.    ------------- 
  188.    -- Methods -- 
  189.    ------------- 
  190.  
  191.    procedure Clear_Cache (Self : not null access Gtk_Tree_Model_Sort_Record); 
  192.    --  This function should almost never be called. It clears the 
  193.    --  Tree_Model_Sort of any cached iterators that haven't been reffed with 
  194.    --  Gtk.Tree_Model.Ref_Node. This might be useful if the child model being 
  195.    --  sorted is static (and doesn't change often) and there has been a lot of 
  196.    --  unreffed access to nodes. As a side effect of this function, all 
  197.    --  unreffed iters will be invalid. 
  198.  
  199.    function Convert_Child_Iter_To_Iter 
  200.       (Self       : not null access Gtk_Tree_Model_Sort_Record; 
  201.        Sort_Iter  : access Gtk.Tree_Model.Gtk_Tree_Iter; 
  202.        Child_Iter : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  203.    --  Sets Sort_Iter to point to the row in Tree_Model_Sort that corresponds 
  204.    --  to the row pointed at by Child_Iter. If Sort_Iter was not set, False is 
  205.    --  returned. Note: a boolean is only returned since 2.14. 
  206.    --  "sort_iter": An uninitialized Gtk.Tree_Model.Gtk_Tree_Iter. 
  207.    --  "child_iter": A valid Gtk.Tree_Model.Gtk_Tree_Iter pointing to a row on 
  208.    --  the child model 
  209.  
  210.    function Convert_Child_Path_To_Path 
  211.       (Self       : not null access Gtk_Tree_Model_Sort_Record; 
  212.        Child_Path : Gtk.Tree_Model.Gtk_Tree_Path) 
  213.        return Gtk.Tree_Model.Gtk_Tree_Path; 
  214.    --  Converts Child_Path to a path relative to Tree_Model_Sort. That is, 
  215.    --  Child_Path points to a path in the child model. The returned path will 
  216.    --  point to the same row in the sorted model. If Child_Path isn't a valid 
  217.    --  path on the child model, then null is returned. 
  218.    --  "child_path": A Gtk.Tree_Model.Gtk_Tree_Path to convert 
  219.  
  220.    procedure Convert_Iter_To_Child_Iter 
  221.       (Self        : not null access Gtk_Tree_Model_Sort_Record; 
  222.        Child_Iter  : out Gtk.Tree_Model.Gtk_Tree_Iter; 
  223.        Sorted_Iter : Gtk.Tree_Model.Gtk_Tree_Iter); 
  224.    --  Sets Child_Iter to point to the row pointed to by Sorted_Iter. 
  225.    --  "child_iter": An uninitialized Gtk.Tree_Model.Gtk_Tree_Iter 
  226.    --  "sorted_iter": A valid Gtk.Tree_Model.Gtk_Tree_Iter pointing to a row 
  227.    --  on Tree_Model_Sort. 
  228.  
  229.    function Convert_Path_To_Child_Path 
  230.       (Self        : not null access Gtk_Tree_Model_Sort_Record; 
  231.        Sorted_Path : Gtk.Tree_Model.Gtk_Tree_Path) 
  232.        return Gtk.Tree_Model.Gtk_Tree_Path; 
  233.    --  Converts Sorted_Path to a path on the child model of Tree_Model_Sort. 
  234.    --  That is, Sorted_Path points to a location in Tree_Model_Sort. The 
  235.    --  returned path will point to the same location in the model not being 
  236.    --  sorted. If Sorted_Path does not point to a location in the child model, 
  237.    --  null is returned. 
  238.    --  "sorted_path": A Gtk.Tree_Model.Gtk_Tree_Path to convert 
  239.  
  240.    function Get_Model 
  241.       (Self : not null access Gtk_Tree_Model_Sort_Record) 
  242.        return Gtk.Tree_Model.Gtk_Tree_Model; 
  243.    --  Returns the model the Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort is 
  244.    --  sorting. 
  245.  
  246.    function Iter_Is_Valid 
  247.       (Self : not null access Gtk_Tree_Model_Sort_Record; 
  248.        Iter : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  249.    --  <warning> 
  250.    --  This function is slow. Only use it for debugging and/or testing 
  251.    --  purposes. </warning> 
  252.    --  Checks if the given iter is a valid iter for this 
  253.    --  Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort. 
  254.    --  Since: gtk+ 2.2 
  255.    --  "iter": A Gtk.Tree_Model.Gtk_Tree_Iter. 
  256.  
  257.    procedure Reset_Default_Sort_Func 
  258.       (Self : not null access Gtk_Tree_Model_Sort_Record); 
  259.    --  This resets the default sort function to be in the 'unsorted' state. 
  260.    --  That is, it is in the same order as the child model. It will re-sort the 
  261.    --  model to be in the same order as the child model only if the 
  262.    --  Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort is in 'unsorted' state. 
  263.  
  264.    procedure Foreach 
  265.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  266.        Func       : Gtk_Tree_Model_Foreach_Func); 
  267.    --  Calls func on each node in model in a depth-first fashion. 
  268.    --  If Func returns True, then the tree ceases to be walked, and 
  269.    --  Gtk.Tree_Model.Foreach returns. 
  270.    --  "func": a function to be called on each row 
  271.  
  272.    generic 
  273.       type User_Data_Type (<>) is private; 
  274.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  275.    package Foreach_User_Data is 
  276.  
  277.       type Gtk_Tree_Model_Foreach_Func is access function 
  278.         (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  279.          Path  : Gtk.Tree_Model.Gtk_Tree_Path; 
  280.          Iter  : Gtk.Tree_Model.Gtk_Tree_Iter; 
  281.          Data  : User_Data_Type) return Boolean; 
  282.       --  Type of the callback passed to Gtk.Tree_Model.Foreach to iterate over 
  283.       --  the rows in a tree model. 
  284.       --  "model": the Gtk.Tree_Model.Gtk_Tree_Model being iterated 
  285.       --  "path": the current Gtk.Tree_Model.Gtk_Tree_Path 
  286.       --  "iter": the current Gtk.Tree_Model.Gtk_Tree_Iter 
  287.       --  "data": The user data passed to Gtk.Tree_Model.Foreach 
  288.  
  289.       procedure Foreach 
  290.          (Tree_Model : not null access Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort_Record'Class; 
  291.           Func       : Gtk_Tree_Model_Foreach_Func; 
  292.           User_Data  : User_Data_Type); 
  293.       --  Calls func on each node in model in a depth-first fashion. 
  294.       --  If Func returns True, then the tree ceases to be walked, and 
  295.       --  Gtk.Tree_Model.Foreach returns. 
  296.       --  "func": a function to be called on each row 
  297.       --  "user_data": user data to passed to Func 
  298.  
  299.    end Foreach_User_Data; 
  300.  
  301.    procedure Set_Default_Sort_Func 
  302.       (Sortable  : not null access Gtk_Tree_Model_Sort_Record; 
  303.        Sort_Func : Gtk_Tree_Iter_Compare_Func); 
  304.    --  Sets the default comparison function used when sorting to be Sort_Func. 
  305.    --  If the current sort column id of Sortable is 
  306.    --  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using 
  307.    --  this function. 
  308.    --  If Sort_Func is null, then there will be no default comparison 
  309.    --  function. This means that once the model has been sorted, it can't go 
  310.    --  back to the default state. In this case, when the current sort column id 
  311.    --  of Sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will 
  312.    --  be unsorted. 
  313.    --  "sort_func": The comparison function 
  314.  
  315.    generic 
  316.       type User_Data_Type (<>) is private; 
  317.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  318.    package Set_Default_Sort_Func_User_Data is 
  319.  
  320.       type Gtk_Tree_Iter_Compare_Func is access function 
  321.         (Model     : Gtk.Tree_Model.Gtk_Tree_Model; 
  322.          A         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  323.          B         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  324.          User_Data : User_Data_Type) return Gint; 
  325.       --  A GtkTreeIterCompareFunc should return a negative integer, zero, or a 
  326.       --  positive integer if A sorts before B, A sorts with B, or A sorts after B 
  327.       --  respectively. If two iters compare as equal, their order in the sorted 
  328.       --  model is undefined. In order to ensure that the 
  329.       --  Gtk.Tree_Sortable.Gtk_Tree_Sortable behaves as expected, the 
  330.       --  GtkTreeIterCompareFunc must define a partial order on the model, i.e. it 
  331.       --  must be reflexive, antisymmetric and transitive. 
  332.       --  For example, if Model is a product catalogue, then a compare function 
  333.       --  for the "price" column could be one which returns 'price_of(A) - 
  334.       --  price_of(B)'. 
  335.       --  "model": The Gtk.Tree_Model.Gtk_Tree_Model the comparison is within 
  336.       --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  337.       --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  338.       --  "user_data": Data passed when the compare func is assigned e.g. by 
  339.       --  Gtk.Tree_Sortable.Set_Sort_Func 
  340.  
  341.       procedure Set_Default_Sort_Func 
  342.          (Sortable  : not null access Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort_Record'Class; 
  343.           Sort_Func : Gtk_Tree_Iter_Compare_Func; 
  344.           User_Data : User_Data_Type); 
  345.       --  Sets the default comparison function used when sorting to be 
  346.       --  Sort_Func. If the current sort column id of Sortable is 
  347.       --  GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort 
  348.       --  using this function. 
  349.       --  If Sort_Func is null, then there will be no default comparison 
  350.       --  function. This means that once the model has been sorted, it can't go 
  351.       --  back to the default state. In this case, when the current sort column 
  352.       --  id of Sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model 
  353.       --  will be unsorted. 
  354.       --  "sort_func": The comparison function 
  355.       --  "user_data": User data to pass to Sort_Func, or null 
  356.  
  357.    end Set_Default_Sort_Func_User_Data; 
  358.  
  359.    procedure Set_Sort_Func 
  360.       (Sortable       : not null access Gtk_Tree_Model_Sort_Record; 
  361.        Sort_Column_Id : Gint; 
  362.        Sort_Func      : Gtk_Tree_Iter_Compare_Func); 
  363.    --  Sets the comparison function used when sorting to be Sort_Func. If the 
  364.    --  current sort column id of Sortable is the same as Sort_Column_Id, then 
  365.    --  the model will sort using this function. 
  366.    --  "sort_column_id": the sort column id to set the function for 
  367.    --  "sort_func": The comparison function 
  368.  
  369.    generic 
  370.       type User_Data_Type (<>) is private; 
  371.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  372.    package Set_Sort_Func_User_Data is 
  373.  
  374.       type Gtk_Tree_Iter_Compare_Func is access function 
  375.         (Model     : Gtk.Tree_Model.Gtk_Tree_Model; 
  376.          A         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  377.          B         : Gtk.Tree_Model.Gtk_Tree_Iter; 
  378.          User_Data : User_Data_Type) return Gint; 
  379.       --  A GtkTreeIterCompareFunc should return a negative integer, zero, or a 
  380.       --  positive integer if A sorts before B, A sorts with B, or A sorts after B 
  381.       --  respectively. If two iters compare as equal, their order in the sorted 
  382.       --  model is undefined. In order to ensure that the 
  383.       --  Gtk.Tree_Sortable.Gtk_Tree_Sortable behaves as expected, the 
  384.       --  GtkTreeIterCompareFunc must define a partial order on the model, i.e. it 
  385.       --  must be reflexive, antisymmetric and transitive. 
  386.       --  For example, if Model is a product catalogue, then a compare function 
  387.       --  for the "price" column could be one which returns 'price_of(A) - 
  388.       --  price_of(B)'. 
  389.       --  "model": The Gtk.Tree_Model.Gtk_Tree_Model the comparison is within 
  390.       --  "a": A Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  391.       --  "b": Another Gtk.Tree_Model.Gtk_Tree_Iter in Model 
  392.       --  "user_data": Data passed when the compare func is assigned e.g. by 
  393.       --  Gtk.Tree_Sortable.Set_Sort_Func 
  394.  
  395.       procedure Set_Sort_Func 
  396.          (Sortable       : not null access Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort_Record'Class; 
  397.           Sort_Column_Id : Gint; 
  398.           Sort_Func      : Gtk_Tree_Iter_Compare_Func; 
  399.           User_Data      : User_Data_Type); 
  400.       --  Sets the comparison function used when sorting to be Sort_Func. If 
  401.       --  the current sort column id of Sortable is the same as Sort_Column_Id, 
  402.       --  then the model will sort using this function. 
  403.       --  "sort_column_id": the sort column id to set the function for 
  404.       --  "sort_func": The comparison function 
  405.       --  "user_data": User data to pass to Sort_Func, or null 
  406.  
  407.    end Set_Sort_Func_User_Data; 
  408.  
  409.    --------------------------------------------- 
  410.    -- Inherited subprograms (from interfaces) -- 
  411.    --------------------------------------------- 
  412.  
  413.    function Drag_Data_Delete 
  414.       (Self : not null access Gtk_Tree_Model_Sort_Record; 
  415.        Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean; 
  416.  
  417.    function Drag_Data_Get 
  418.       (Self           : not null access Gtk_Tree_Model_Sort_Record; 
  419.        Path           : Gtk.Tree_Model.Gtk_Tree_Path; 
  420.        Selection_Data : Gtk.Selection_Data.Gtk_Selection_Data) 
  421.        return Boolean; 
  422.  
  423.    function Row_Draggable 
  424.       (Self : not null access Gtk_Tree_Model_Sort_Record; 
  425.        Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean; 
  426.  
  427.    function Get_Column_Type 
  428.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  429.        Index      : Gint) return GType; 
  430.  
  431.    function Get_Flags 
  432.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record) 
  433.        return Gtk.Tree_Model.Tree_Model_Flags; 
  434.  
  435.    function Get_Iter 
  436.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  437.        Path       : Gtk.Tree_Model.Gtk_Tree_Path) 
  438.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  439.  
  440.    function Get_Iter_First 
  441.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record) 
  442.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  443.  
  444.    function Get_Iter_From_String 
  445.       (Tree_Model  : not null access Gtk_Tree_Model_Sort_Record; 
  446.        Path_String : UTF8_String) return Gtk.Tree_Model.Gtk_Tree_Iter; 
  447.  
  448.    function Get_N_Columns 
  449.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record) return Gint; 
  450.  
  451.    function Get_Path 
  452.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  453.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) 
  454.        return Gtk.Tree_Model.Gtk_Tree_Path; 
  455.  
  456.    function Get_String_From_Iter 
  457.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  458.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) return UTF8_String; 
  459.  
  460.    procedure Get_Value 
  461.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  462.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  463.        Column     : Gint; 
  464.        Value      : out Glib.Values.GValue); 
  465.  
  466.    function Children 
  467.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  468.        Parent     : Gtk.Tree_Model.Gtk_Tree_Iter) 
  469.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  470.  
  471.    function Has_Child 
  472.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  473.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; 
  474.  
  475.    function N_Children 
  476.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  477.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter := Gtk.Tree_Model.Null_Iter) 
  478.        return Gint; 
  479.  
  480.    procedure Next 
  481.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  482.        Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  483.  
  484.    function Nth_Child 
  485.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  486.        Parent     : Gtk.Tree_Model.Gtk_Tree_Iter; 
  487.        N          : Gint) return Gtk.Tree_Model.Gtk_Tree_Iter; 
  488.  
  489.    function Parent 
  490.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  491.        Child      : Gtk.Tree_Model.Gtk_Tree_Iter) 
  492.        return Gtk.Tree_Model.Gtk_Tree_Iter; 
  493.  
  494.    procedure Previous 
  495.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  496.        Iter       : in out Gtk.Tree_Model.Gtk_Tree_Iter); 
  497.  
  498.    procedure Ref_Node 
  499.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  500.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  501.  
  502.    procedure Row_Changed 
  503.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  504.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  505.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  506.  
  507.    procedure Row_Deleted 
  508.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  509.        Path       : Gtk.Tree_Model.Gtk_Tree_Path); 
  510.  
  511.    procedure Row_Has_Child_Toggled 
  512.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  513.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  514.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  515.  
  516.    procedure Row_Inserted 
  517.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  518.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  519.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  520.  
  521.    procedure Rows_Reordered 
  522.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  523.        Path       : Gtk.Tree_Model.Gtk_Tree_Path; 
  524.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter; 
  525.        New_Order  : Gint_Array); 
  526.  
  527.    procedure Unref_Node 
  528.       (Tree_Model : not null access Gtk_Tree_Model_Sort_Record; 
  529.        Iter       : Gtk.Tree_Model.Gtk_Tree_Iter); 
  530.  
  531.    procedure Get_Sort_Column_Id 
  532.       (Sortable       : not null access Gtk_Tree_Model_Sort_Record; 
  533.        Sort_Column_Id : out Gint; 
  534.        Order          : out Gtk.Enums.Gtk_Sort_Type); 
  535.  
  536.    procedure Set_Sort_Column_Id 
  537.       (Sortable       : not null access Gtk_Tree_Model_Sort_Record; 
  538.        Sort_Column_Id : Gint; 
  539.        Order          : Gtk.Enums.Gtk_Sort_Type); 
  540.  
  541.    function Has_Default_Sort_Func 
  542.       (Sortable : not null access Gtk_Tree_Model_Sort_Record) return Boolean; 
  543.  
  544.    procedure Sort_Column_Changed 
  545.       (Sortable : not null access Gtk_Tree_Model_Sort_Record); 
  546.  
  547.    ---------------- 
  548.    -- Properties -- 
  549.    ---------------- 
  550.    --  The following properties are defined for this widget. See 
  551.    --  Glib.Properties for more information on properties) 
  552.  
  553.    Model_Property : constant Glib.Properties.Property_Interface; 
  554.    --  Type: Gtk.Tree_Model.Gtk_Tree_Model 
  555.  
  556.    ---------------- 
  557.    -- Interfaces -- 
  558.    ---------------- 
  559.    --  This class implements several interfaces. See Glib.Types 
  560.    -- 
  561.    --  - "TreeDragSource" 
  562.    -- 
  563.    --  - "TreeModel" 
  564.    -- 
  565.    --  - "TreeSortable" 
  566.  
  567.    package Implements_Gtk_Tree_Drag_Source is new Glib.Types.Implements 
  568.      (Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source, Gtk_Tree_Model_Sort_Record, Gtk_Tree_Model_Sort); 
  569.    function "+" 
  570.      (Widget : access Gtk_Tree_Model_Sort_Record'Class) 
  571.    return Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source 
  572.    renames Implements_Gtk_Tree_Drag_Source.To_Interface; 
  573.    function "-" 
  574.      (Interf : Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source) 
  575.    return Gtk_Tree_Model_Sort 
  576.    renames Implements_Gtk_Tree_Drag_Source.To_Object; 
  577.  
  578.    package Implements_Gtk_Tree_Model is new Glib.Types.Implements 
  579.      (Gtk.Tree_Model.Gtk_Tree_Model, Gtk_Tree_Model_Sort_Record, Gtk_Tree_Model_Sort); 
  580.    function "+" 
  581.      (Widget : access Gtk_Tree_Model_Sort_Record'Class) 
  582.    return Gtk.Tree_Model.Gtk_Tree_Model 
  583.    renames Implements_Gtk_Tree_Model.To_Interface; 
  584.    function "-" 
  585.      (Interf : Gtk.Tree_Model.Gtk_Tree_Model) 
  586.    return Gtk_Tree_Model_Sort 
  587.    renames Implements_Gtk_Tree_Model.To_Object; 
  588.  
  589.    package Implements_Gtk_Tree_Sortable is new Glib.Types.Implements 
  590.      (Gtk.Tree_Sortable.Gtk_Tree_Sortable, Gtk_Tree_Model_Sort_Record, Gtk_Tree_Model_Sort); 
  591.    function "+" 
  592.      (Widget : access Gtk_Tree_Model_Sort_Record'Class) 
  593.    return Gtk.Tree_Sortable.Gtk_Tree_Sortable 
  594.    renames Implements_Gtk_Tree_Sortable.To_Interface; 
  595.    function "-" 
  596.      (Interf : Gtk.Tree_Sortable.Gtk_Tree_Sortable) 
  597.    return Gtk_Tree_Model_Sort 
  598.    renames Implements_Gtk_Tree_Sortable.To_Object; 
  599.  
  600. private 
  601.    Model_Property : constant Glib.Properties.Property_Interface := 
  602.      Glib.Properties.Build ("model"); 
  603. end Gtk.Tree_Model_Sort;