GtkListItem

GtkListItem — Object used to represent items of a ListModel

Properties

gboolean activatable Read / Write
GtkWidget * child Read / Write
GObject * item Read
guint position Read
gboolean selectable Read / Write
gboolean selected Read

Types and Values

Object Hierarchy

    GObject
    ╰── GtkListItem

Includes

#include <gtk/gtk.h>

Description

GtkListItem is the object that list-handling containers such as GtkListView use to represent items in a GListModel. They are managed by the container and cannot be created by application code.

GtkListItems need to be populated by application code. This is done by calling gtk_list_item_set_child().

GtkListItems exist in 2 stages:

  1. The unbound stage where the listitem is not currently connected to an item in the list. In that case, the “item” property is set to NULL.

  2. The bound stage where the listitem references an item from the list. The “item” property is not NULL.

Functions

gtk_list_item_get_item ()

gpointer
gtk_list_item_get_item (GtkListItem *self);

Gets the item that is currently displayed in model that self is currently bound to or NULL if self is unbound.

Parameters

self

a GtkListItem

 

Returns

The item displayed.

[nullable][transfer none][type GObject]


gtk_list_item_get_position ()

guint
gtk_list_item_get_position (GtkListItem *self);

Gets the position in the model that self currently displays. If self is unbound, 0 is returned.

Parameters

self

a GtkListItem

 

Returns

The position of this item


gtk_list_item_get_child ()

GtkWidget *
gtk_list_item_get_child (GtkListItem *self);

Gets the child previously set via gtk_list_item_set_child() or NULL if none was set.

Parameters

self

a GtkListItem

 

Returns

The child.

[transfer none][nullable]


gtk_list_item_set_child ()

void
gtk_list_item_set_child (GtkListItem *self,
                         GtkWidget *child);

Sets the child to be used for this listitem.

This function is typically called by applications when setting up a listitem so that the widget can be reused when binding it multiple times.

Parameters

self

a GtkListItem

 

child

The list item's child or NULL to unset.

[nullable]

gtk_list_item_get_selected ()

gboolean
gtk_list_item_get_selected (GtkListItem *self);

Checks if the item is displayed as selected. The selected state is maintained by the container and its list model and cannot be set otherwise.

Parameters

self

a GtkListItem

 

Returns

TRUE if the item is selected.


gtk_list_item_get_selectable ()

gboolean
gtk_list_item_get_selectable (GtkListItem *self);

Checks if a list item has been set to be selectable via gtk_list_item_set_selectable().

Do not confuse this function with gtk_list_item_get_selected().

Parameters

self

a GtkListItem

 

Returns

TRUE if the item is selectable


gtk_list_item_set_selectable ()

void
gtk_list_item_set_selectable (GtkListItem *self,
                              gboolean selectable);

Sets self to be selectable. If an item is selectable, clicking on the item or using the keyboard will try to select or unselect the item. If this succeeds is up to the model to determine, as it is managing the selected state.

Note that this means that making an item non-selectable has no influence on the selected state at all. A non-selectable item may still be selected.

By default, list items are selectable. When rebinding them to a new item, they will also be reset to be selectable by GTK.

Parameters

self

a GtkListItem

 

selectable

if the item should be selectable

 

Types and Values

GtkListItem

typedef struct _GtkListItem GtkListItem;

Property Details

The “activatable” property

  “activatable”              gboolean

If the item can be activated by the user

Owner: GtkListItem

Flags: Read / Write

Default value: TRUE


The “child” property

  “child”                    GtkWidget *

Widget used for display

Owner: GtkListItem

Flags: Read / Write


The “item” property

  “item”                     GObject *

Displayed item

Owner: GtkListItem

Flags: Read


The “position” property

  “position”                 guint

Position of the item

Owner: GtkListItem

Flags: Read

Default value: 4294967295


The “selectable” property

  “selectable”               gboolean

If the item can be selected by the user

Owner: GtkListItem

Flags: Read / Write

Default value: TRUE


The “selected” property

  “selected”                 gboolean

If the item is currently selected

Owner: GtkListItem

Flags: Read

Default value: FALSE

See Also

GtkListView, GListModel