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. --  A GtkTreeRowReference tracks model changes so that it always refers to the 
  26. --  same row (a Gtk.Tree_Model.Gtk_Tree_Path refers to a position, not a fixed 
  27. --  row). Create a new GtkTreeRowReference with gtk_tree_row_reference_new. 
  28. -- 
  29. --  </description> 
  30. pragma Ada_2005; 
  31.  
  32. pragma Warnings (Off, "*is already use-visible*"); 
  33. with Glib;           use Glib; 
  34. with Glib.Object;    use Glib.Object; 
  35. with Gtk.Tree_Model; use Gtk.Tree_Model; 
  36.  
  37. package Gtk.Tree_Row_Reference is 
  38.  
  39.    type Gtk_Tree_Row_Reference is new Glib.C_Boxed with null record; 
  40.    Null_Gtk_Tree_Row_Reference : constant Gtk_Tree_Row_Reference; 
  41.  
  42.    function From_Object (Object : System.Address) return Gtk_Tree_Row_Reference; 
  43.    function From_Object_Free (B : access Gtk_Tree_Row_Reference'Class) return Gtk_Tree_Row_Reference; 
  44.    pragma Inline (From_Object_Free, From_Object); 
  45.  
  46.    ------------------ 
  47.    -- Constructors -- 
  48.    ------------------ 
  49.  
  50.    procedure Gtk_New 
  51.       (Reference : out Gtk_Tree_Row_Reference; 
  52.        Model     : Gtk.Tree_Model.Gtk_Tree_Model; 
  53.        Path      : Gtk.Tree_Model.Gtk_Tree_Path); 
  54.    --  Creates a row reference based on Path. 
  55.    --  This reference will keep pointing to the node pointed to by Path, so 
  56.    --  long as it exists. Any changes that occur on Model are propagated, and 
  57.    --  the path is updated appropriately. If Path isn't a valid path in Model, 
  58.    --  then null is returned. 
  59.    --  "model": a Gtk.Tree_Model.Gtk_Tree_Model 
  60.    --  "path": a valid Gtk.Tree_Model.Gtk_Tree_Path to monitor 
  61.  
  62.    function Gtk_Tree_Row_Reference_New 
  63.       (Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  64.        Path  : Gtk.Tree_Model.Gtk_Tree_Path) return Gtk_Tree_Row_Reference; 
  65.    --  Creates a row reference based on Path. 
  66.    --  This reference will keep pointing to the node pointed to by Path, so 
  67.    --  long as it exists. Any changes that occur on Model are propagated, and 
  68.    --  the path is updated appropriately. If Path isn't a valid path in Model, 
  69.    --  then null is returned. 
  70.    --  "model": a Gtk.Tree_Model.Gtk_Tree_Model 
  71.    --  "path": a valid Gtk.Tree_Model.Gtk_Tree_Path to monitor 
  72.  
  73.    procedure Gtk_New_Proxy 
  74.       (Reference : out Gtk_Tree_Row_Reference; 
  75.        Proxy     : not null access Glib.Object.GObject_Record'Class; 
  76.        Model     : Gtk.Tree_Model.Gtk_Tree_Model; 
  77.        Path      : Gtk.Tree_Model.Gtk_Tree_Path); 
  78.    --  You do not need to use this function. 
  79.    --  Creates a row reference based on Path. 
  80.    --  This reference will keep pointing to the node pointed to by Path, so 
  81.    --  long as it exists. If Path isn't a valid path in Model, then null is 
  82.    --  returned. However, unlike references created with 
  83.    --  gtk_tree_row_reference_new, it does not listen to the model for changes. 
  84.    --  The creator of the row reference must do this explicitly using 
  85.    --  Gtk.Tree_Row_Reference.Inserted, Gtk.Tree_Row_Reference.Deleted, 
  86.    --  Gtk.Tree_Row_Reference.Reordered. 
  87.    --  These functions must be called exactly once per proxy when the 
  88.    --  corresponding signal on the model is emitted. This single call updates 
  89.    --  all row references for that proxy. Since built-in GTK+ objects like 
  90.    --  Gtk.Tree_View.Gtk_Tree_View already use this mechanism internally, using 
  91.    --  them as the proxy object will produce unpredictable results. Further 
  92.    --  more, passing the same object as Model and Proxy doesn't work for 
  93.    --  reasons of internal implementation. 
  94.    --  This type of row reference is primarily meant by structures that need 
  95.    --  to carefully monitor exactly when a row reference updates itself, and is 
  96.    --  not generally needed by most applications. 
  97.    --  "proxy": a proxy Glib.Object.GObject 
  98.    --  "model": a Gtk.Tree_Model.Gtk_Tree_Model 
  99.    --  "path": a valid Gtk.Tree_Model.Gtk_Tree_Path to monitor 
  100.  
  101.    function Gtk_Tree_Row_Reference_New_Proxy 
  102.       (Proxy : not null access Glib.Object.GObject_Record'Class; 
  103.        Model : Gtk.Tree_Model.Gtk_Tree_Model; 
  104.        Path  : Gtk.Tree_Model.Gtk_Tree_Path) return Gtk_Tree_Row_Reference; 
  105.    --  You do not need to use this function. 
  106.    --  Creates a row reference based on Path. 
  107.    --  This reference will keep pointing to the node pointed to by Path, so 
  108.    --  long as it exists. If Path isn't a valid path in Model, then null is 
  109.    --  returned. However, unlike references created with 
  110.    --  gtk_tree_row_reference_new, it does not listen to the model for changes. 
  111.    --  The creator of the row reference must do this explicitly using 
  112.    --  Gtk.Tree_Row_Reference.Inserted, Gtk.Tree_Row_Reference.Deleted, 
  113.    --  Gtk.Tree_Row_Reference.Reordered. 
  114.    --  These functions must be called exactly once per proxy when the 
  115.    --  corresponding signal on the model is emitted. This single call updates 
  116.    --  all row references for that proxy. Since built-in GTK+ objects like 
  117.    --  Gtk.Tree_View.Gtk_Tree_View already use this mechanism internally, using 
  118.    --  them as the proxy object will produce unpredictable results. Further 
  119.    --  more, passing the same object as Model and Proxy doesn't work for 
  120.    --  reasons of internal implementation. 
  121.    --  This type of row reference is primarily meant by structures that need 
  122.    --  to carefully monitor exactly when a row reference updates itself, and is 
  123.    --  not generally needed by most applications. 
  124.    --  "proxy": a proxy Glib.Object.GObject 
  125.    --  "model": a Gtk.Tree_Model.Gtk_Tree_Model 
  126.    --  "path": a valid Gtk.Tree_Model.Gtk_Tree_Path to monitor 
  127.  
  128.    function Get_Type return Glib.GType; 
  129.    pragma Import (C, Get_Type, "gtk_tree_row_reference_get_type"); 
  130.  
  131.    ------------- 
  132.    -- Methods -- 
  133.    ------------- 
  134.  
  135.    function Copy 
  136.       (Reference : Gtk_Tree_Row_Reference) return Gtk_Tree_Row_Reference; 
  137.    --  Copies a Gtk.Tree_Row_Reference.Gtk_Tree_Row_Reference. 
  138.    --  Since: gtk+ 2.2 
  139.  
  140.    procedure Free (Reference : Gtk_Tree_Row_Reference); 
  141.    --  Free's Reference. Reference may be null 
  142.  
  143.    function Get_Model 
  144.       (Reference : Gtk_Tree_Row_Reference) 
  145.        return Gtk.Tree_Model.Gtk_Tree_Model; 
  146.    --  Returns the model that the row reference is monitoring. 
  147.    --  Since: gtk+ 2.8 
  148.  
  149.    function Get_Path 
  150.       (Reference : Gtk_Tree_Row_Reference) 
  151.        return Gtk.Tree_Model.Gtk_Tree_Path; 
  152.    --  Returns a path that the row reference currently points to, or null if 
  153.    --  the path pointed to is no longer valid. 
  154.  
  155.    function Valid (Reference : Gtk_Tree_Row_Reference) return Boolean; 
  156.    --  Returns True if the Reference is non-null and refers to a current valid 
  157.    --  path. 
  158.  
  159.    --------------- 
  160.    -- Functions -- 
  161.    --------------- 
  162.  
  163.    procedure Deleted 
  164.       (Proxy : not null access Glib.Object.GObject_Record'Class; 
  165.        Path  : Gtk.Tree_Model.Gtk_Tree_Path); 
  166.    --  Lets a set of row reference created by gtk_tree_row_reference_new_proxy 
  167.    --  know that the model emitted the 
  168.    --  Gtk.Tree_Model.Gtk_Tree_Model::row-deleted signal. 
  169.    --  "proxy": a Glib.Object.GObject 
  170.    --  "path": the path position that was deleted 
  171.  
  172.    procedure Inserted 
  173.       (Proxy : not null access Glib.Object.GObject_Record'Class; 
  174.        Path  : Gtk.Tree_Model.Gtk_Tree_Path); 
  175.    --  Lets a set of row reference created by gtk_tree_row_reference_new_proxy 
  176.    --  know that the model emitted the 
  177.    --  Gtk.Tree_Model.Gtk_Tree_Model::row-inserted signal. 
  178.    --  "proxy": a Glib.Object.GObject 
  179.    --  "path": the row position that was inserted 
  180.  
  181.    procedure Reordered 
  182.       (Proxy     : not null access Glib.Object.GObject_Record'Class; 
  183.        Path      : Gtk.Tree_Model.Gtk_Tree_Path; 
  184.        Iter      : Gtk.Tree_Model.Gtk_Tree_Iter; 
  185.        New_Order : in out Gint); 
  186.    --  Lets a set of row reference created by gtk_tree_row_reference_new_proxy 
  187.    --  know that the model emitted the 
  188.    --  Gtk.Tree_Model.Gtk_Tree_Model::rows-reordered signal. 
  189.    --  "proxy": a Glib.Object.GObject 
  190.    --  "path": the parent path of the reordered signal 
  191.    --  "iter": the iter pointing to the parent of the reordered 
  192.    --  "new_order": the new order of rows 
  193.  
  194. private 
  195.  
  196.    Null_Gtk_Tree_Row_Reference : constant Gtk_Tree_Row_Reference := (Glib.C_Boxed with null record); 
  197.  
  198. end Gtk.Tree_Row_Reference;