Class SingleSelection<T extends GObject>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>,SequencedCollection<T>,ListModel<T>,SectionModel<T>,SelectionModel<T>,Proxy,ListModelJavaList<T>
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
Nested ClassesModifier and TypeClassDescriptionstatic classSingleSelection.Builder<B extends SingleSelection.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classSingleSelection.SingleSelectionClass<T extends GObject>Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterfaceNested classes/interfaces inherited from interface org.javagi.gio.ListModelJavaList
ListModelJavaList.SubList<E extends @Nullable GObject,List extends ListModelJavaList<E>> Nested classes/interfaces inherited from interface org.gnome.gtk.SectionModel
SectionModel.SectionModel$Impl, SectionModel.SectionModelInterface, SectionModel.SectionsChangedCallbackNested classes/interfaces inherited from interface org.gnome.gtk.SelectionModel
SelectionModel.SelectionChangedCallback, SelectionModel.SelectionModel$Impl, SelectionModel.SelectionModelInterface -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new SingleSelection.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 SingleSelectionasParent()Returns this instance as if it were its parent type.static SingleSelection.Builder<? extends SingleSelection.Builder> builder()ASingleSelection.Builderobject constructs aSingleSelectionwith the specified properties.booleanChecks if autoselect has been enabled or disabled via gtk_single_selection_set_autoselect().booleanIftrue, gtk_selection_model_unselect_item() is supported and allows unselecting the selected item.@Nullable ListModelgetModel()Gets the model that this SingleSelection is wrapping.intGets the position of the selected item.Gets the selected item.static @Nullable TypegetType()Get the GType of the SingleSelection classvoidsetAutoselect(boolean autoselect) Enables or disables autoselect.voidsetCanUnselect(boolean canUnselect) Iftrue, unselecting the current item via gtk_selection_model_unselect_item() is supported.voidSets the model that this SingleSelection should wrap.voidsetSelected(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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliteratorMethods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChangedMethods inherited from interface org.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, toArrayMethods inherited from interface org.gnome.gtk.SectionModel
emitSectionsChanged, getSection, onSectionsChanged, sectionsChangedMethods 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- theGListModelto manage
-
SingleSelection
public SingleSelection()Creates a new SingleSelection.
-
-
Method Details
-
getType
Get the GType of the SingleSelection class- Returns:
- the GType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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:
trueif autoselect is enabled
-
getCanUnselect
public boolean getCanUnselect()Iftrue, gtk_selection_model_unselect_item() is supported and allows unselecting the selected item.- Returns:
trueto 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_POSITIONis returned.- Returns:
- The position of the selected item
-
getSelectedItem
Gets the selected item.If no item is selected,
nullis returned.- Returns:
- The selected item
-
setAutoselect
public void setAutoselect(boolean autoselect) Enables or disables autoselect.If
autoselectistrue, 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-trueto 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:autoselectwill cause unselecting to not work, so it practically makes no sense to set both at the same time.- Parameters:
canUnselect-trueto allow unselecting
-
setModel
Sets the model that this SingleSelection should wrap.If
modelisnull, this SingleSelection will be empty.- Parameters:
model- AGListModelto wrap
-
setSelected
public void setSelected(int position) Selects the item at the given position.If the list does not have an item at
positionorGTK_INVALID_LIST_POSITIONis given, the behavior depends on the value of theGtk.SingleSelection:autoselectproperty: 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-unselectis set tofalse.- Parameters:
position- the item to select orGTK_INVALID_LIST_POSITION
-
builder
ASingleSelection.Builderobject constructs aSingleSelectionwith the specified properties. Use the variousset...()methods to set properties, and finish construction withSingleSelection.Builder.build().- Returns:
- the builder object
-