Class StringList
- All Implemented Interfaces:
Iterable<StringObject>,Collection<StringObject>,List<StringObject>,SequencedCollection<StringObject>,ListModel<StringObject>,Buildable,Proxy,ListModelJavaList<StringObject>,ListModelJavaListMutable<StringObject>,ListModelJavaListSpliceable<StringObject>
The objects in the model are of type StringObject and have
a "string" property that can be used inside expressions.
GtkStringList is well-suited for any place where you would
typically use a char*[], but need a list model.
GtkStringList as GtkBuildable
The GtkStringList implementation of the GtkBuildable interface
supports adding items directly using the <items> element and
specifying <item> elements for each item. Each <item> element
supports the regular translation attributes “translatable”,
“context” and “comments”.
Here is a UI definition fragment specifying a GtkStringList
<object class="GtkStringList">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStringList.Builder<B extends StringList.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested 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.javagi.gio.ListModelJavaListSpliceable
ListModelJavaListSpliceable.SubList<E extends @Nullable GObject,List extends ListModelJavaListSpliceable<E>> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new StringList.StringList(@Nullable String @Nullable [] strings) Creates a newGtkStringListwith the givenstrings.StringList(MemorySegment address) Create a StringList proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppendsstringtoself.voidAdds the specified element to the end of this list.protected StringListasParent()Returns this instance as if it were its parent type.static StringList.Builder<? extends StringList.Builder> builder()AStringList.Builderobject constructs aStringListwith the specified properties.intGets the position of thestringinself.@Nullable StringgetString(int position) Gets the string that is atpositioninself.static @Nullable TypegetType()Get the GType of the StringList classvoidremoveAt(int position) Removes the string atpositionfromself.voidChanges this StringList by removingnRemovalsstrings and addingadditionsto it.voidsplice(int index, int nRemovals, Collection<? extends StringObject> additions) Modifies this list by removingnRemovalselements starting atindexand replacing them with the elements inadditions.voidsplice(int index, int nRemovals, StringObject[] additions) Modifies this list by removingnRemovalselements starting atindexand replacing them with the elements inadditions.voidAddsstringto self at the end, and takes ownership of it.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 org.gnome.gtk.Buildable
getBuildableIdMethods 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
contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, size, toArray, toArrayMethods inherited from interface org.javagi.gio.ListModelJavaListMutable
add, remove
-
Constructor Details
-
StringList
Create a StringList proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
StringList
Creates a newGtkStringListwith the givenstrings.- Parameters:
strings- The strings to put in the model
-
StringList
public StringList()Creates a new StringList.
-
-
Method Details
-
splice
Modifies this list by removingnRemovalselements starting atindexand replacing them with the elements inadditions.- Specified by:
splicein interfaceListModelJavaListSpliceable<StringObject>- Parameters:
index- the index at which to splice the listnRemovals- the number of elements to removeadditions- the elements to insert at the index- Throws:
IndexOutOfBoundsException- if the index is out of range
-
splice
Modifies this list by removingnRemovalselements starting atindexand replacing them with the elements inadditions.- Specified by:
splicein interfaceListModelJavaListSpliceable<StringObject>- Parameters:
index- the index at which to splice the listnRemovals- the number of elements to removeadditions- the elements to insert at the index- Throws:
IndexOutOfBoundsException- if the index is out of range
-
append
Adds the specified element to the end of this list.- Specified by:
appendin interfaceListModelJavaListMutable<StringObject>- Parameters:
e- element to be appended to this list
-
getType
-
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. -
append
Appendsstringtoself.The
stringwill be copied. Seetake(java.lang.String)for a way to avoid that.- Parameters:
string- the string to insert
-
find
Gets the position of thestringinself.If this StringList does not contain
stringitem,G_MAXUINTis returned.- Parameters:
string- the string to find- Returns:
- the position of the string
- Since:
- 4.18
-
getString
Gets the string that is atpositioninself.If this StringList does not contain
positionitems,nullis returned.This function returns the const char *. To get the object wrapping it, use g_list_model_get_item().
- Parameters:
position- the position to get the string for- Returns:
- the string at the given position
-
removeAt
public void removeAt(int position) Removes the string atpositionfromself.positionmust be smaller than the current length of the list.- Specified by:
removeAtin interfaceListModelJavaListMutable<StringObject>- Parameters:
position- the position of the string that is to be removed
-
splice
Changes this StringList by removingnRemovalsstrings and addingadditionsto it.This function is more efficient than
append(org.gnome.gtk.StringObject)andStringList#remove, because it only emits the ::items-changed signal once for the change.This function copies the strings in
additions.The parameters
positionandnRemovalsmust be correct (ie:position+nRemovalsmust be less than or equal to the length of the list at the time this function is called).- Parameters:
position- the position at which to make the changenRemovals- the number of strings to removeadditions- The strings to add
-
take
Addsstringto self at the end, and takes ownership of it.This variant of
append(org.gnome.gtk.StringObject)is convenient for formatting strings:gtk_string_list_take (self, g_strdup_print ("%d dollars", lots));- Parameters:
string- the string to insert
-
builder
AStringList.Builderobject constructs aStringListwith the specified properties. Use the variousset...()methods to set properties, and finish construction withStringList.Builder.build().- Returns:
- the builder object
-