Class SingleSelection<T extends GObject>
- All Implemented Interfaces:
Proxy
,ListModelJavaList<T>
,Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
,ListModel<T>
,SectionModel<T>
,SelectionModel<T>
GtkSingleSelection
is a GtkSelectionModel
that allows selecting a single
item.
Note that the selection is persistent -- if the selected item is removed
and re-added in the same Gio.ListModel::items-changed
emission, it
stays selected. In particular, this means that changing the sort order of an
underlying sort model will preserve the selection.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
SingleSelection.Builder<B extends SingleSelection.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
SingleSelection.SingleSelectionClass<T extends GObject>
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModelImpl, ListModel.ListModelInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.SectionModel
SectionModel.SectionModelImpl, SectionModel.SectionModelInterface, SectionModel.SectionsChangedCallback
Nested classes/interfaces inherited from interface org.gnome.gtk.SelectionModel
SelectionModel.SelectionChangedCallback, SelectionModel.SelectionModelImpl, SelectionModel.SelectionModelInterface
-
Constructor Summary
ConstructorDescriptionCallsSingleSelection(org.gnome.gio.ListModel)
with model =null
SingleSelection
(MemorySegment address) Create a SingleSelection proxy instance for the provided memory address.SingleSelection
(@Nullable ListModel model) Creates a new selection to handlemodel
. -
Method Summary
Modifier and TypeMethodDescriptionprotected SingleSelection
asParent()
Returns this instance as if it were its parent type.static SingleSelection.Builder
<? extends SingleSelection.Builder> builder()
ASingleSelection.Builder
object constructs aSingleSelection
with the specified properties.boolean
Checks if autoselect has been enabled or disabled via gtk_single_selection_set_autoselect().boolean
Iftrue
, gtk_selection_model_unselect_item() is supported and allows unselecting the selected item.getModel()
Gets the model that this SingleSelection is wrapping.int
Gets the position of the selected item.Gets the selected item.static Type
getType()
Get the GType of the SingleSelection classvoid
setAutoselect
(boolean autoselect) Enables or disables autoselect.void
setCanUnselect
(boolean canUnselect) Iftrue
, unselecting the current item via gtk_selection_model_unselect_item() is supported.void
Sets the model that this SingleSelection should wrap.void
setSelected
(int position) Selects the item at the given position.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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
Methods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChanged
Methods inherited from interface io.github.jwharm.javagi.gio.ListModelJavaList
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
Methods inherited from interface org.gnome.gtk.SectionModel
emitSectionsChanged, getSection, onSectionsChanged, sectionsChanged
Methods inherited from interface org.gnome.gtk.SelectionModel
emitSelectionChanged, getSelection, getSelectionInRange, isSelected, onSelectionChanged, selectAll, selectionChanged, selectItem, selectRange, setSelection, unselectAll, unselectItem, unselectRange
-
Constructor Details
-
SingleSelection
Create a SingleSelection proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
SingleSelection
Creates a new selection to handlemodel
.- Parameters:
model
- theGListModel
to manage
-
SingleSelection
public SingleSelection()CallsSingleSelection(org.gnome.gio.ListModel)
with model =null
-
-
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. -
getAutoselect
public boolean getAutoselect()Checks if autoselect has been enabled or disabled via gtk_single_selection_set_autoselect().- Returns:
true
if autoselect is enabled
-
getCanUnselect
public boolean getCanUnselect()Iftrue
, gtk_selection_model_unselect_item() is supported and allows unselecting the selected item.- Returns:
true
to support unselecting
-
getModel
Gets the model that this SingleSelection is wrapping.- Returns:
- The model being wrapped
-
getSelected
public int getSelected()Gets the position of the selected item.If no item is selected,
GTK_INVALID_LIST_POSITION
is returned.- Returns:
- The position of the selected item
-
getSelectedItem
Gets the selected item.If no item is selected,
null
is returned.- Returns:
- The selected item
-
setAutoselect
public void setAutoselect(boolean autoselect) Enables or disables autoselect.If
autoselect
istrue
, this SingleSelection will enforce that an item is always selected. It will select a new item when the currently selected item is deleted and it will disallow unselecting the current item.- Parameters:
autoselect
-true
to always select an item
-
setCanUnselect
public void setCanUnselect(boolean canUnselect) Iftrue
, unselecting the current item via gtk_selection_model_unselect_item() is supported.Note that setting
Gtk.SingleSelection:autoselect
will cause unselecting to not work, so it practically makes no sense to set both at the same time.- Parameters:
canUnselect
-true
to allow unselecting
-
setModel
Sets the model that this SingleSelection should wrap.If
model
isnull
, this SingleSelection will be empty.- Parameters:
model
- AGListModel
to wrap
-
setSelected
public void setSelected(int position) Selects the item at the given position.If the list does not have an item at
position
orGTK_INVALID_LIST_POSITION
is given, the behavior depends on the value of theGtk.SingleSelection:autoselect
property: If it is set, no change will occur and the old item will stay selected. If it is unset, the selection will be unset and no item will be selected. This also applies ifGtk.SingleSelection:can-unselect
is set tofalse
.- Parameters:
position
- the item to select orGTK_INVALID_LIST_POSITION
-
builder
ASingleSelection.Builder
object constructs aSingleSelection
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withSingleSelection.Builder.build()
.
-