GtkSliceListModel

GtkSliceListModel — A list model that presents a slice out of a larger list

Properties

GType * item-type Read / Write / Construct Only
GListModel * model Read / Write
guint offset Read / Write
guint size Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GtkSliceListModel

Implemented Interfaces

GtkSliceListModel implements GListModel.

Includes

#include <gtk/gtk.h>

Description

GtkSliceListModel is a list model that takes a list model and presents a slice of that 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.

Functions

gtk_slice_list_model_new ()

GtkSliceListModel *
gtk_slice_list_model_new (GListModel *model,
                          guint offset,
                          guint size);

Creates a new slice model that presents the slice from offset to offset + size our of the given model .

Parameters

model

The model to use.

[transfer none]

offset

the offset of the slice

 

size

maximum size of the slice

 

Returns

A new GtkSliceListModel


gtk_slice_list_model_new_for_type ()

GtkSliceListModel *
gtk_slice_list_model_new_for_type (GType item_type);

Creates a new empty GtkSliceListModel for the given item_type that can be set up later.

Parameters

item_type

the type of items

 

Returns

a new empty GtkSliceListModel


gtk_slice_list_model_set_model ()

void
gtk_slice_list_model_set_model (GtkSliceListModel *self,
                                GListModel *model);

Sets the model to show a slice of. The model's item type must conform to self 's item type.

Parameters

self

a GtkSliceListModel

 

model

The model to be sliced.

[allow-none]

gtk_slice_list_model_get_model ()

GListModel *
gtk_slice_list_model_get_model (GtkSliceListModel *self);

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

Parameters

self

a GtkSliceListModel

 

Returns

The model in use.

[nullable][transfer none]


gtk_slice_list_model_set_offset ()

void
gtk_slice_list_model_set_offset (GtkSliceListModel *self,
                                 guint offset);

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.

Parameters

self

a GtkSliceListModel

 

offset

the new offset to use

 

gtk_slice_list_model_get_offset ()

guint
gtk_slice_list_model_get_offset (GtkSliceListModel *self);

Gets the offset set via gtk_slice_list_model_set_offset()

Parameters

self

a GtkSliceListModel

 

Returns

The offset


gtk_slice_list_model_set_size ()

void
gtk_slice_list_model_set_size (GtkSliceListModel *self,
                               guint 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.

Parameters

self

a GtkSliceListModel

 

size

the maximum size

 

gtk_slice_list_model_get_size ()

guint
gtk_slice_list_model_get_size (GtkSliceListModel *self);

Gets the size set via gtk_slice_list_model_set_size().

Parameters

self

a GtkSliceListModel

 

Returns

The size

Types and Values

GtkSliceListModel

typedef struct _GtkSliceListModel GtkSliceListModel;

Property Details

The “item-type” property

  “item-type”                GType *

The GType for elements of this object

Owner: GtkSliceListModel

Flags: Read / Write / Construct Only

Allowed values: GObject


The “model” property

  “model”                    GListModel *

Child model to take slice from

Owner: GtkSliceListModel

Flags: Read / Write


The “offset” property

  “offset”                   guint

Offset of slice

Owner: GtkSliceListModel

Flags: Read / Write

Default value: 0


The “size” property

  “size”                     guint

Maximum size of slice

Owner: GtkSliceListModel

Flags: Read / Write

Default value: 10

See Also

GListModel