GtkFilterListModel — A list model that filters its items
GtkFilterListModel * | gtk_filter_list_model_new () |
void | gtk_filter_list_model_set_model () |
GListModel * | gtk_filter_list_model_get_model () |
void | gtk_filter_list_model_set_filter () |
GtkFilter * | gtk_filter_list_model_get_filter () |
void | gtk_filter_list_model_set_incremental () |
gboolean | gtk_filter_list_model_get_incremental () |
guint | gtk_filter_list_model_get_pending () |
GtkFilter * | filter | Read / Write |
gboolean | incremental | Read / Write |
GListModel * | model | Read / Write |
guint | pending | Read |
GObject ╰── GtkFilterListModel
GtkFilterListModel implements GListModel.
#include <gtk/gtk.h>
GtkFilterListModel is a list model that filters a given other listmodel. It hides some elements from the other model according to criteria given by a GtkFilter.
The model can be set up to do incremental searching, so that filtering long lists doesn't block the UI. See gtk_filter_list_model_set_incremental()
for details.
GtkFilterListModel * gtk_filter_list_model_new (GListModel *model
,GtkFilter *filter
);
Creates a new GtkFilterListModel that will filter model
using the given filter
.
model | the model to sort, or | [allow-none][transfer full] |
filter | filter or | [allow-none][transfer full] |
a new GtkFilterListModel
void gtk_filter_list_model_set_model (GtkFilterListModel *self
,GListModel *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.
self | ||
model | The model to be filtered. | [allow-none] |
GListModel *
gtk_filter_list_model_get_model (GtkFilterListModel *self
);
Gets the model currently filtered or NULL
if none.
self |
The model that gets filtered.
[nullable][transfer none]
void gtk_filter_list_model_set_filter (GtkFilterListModel *self
,GtkFilter *filter
);
Sets the filter used to filter items.
self | ||
filter | filter to use or | [allow-none][transfer none] |
GtkFilter *
gtk_filter_list_model_get_filter (GtkFilterListModel *self
);
Gets the GtkFilter currently set on self
.
self |
The filter currently in use or NULL
if the list isn't filtered.
[nullable][transfer none]
void gtk_filter_list_model_set_incremental (GtkFilterListModel *self
,gboolean incremental
);
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 gtk_filter_list_model_get_pending()
for progress information about an ongoing incremental filtering operation.
self | ||
incremental |
|
gboolean
gtk_filter_list_model_get_incremental (GtkFilterListModel *self
);
Returns whether incremental filtering was enabled via gtk_filter_list_model_set_incremental()
.
self |
TRUE
if incremental filtering is enabled
guint
gtk_filter_list_model_get_pending (GtkFilterListModel *self
);
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:
pending = gtk_filter_list_model_get_pending (self); 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 “incremental” is FALSE
- this function returns 0.
self |
The number of items not yet filtered
typedef struct _GtkFilterListModel GtkFilterListModel;
“filter”
property“filter” GtkFilter *
The filter for this model
Owner: GtkFilterListModel
Flags: Read / Write
“incremental”
property“incremental” gboolean
If the model should filter items incrementally
Owner: GtkFilterListModel
Flags: Read / Write
Default value: FALSE
“model”
property“model” GListModel *
The model being filtered
Owner: GtkFilterListModel
Flags: Read / Write
“pending”
property“pending” guint
Number of items not yet filtered
Owner: GtkFilterListModel
Flags: Read
Default value: 0
GListModel, GtkFilter
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkFilterListModel.html