Class ListItem

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
ColumnViewCell

@Generated("org.javagi.JavaGI") public class ListItem extends GObject

Used by list widgets to represent items in a ListModel.

GtkListItem objects are managed by the list widget (with its factory) and cannot be created by applications, but they need to be populated by application code. This is done by calling setChild(Widget).

GtkListItem objects 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 Gtk.ListItem:item property is set to NULL.

  2. The bound stage where the listitem references an item from the list. The Gtk.ListItem:item property is not NULL.

  • Constructor Details

    • ListItem

      public ListItem(MemorySegment address)
      Create a ListItem instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ListItem

      public ListItem()
      Create a new ListItem.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ListItem class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ListItem asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getAccessibleDescription

      public String getAccessibleDescription()
      Gets the accessible description of self.
      Returns:
      the accessible description
      Since:
      4.12
    • getAccessibleLabel

      public String getAccessibleLabel()
      Gets the accessible label of self.
      Returns:
      the accessible label
      Since:
      4.12
    • getActivatable

      public boolean getActivatable()
      Checks if a listitem has been set to be activatable via setActivatable(boolean).
      Returns:
      true if the item is activatable
    • getChild

      public @Nullable Widget getChild()
      Gets the child previously set via setChild(Widget) or NULL if none was set.
      Returns:
      The child
    • getFocusable

      public boolean getFocusable()
      Checks if a listitem has been set to be focusable via setFocusable(boolean).
      Returns:
      true if the item is focusable
      Since:
      4.12
    • getItem

      public @Nullable GObject getItem()

      Gets the model item that associated with self.

      If this ListItem is unbound, this function returns NULL.

      Returns:
      The item displayed
    • getPosition

      public int getPosition()

      Gets the position in the model that this ListItem currently displays.

      If this ListItem is unbound, GTK_INVALID_LIST_POSITION is returned.

      Returns:
      The position of this item
    • getSelectable

      public boolean getSelectable()

      Checks if a listitem has been set to be selectable via setSelectable(boolean).

      Do not confuse this function with getSelected().

      Returns:
      true if the item is selectable
    • getSelected

      public boolean getSelected()

      Checks if the item is displayed as selected.

      The selected state is maintained by the list widget and its model and cannot be set otherwise.

      Returns:
      true if the item is selected.
    • setAccessibleDescription

      public void setAccessibleDescription(String description)

      Sets the accessible description for the listitem.

      The accessible description may be used by e.g. screen readers.

      Parameters:
      description - the description
      Since:
      4.12
    • setAccessibleLabel

      public void setAccessibleLabel(String label)

      Sets the accessible label for the listitem.

      The accessible label may be used by e.g. screen readers.

      Parameters:
      label - the label
      Since:
      4.12
    • setActivatable

      public void setActivatable(boolean activatable)

      Sets this ListItem to be activatable.

      If an item is activatable, double-clicking on the item, using the Return key or calling Widget.activate will activate the item. Activating instructs the containing view to handle activation. GtkListView for example will be emitting the Gtk.ListView::activate signal.

      By default, listitems are activatable.

      Parameters:
      activatable - if the item should be activatable
    • setChild

      public void setChild(@Nullable Widget 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:
      child - The listitem's child or NULL to unset
    • setFocusable

      public void setFocusable(boolean focusable)

      Sets this ListItem to be focusable.

      If an item is focusable, it can be focused using the keyboard. This works similar to Widget.setFocusable(boolean).

      Note that if items are not focusable, the keyboard cannot be used to activate them and selecting only works if one of the listitem's children is focusable.

      By default, listitems are focusable.

      Parameters:
      focusable - if the item should be focusable
      Since:
      4.12
    • setSelectable

      public void setSelectable(boolean selectable)

      Sets this ListItem 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, listitems are selectable. When rebinding them to a new item, they will also be reset to be selectable by GTK.

      Parameters:
      selectable - if the item should be selectable
    • builder

      public static ListItem.Builder<? extends ListItem.Builder> builder()
      A ListItem.Builder object constructs a ListItem with the specified properties. Use the various set...() methods to set properties, and finish construction with ListItem.Builder.build().
      Returns:
      the builder object