Class ListItem
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
ColumnViewCell
GtkListItem
is 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(org.gnome.gtk.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
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ListItem.Builder<B extends ListItem.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionListItem
(MemorySegment address) Create a ListItem proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected ListItem
asParent()
Returns this instance as if it were its parent type.static ListItem.Builder
<? extends ListItem.Builder> builder()
AListItem.Builder
object constructs aListItem
with the specified properties.Gets the accessible description of this ListItem.Gets the accessible label of this ListItem.boolean
Checks if a list item has been set to be activatable via gtk_list_item_set_activatable().getChild()
Gets the child previously set via gtk_list_item_set_child() ornull
if none was set.boolean
Checks if a list item has been set to be focusable via gtk_list_item_set_focusable().getItem()
Gets the model item that associated with this ListItem.int
Gets the position in the model that this ListItem currently displays.boolean
Checks if a list item has been set to be selectable via gtk_list_item_set_selectable().boolean
Checks if the item is displayed as selected.static Type
getType()
Get the GType of the ListItem classvoid
setAccessibleDescription
(String description) Sets the accessible description for the list item, which may be used by e.g.void
setAccessibleLabel
(String label) Sets the accessible label for the list item, which may be used by e.g.void
setActivatable
(boolean activatable) Sets this ListItem to be activatable.void
Sets the child to be used for this listitem.void
setFocusable
(boolean focusable) Sets this ListItem to be focusable.void
setSelectable
(boolean selectable) Sets this ListItem to be selectable.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
ListItem
Create a ListItem proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getAccessibleDescription
Gets the accessible description of this ListItem.- Returns:
- the accessible description
-
getAccessibleLabel
Gets the accessible label of this ListItem.- Returns:
- the accessible label
-
getActivatable
public boolean getActivatable()Checks if a list item has been set to be activatable via gtk_list_item_set_activatable().- Returns:
true
if the item is activatable
-
getChild
Gets the child previously set via gtk_list_item_set_child() ornull
if none was set.- Returns:
- The child
-
getFocusable
public boolean getFocusable()Checks if a list item has been set to be focusable via gtk_list_item_set_focusable().- Returns:
true
if the item is focusable
-
getItem
Gets the model item that associated with this ListItem.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 list item has been set to be selectable via gtk_list_item_set_selectable().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
Sets the accessible description for the list item, which may be used by e.g. screen readers.- Parameters:
description
- the description
-
setAccessibleLabel
Sets the accessible label for the list item, which may be used by e.g. screen readers.- Parameters:
label
- the label
-
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 gtk_widget_activate() will activate the item. Activating instructs the containing view to handle activation.
GtkListView
for example will be emitting theGtk.ListView::activate
signal.By default, list items are activatable.
- Parameters:
activatable
- if the item should be activatable
-
setChild
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 list item's child ornull
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, list items are focusable.
- Parameters:
focusable
- if the item should be focusable
-
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, list items 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
AListItem.Builder
object constructs aListItem
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withListItem.Builder.build()
.
-