GtkFilterListModel

GtkFilterListModel — A list model that filters its items

Functions

Properties

gboolean has-filter Read
GType * item-type Read / Write / Construct Only
GListModel * model Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── GtkFilterListModel

Implemented Interfaces

GtkFilterListModel implements GListModel.

Includes

#include <gtk/gtk.h>

Description

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 GtkFilterListModelFilterFunc.

Functions

gtk_filter_list_model_new ()

GtkFilterListModel *
gtk_filter_list_model_new (GListModel *model,
                           GtkFilterListModelFilterFunc filter_func,
                           gpointer user_data,
                           GDestroyNotify user_destroy);

Creates a new GtkFilterListModel that will filter model using the given filter_func .

Parameters

model

the model to sort

 

filter_func

filter function or NULL to not filter items.

[allow-none]

user_data

user data passed to filter_func .

[closure]

user_destroy

destroy notifier for user_data

 

Returns

a new GtkFilterListModel


gtk_filter_list_model_new_for_type ()

GtkFilterListModel *
gtk_filter_list_model_new_for_type (GType item_type);

Creates a new empty filter list model set up to return items of type item_type . It is up to the application to set a proper filter function and model to ensure the item type is matched.

Parameters

item_type

the type of the items that will be returned

 

Returns

a new GtkFilterListModel


gtk_filter_list_model_set_model ()

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 function to ensure that item types match.

Parameters

self

a GtkFilterListModel

 

model

The model to be filtered.

[allow-none]

gtk_filter_list_model_get_model ()

GListModel *
gtk_filter_list_model_get_model (GtkFilterListModel *self);

Gets the model currently filtered or NULL if none.

Parameters

self

a GtkFilterListModel

 

Returns

The model that gets filtered.

[nullable][transfer none]


gtk_filter_list_model_set_filter_func ()

void
gtk_filter_list_model_set_filter_func (GtkFilterListModel *self,
                                       GtkFilterListModelFilterFunc filter_func,
                                       gpointer user_data,
                                       GDestroyNotify user_destroy);

Sets the function used to filter items. The function will be called for every item and if it returns TRUE the item is considered visible.

Parameters

self

a GtkFilterListModel

 

filter_func

filter function or NULL to not filter items.

[allow-none]

user_data

user data passed to filter_func .

[closure]

user_destroy

destroy notifier for user_data

 

gtk_filter_list_model_has_filter ()

gboolean
gtk_filter_list_model_has_filter (GtkFilterListModel *self);

Checks if a filter function is currently set on self

Parameters

self

a GtkFilterListModel

 

Returns

TRUE if a filter function is set


gtk_filter_list_model_refilter ()

void
gtk_filter_list_model_refilter (GtkFilterListModel *self);

Causes self to refilter all items in the model.

Calling this function is necessary when data used by the filter function has changed.

Parameters

self

a GtkFilterListModel

 

Property Details

The “has-filter” property

  “has-filter”               gboolean

If a filter is set for this model

Owner: GtkFilterListModel

Flags: Read

Default value: FALSE


The “item-type” property

  “item-type”                GType *

The GType for elements of this object

Owner: GtkFilterListModel

Flags: Read / Write / Construct Only

Allowed values: GObject


The “model” property

  “model”                    GListModel *

The model being filtered

Owner: GtkFilterListModel

Flags: Read / Write / Construct Only

See Also

GListModel