A list model that filters the elements of another model.
It hides some elements from the underlying model according to criteria given by a GtkFilter.
The model can be set up to do incremental filtering, so that filtering long lists doesn't block the UI. See [methodGtk.FilterListModel.set_incremental] for details.
GtkFilterListModel passes through sections from the underlying model.
function "+"
(Widget : access Gtk_Filter_List_Model_Record'Class)
return Glib.List_Model.Glist_Model
function "+"
(Widget : access Gtk_Filter_List_Model_Record'Class)
return Gtk.Section_Model.Gtk_Section_Model
function "-"
(Interf : Glib.List_Model.Glist_Model)
return Gtk_Filter_List_Model
function "-"
(Interf : Gtk.Section_Model.Gtk_Section_Model)
return Gtk_Filter_List_Model
Filter_Property : constant Glib.Properties.Property_Object;
Type: Gtk.Filter.Gtk_Filter The filter for this model.
function Get_Filter
(Self : not null access Gtk_Filter_List_Model_Record)
return Gtk.Filter.Gtk_Filter
Gets the GtkFilter currently set on Self.
The filter currently in use. Has transfer-ownership='none'.
function Get_Incremental
(Self : not null access Gtk_Filter_List_Model_Record) return Boolean
Returns whether incremental filtering is enabled. See [methodGtk.FilterListModel.set_incremental].
True if incremental filtering is enabled
function Get_Item
(Self : not null access Gtk_Filter_List_Model_Record;
Position : Guint) return Glib.Object.GObject
function Get_Item_Type
(Self : not null access Gtk_Filter_List_Model_Record) return GType
function Get_Model
(Self : not null access Gtk_Filter_List_Model_Record)
return Glib.List_Model.Glist_Model
Gets the model currently filtered or null if none.
The model that gets filtered
function Get_N_Items
(Self : not null access Gtk_Filter_List_Model_Record) return Guint
function Get_Pending
(Self : not null access Gtk_Filter_List_Model_Record) return Guint
Returns the number of items that have not been filtered yet. You can use this value to check if Self is busy filtering by comparing the return value to 0 or you can compute the percentage of the filter remaining by dividing the return value by the total number of items in the underlying model:
gtk_filter_list_model_get_model (self); percentage = pending / (double)
g_list_model_get_n_items (model); ```
If no filter operation is ongoing - in particular when
[propertyGtk.FilterListModel:incremental] is False - this function
returns 0.
The number of items not yet filtered
procedure Get_Section
(Self : not null access Gtk_Filter_List_Model_Record;
Position : Guint;
Out_Start : out Guint;
Out_End : out Guint)
function Get_Type return Glib.GType
function Get_Watch_Items
(Self : not null access Gtk_Filter_List_Model_Record) return Boolean
Returns whether watching items is enabled. See [methodGtk.FilterListModel.set_watch_items]. Since: gtk+ 4.20
True if watching items is enabled
type Gtk_Filter_List_Model is access all Gtk_Filter_List_Model_Record'Class;
function Gtk_Filter_List_Model_New
(Model : Glib.List_Model.Glist_Model;
Filter : access Gtk.Filter.Gtk_Filter_Record'Class)
return Gtk_Filter_List_Model
Creates a new GtkFilterListModel that will filter Model using the given Filter.
the model to sort
filter. Has transfer-ownership='full'.
type Gtk_Filter_List_Model_Record is new GObject_Record with null record;
procedure Gtk_New
(Self : out Gtk_Filter_List_Model;
Model : Glib.List_Model.Glist_Model;
Filter : access Gtk.Filter.Gtk_Filter_Record'Class)
Creates a new GtkFilterListModel that will filter Model using the given Filter. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the model to sort
filter. Has transfer-ownership='full'.
package Implements_Glist_Model is new Glib.Types.Implements
(Glib.List_Model.Glist_Model, Gtk_Filter_List_Model_Record, Gtk_Filter_List_Model);
package Implements_Gtk_Section_Model is new Glib.Types.Implements
(Gtk.Section_Model.Gtk_Section_Model, Gtk_Filter_List_Model_Record, Gtk_Filter_List_Model);
Incremental_Property : constant Glib.Properties.Property_Boolean;
If the model should filter items incrementally.
procedure Initialize
(Self : not null access Gtk_Filter_List_Model_Record'Class;
Model : Glib.List_Model.Glist_Model;
Filter : access Gtk.Filter.Gtk_Filter_Record'Class)
Creates a new GtkFilterListModel that will filter Model using the given Filter. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the model to sort
filter. Has transfer-ownership='full'.
Item_Type_Property : constant Glib.Properties.Property_Boxed;
Type: GType The type of items. See [methodGio.ListModel.get_item_type].
procedure Items_Changed
(Self : not null access Gtk_Filter_List_Model_Record;
Position : Guint;
Removed : Guint;
Added : Guint)
Model_Property : constant Glib.Properties.Property_Boxed;
Type: Gio.List_Model The model being filtered.
N_Items_Property : constant Glib.Properties.Property_Uint;
The number of items. See [methodGio.ListModel.get_n_items].
Pending_Property : constant Glib.Properties.Property_Uint;
Number of items not yet filtered.
procedure Sections_Changed
(Self : not null access Gtk_Filter_List_Model_Record;
Position : Guint;
N_Items : Guint)
procedure Set_Filter
(Self : not null access Gtk_Filter_List_Model_Record;
Filter : access Gtk.Filter.Gtk_Filter_Record'Class)
Sets the filter used to filter items.
filter to use
procedure Set_Incremental
(Self : not null access Gtk_Filter_List_Model_Record;
Incremental : Boolean)
Sets the filter model to do an incremental sort. When incremental filtering is enabled, the GtkFilterListModel will not run filters immediately, but will instead queue an idle handler that incrementally filters the items and adds them to the list. This of course means that items are not instantly added to the list, but only appear incrementally. When your filter blocks the UI while filtering, you might consider turning this on. Depending on your model and filters, this may become interesting around 10,000 to 100,000 items. By default, incremental filtering is disabled. See [methodGtk.FilterListModel.get_pending] for progress information about an ongoing incremental filtering operation.
True to enable incremental filtering
procedure Set_Model
(Self : not null access Gtk_Filter_List_Model_Record;
Model : Glib.List_Model.Glist_Model)
Sets the model to be filtered. Note that GTK makes no effort to ensure that Model conforms to the item type of Self. It assumes that the caller knows what they are doing and have set up an appropriate filter to ensure that item types match.
The model to be filtered
procedure Set_Watch_Items
(Self : not null access Gtk_Filter_List_Model_Record;
Watch_Items : Boolean)
Sets the filter model to monitor properties of its items. This allows implementations of [classGtk.Filter] that support expression watching to react to property changes. This property has no effect if the current filter doesn't support watching items. By default, watching items is disabled. Since: gtk+ 4.20
True to watch items for property changes
Watch_Items_Property : constant Glib.Properties.Property_Boolean;
Monitor the list items for changes. It may impact performance.