### Interface

# Gtk SectionModel

since: 4.12

#### Description [src]

    interface Gtk.SectionModel : Gio.ListModel

An interface that adds support for sections to list models.

A `GtkSectionModel` groups successive items into so-called sections. List widgets like `GtkListView` and `GtkGridView` then allow displaying section headers for these sections by installing a header factory.

Many GTK list models support sections inherently, or they pass through the sections of a model they are wrapping.

When the section groupings of a model change, the model will emit the `GtkSectionModel::sections-changed` signal by calling the `gtk_section_model_sections_changed()` function. All sections in the given range then need to be queried again. The `GListModel::items-changed` signal has the same effect, all sections in that range are invalidated, too.

Available since: 4.12

#### Prerequisite

In order to implement SectionModel, your type must inherit from`GListModel`.

#### Implementations

- GtkFilterListModel
- GtkFlattenListModel
- GtkMapListModel
- GtkMultiSelection
- GtkNoSelection
- GtkSingleSelection
- GtkSliceListModel
- GtkSortListModel

#### Instance methods

###### gtk_section_model_get_section

Query the section that covers the given position. The number of items in the section can be computed by `out_end - out_start`.

since: 4.12

###### gtk_section_model_sections_changed

This function emits the `GtkSectionModel::sections-changed` signal to notify about changes to sections.

since: 4.12

#### Signals

###### Gtk.SectionModel::sections-changed

Emitted when the start-of-section state of some of the items in `model` changes.

since: 4.12

#### Interface structure

    struct GtkSectionModelInterface {
      void (* get_section) (
        GtkSectionModel* self,
        guint position,
        guint* out_start,
        guint* out_end
      );

    }

The list of virtual functions for the `GtkSectionModel` interface. No function must be implemented, but unless `GtkSectionModel::get_section()` is implemented, the whole model will just be a single section.

###### Interface members

`get_section`

    void (* get_section) (
        GtkSectionModel* self,
        guint position,
        guint* out_start,
        guint* out_end
      )

| Return the section that covers the given position. If the position is outside the number of items, returns a single range from n_items to G_MAXUINT.

#### Virtual methods

###### Gtk.SectionModel.get_section

Query the section that covers the given position. The number of items in the section can be computed by `out_end - out_start`.

since: 4.12