Gtk.SliceListModel

g GObject.GInterface GObject.GInterface Gio.ListModel Gio.ListModel GObject.GInterface->Gio.ListModel Gtk.SectionModel Gtk.SectionModel GObject.GInterface->Gtk.SectionModel GObject.Object GObject.Object Gtk.SliceListModel Gtk.SliceListModel GObject.Object->Gtk.SliceListModel Gio.ListModel->Gtk.SliceListModel Gtk.SectionModel->Gtk.SliceListModel

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.ListModel (4), Gtk.SectionModel (2)

Structs:

GObject.ObjectClass (5)

class

new (model, offset, size)

get_model ()

get_offset ()

get_size ()

set_model (model)

set_offset (offset)

set_size (size)

Virtual Methods

Inherited:

GObject.Object (7), Gio.ListModel (3), Gtk.SectionModel (1)

Properties

Name

Type

Flags

Short Description

item-type

GObject.GType

r

model

Gio.ListModel

r/w/en

n-items

int

r

offset

int

r/w/en

size

int

r/w/en

Signals

Inherited:

GObject.Object (1), Gio.ListModel (1), Gtk.SectionModel (1)

Fields

Inherited:

GObject.Object (1), Gio.ListModel (1), Gtk.SectionModel (1)

Class Details

class Gtk.SliceListModel(**kwargs)
Bases:

GObject.Object, Gio.ListModel, Gtk.SectionModel

Abstract:

No

Structure:

Gtk.SliceListModelClass

GtkSliceListModel is a list model that presents a slice of another model.

This is useful when implementing paging by setting the size to the number of elements per page and updating the offset whenever a different page is opened.

GtkSliceListModel passes through sections from the underlying model.

classmethod new(model, offset, size)[source]
Parameters:
  • model (Gio.ListModel or None) – The model to use

  • offset (int) – the offset of the slice

  • size (int) – maximum size of the slice

Returns:

A new GtkSliceListModel

Return type:

Gtk.SliceListModel

Creates a new slice model.

It presents the slice from offset to offset + size of the given model.

get_model()[source]
Returns:

The model in use

Return type:

Gio.ListModel or None

Gets the model that is currently being used or None if none.

get_offset()[source]
Returns:

The offset

Return type:

int

Gets the offset set via Gtk.SliceListModel.set_offset().

get_size()[source]
Returns:

The size

Return type:

int

Gets the size set via Gtk.SliceListModel.set_size().

set_model(model)[source]
Parameters:

model (Gio.ListModel or None) – The model to be sliced

Sets the model to show a slice of.

The model’s item type must conform to self's item type.

set_offset(offset)[source]
Parameters:

offset (int) – the new offset to use

Sets the offset into the original model for this slice.

If the offset is too large for the sliced model, self will end up empty.

set_size(size)[source]
Parameters:

size (int) – the maximum size

Sets the maximum size. self will never have more items than size.

It can however have fewer items if the offset is too large or the model sliced from doesn’t have enough items.

Property Details

Gtk.SliceListModel.props.item_type
Name:

item-type

Type:

GObject.GType

Default Value:

<GType GObject>

Flags:

READABLE

The type of items. See [method`Gio`.ListModel.get_item_type].

New in version 4.8.

Gtk.SliceListModel.props.model
Name:

model

Type:

Gio.ListModel

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Child model to take slice from.

Gtk.SliceListModel.props.n_items
Name:

n-items

Type:

int

Default Value:

0

Flags:

READABLE

The number of items. See [method`Gio`.ListModel.get_n_items].

New in version 4.8.

Gtk.SliceListModel.props.offset
Name:

offset

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Offset of slice.

Gtk.SliceListModel.props.size
Name:

size

Type:

int

Default Value:

10

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Maximum size of slice.