package Implements_Gtk_Tree_Drag_Source is new Glib.Types.Implements (Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source, Gtk_Tree_Model_Filter_Record, Gtk_Tree_Model_Filter);
package Implements_Gtk_Tree_Model is new Glib.Types.Implements (Gtk.Tree_Model.Gtk_Tree_Model, Gtk_Tree_Model_Filter_Record, Gtk_Tree_Model_Filter);
type Gtk_Tree_Model_Filter_Record is new Gtk_Root_Tree_Model_Record with null record;
type Gtk_Tree_Model_Filter is access all Gtk_Tree_Model_Filter_Record'Class;
type Gtk_Tree_Model_Filter_Modify_Func is access procedure (Model : Gtk.Tree_Model.Gtk_Tree_Model; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Value : in out Glib.Values.GValue; Column : Gint);
type Gtk_Tree_Model_Filter_Visible_Func is access function (Model : Gtk.Tree_Model.Gtk_Tree_Model; Iter : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean;
type Gtk_Tree_Model_Foreach_Func is access function (Model : Gtk.Tree_Model.Gtk_Tree_Model; Path : Gtk.Tree_Model.Gtk_Tree_Path; Iter : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean;
Child_Model_Property : constant Glib.Properties.Property_Interface;
Virtual_Root_Property : constant Glib.Properties.Property_Object;
procedure Gtk_New
( | Self | : out Gtk_Tree_Model_Filter; |
Child_Model | : Gtk.Tree_Model.Gtk_Tree_Model; | |
Root | : Gtk.Tree_Model.Gtk_Tree_Path := Null_Gtk_Tree_Path); |
procedure Initialize
( | Self | : not null access Gtk_Tree_Model_Filter_Record'Class; |
Child_Model | : Gtk.Tree_Model.Gtk_Tree_Model; | |
Root | : Gtk.Tree_Model.Gtk_Tree_Path := Null_Gtk_Tree_Path); |
function Gtk_Tree_Model_Filter_Filter_New
( | Child_Model | : Gtk.Tree_Model.Gtk_Tree_Model; |
Root | : Gtk.Tree_Model.Gtk_Tree_Path := Null_Gtk_Tree_Path) return Gtk_Tree_Model_Filter; |
function Get_Type return Glib.GType;
procedure Clear_Cache
( | Self | : not null access Gtk_Tree_Model_Filter_Record); |
procedure Convert_Child_Iter_To_Iter
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Filter_Iter | : out Gtk.Tree_Model.Gtk_Tree_Iter; | |
Child_Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
function Convert_Child_Path_To_Path
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Child_Path | : Gtk.Tree_Model.Gtk_Tree_Path) return Gtk.Tree_Model.Gtk_Tree_Path; |
procedure Convert_Iter_To_Child_Iter
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Child_Iter | : out Gtk.Tree_Model.Gtk_Tree_Iter; | |
Filter_Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
function Convert_Path_To_Child_Path
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Filter_Path | : Gtk.Tree_Model.Gtk_Tree_Path) return Gtk.Tree_Model.Gtk_Tree_Path; |
function Get_Model
( | Self | : not null access Gtk_Tree_Model_Filter_Record) return Gtk.Tree_Model.Gtk_Tree_Model; |
procedure Refilter
( | Self | : not null access Gtk_Tree_Model_Filter_Record); |
procedure Set_Modify_Func
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Types | : Glib.GType_Array; | |
Func | : Gtk_Tree_Model_Filter_Modify_Func); |
procedure Set_Visible_Column
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Column | : Gint); |
procedure Set_Visible_Func
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Func | : Gtk_Tree_Model_Filter_Visible_Func); |
procedure Foreach
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Func | : Gtk_Tree_Model_Foreach_Func); |
function Drag_Data_Delete
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean; |
function Drag_Data_Get
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path; | |
Selection_Data | : Gtk.Selection_Data.Gtk_Selection_Data) return Boolean; |
function Row_Draggable
( | Self | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean; |
function Get_Column_Type
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Index | : Gint) return GType; |
function Get_Flags
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record) return Gtk.Tree_Model.Tree_Model_Flags; |
function Get_Iter
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path) return Gtk.Tree_Model.Gtk_Tree_Iter; |
function Get_Iter_First
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record) return Gtk.Tree_Model.Gtk_Tree_Iter; |
function Get_Iter_From_String
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path_String | : UTF8_String) return Gtk.Tree_Model.Gtk_Tree_Iter; |
function Get_N_Columns
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record) return Gint; |
function Get_Path
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter) return Gtk.Tree_Model.Gtk_Tree_Path; |
function Get_String_From_Iter
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter) return UTF8_String; |
procedure Get_Value
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter; | |
Column | : Gint; | |
Value | : out Glib.Values.GValue); |
function Children
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Parent | : Gtk.Tree_Model.Gtk_Tree_Iter) return Gtk.Tree_Model.Gtk_Tree_Iter; |
function Has_Child
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; |
function N_Children
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter := Gtk.Tree_Model.Null_Iter) return Gint; |
procedure Next
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : in out Gtk.Tree_Model.Gtk_Tree_Iter); |
function Nth_Child
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Parent | : Gtk.Tree_Model.Gtk_Tree_Iter; | |
N | : Gint) return Gtk.Tree_Model.Gtk_Tree_Iter; |
function Parent
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Child | : Gtk.Tree_Model.Gtk_Tree_Iter) return Gtk.Tree_Model.Gtk_Tree_Iter; |
procedure Previous
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : in out Gtk.Tree_Model.Gtk_Tree_Iter); |
procedure Ref_Node
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
procedure Row_Changed
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path; | |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
procedure Row_Deleted
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path); |
procedure Row_Has_Child_Toggled
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path; | |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
procedure Row_Inserted
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path; | |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
procedure Rows_Reordered
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Path | : Gtk.Tree_Model.Gtk_Tree_Path; | |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter; | |
New_Order | : Gint_Array); |
procedure Unref_Node
( | Tree_Model | : not null access Gtk_Tree_Model_Filter_Record; |
Iter | : Gtk.Tree_Model.Gtk_Tree_Iter); |
function "+"
( | Widget | : access Gtk_Tree_Model_Filter_Record'Class) return Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source renames Implements_Gtk_Tree_Drag_Source.To_Interface; |
function "-"
( | Interf | : Gtk.Tree_Drag_Source.Gtk_Tree_Drag_Source) return Gtk_Tree_Model_Filter renames Implements_Gtk_Tree_Drag_Source.To_Object; |
function "+"
( | Widget | : access Gtk_Tree_Model_Filter_Record'Class) return Gtk.Tree_Model.Gtk_Tree_Model renames Implements_Gtk_Tree_Model.To_Interface; |
function "-"
( | Interf | : Gtk.Tree_Model.Gtk_Tree_Model) return Gtk_Tree_Model_Filter renames Implements_Gtk_Tree_Model.To_Object; |
A Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter is a tree model which wraps another tree model, and can do the following things: * Filter specific rows, based on data from a "visible column", a column storing booleans indicating whether the row should be filtered or not, or based on the return value of a "visible function", which gets a model, iter and user_data and returns a boolean indicating whether the row should be filtered or not. * Modify the "appearance" of the model, using a modify function. This is extremely powerful and allows for just changing some values and also for creating a completely different model based on the given child model. * Set a different root node, also known as a "virtual root". You can pass in a Gtk.Tree_Model.Gtk_Tree_Path indicating the root node for the filter at construction time.
The basic API is similar to Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort. For an example on its usage, see the section on Gtk.Tree_Model_Sort.Gtk_Tree_Model_Sort.
When using Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter, it is important to realize that Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter maintains an internal cache of all nodes which are visible in its clients. The cache is likely to be a subtree of the tree exposed by the child model.
Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter will not cache the entire child model when unnecessary to not compromise the caching mechanism that is exposed by the reference counting scheme. If the child model implements reference counting, unnecessary signals may not be emitted because of reference counting rule 3, see the Gtk.Tree_Model.Gtk_Tree_Model documentation. (Note that e.g. Gtk.Tree_Store.Gtk_Tree_Store does not implement reference counting and will always emit all signals, even when the receiving node is not visible).
Because of this, limitations for possible visible functions do apply. In general, visible functions should only use data or properties from the node for which the visibility state must be determined, its siblings or its parents. Usually, having a dependency on the state of any child node is not possible, unless references are taken on these explicitly. When no such reference exists, no signals may be received for these child nodes (see reference couting rule number 3 in the Gtk.Tree_Model.Gtk_Tree_Model section).
Determining the visibility state of a given node based on the state of its child nodes is a frequently occurring use case. Therefore, Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter explicitly supports this. For example, when a node does not have any children, you might not want the node to be visible. As soon as the first row is added to the node's child level (or the last row removed), the node's visibility should be updated.
This introduces a dependency from the node on its child nodes. In order to accommodate this, Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter must make sure the necesary signals are received from the child model. This is achieved by building, for all nodes which are exposed as visible nodes to Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter's clients, the child level (if any) and take a reference on the first node in this level. Furthermore, for every row-inserted, row-changed or row-deleted signal (also these which were not handled because the node was not cached), Gtk.Tree_Model_Filter.Gtk_Tree_Model_Filter will check if the visibility state of any parent node has changed.
Beware, however, that this explicit support is limited to these two cases.
For example, if you want a node to be visible only if two nodes in a child's child level (2 levels deeper) are visible, you are on your own. In this case, either rely on Gtk.Tree_Store.Gtk_Tree_Store to emit all signals because it does not implement reference counting, or for models that do implement reference counting, obtain references on these child levels yourself.