Class StringList
- All Implemented Interfaces:
Proxy
,ListModelJavaList<StringObject>
,ListModelJavaListMutable<StringObject>
,ListModelJavaListSpliceable<StringObject>
,Iterable<StringObject>
,Collection<StringObject>
,List<StringObject>
,SequencedCollection<StringObject>
,ListModel<StringObject>
,Buildable
GtkStringList
is a list model that wraps an array of strings.
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 class
StringList.Builder<B extends StringList.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
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModelImpl, ListModel.ListModelInterface
Nested classes/interfaces inherited from interface io.github.jwharm.javagi.gio.ListModelJavaList
ListModelJavaList.SubList<E extends GObject,
List extends ListModelJavaList<E>> Nested classes/interfaces inherited from interface io.github.jwharm.javagi.gio.ListModelJavaListSpliceable
ListModelJavaListSpliceable.SubList<E extends GObject,
List extends ListModelJavaListSpliceable<E>> -
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionStringList
(@Nullable String[] strings) Creates a newGtkStringList
with the givenstrings
.StringList
(MemorySegment address) Create a StringList proxy instance for the provided memory address.StringList
(Object... propertyNamesAndValues) Creates a new StringList with the provided property names and values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appendsstring
to this StringList.void
Adds the specified element to the end of this list.protected StringList
asParent()
Returns this instance as if it were its parent type.static StringList.Builder
<? extends StringList.Builder> builder()
AStringList.Builder
object constructs aStringList
with the specified properties.getString
(int position) Gets the string that is atposition
in this StringList.static Type
getType()
Get the GType of the StringList classvoid
removeAt
(int position) Removes the string atposition
from this StringList.void
Changes this StringList by removingnRemovals
strings and addingadditions
to it.void
splice
(int index, int nRemovals, @NotNull Collection<? extends StringObject> additions) Modifies this list by removingnRemovals
elements starting atindex
and replacing them with the elements inadditions
.void
splice
(int index, int nRemovals, StringObject[] additions) Modifies this list by removingnRemovals
elements starting atindex
and replacing them with the elements inadditions
.void
Addsstring
to 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, 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 org.gnome.gtk.Buildable
getBuildableId
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
contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, size, toArray, toArray
Methods inherited from interface io.github.jwharm.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 newGtkStringList
with the givenstrings
.- Parameters:
strings
- The strings to put in the model
-
StringList
Creates a new StringList with the provided property names and values.- Parameters:
propertyNamesAndValues
- pairs of property names and values (Strings and Objects). Does not need to be null-terminated.- Throws:
IllegalArgumentException
- invalid property names or values
-
-
Method Details
-
splice
public void splice(int index, int nRemovals, @NotNull @NotNull Collection<? extends StringObject> additions) Modifies this list by removingnRemovals
elements starting atindex
and replacing them with the elements inadditions
.- Specified by:
splice
in interfaceListModelJavaListSpliceable<StringObject>
- Parameters:
index
- the index at which to splice the listnRemovals
- the number of elements to removeelements
- the elements to insert at the index- Throws:
IndexOutOfBoundsException
- if the index is out of range
-
splice
Modifies this list by removingnRemovals
elements starting atindex
and replacing them with the elements inadditions
.- Specified by:
splice
in 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:
append
in 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 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. -
append
Appendsstring
to this StringList.The
string
will be copied. Seetake(java.lang.String)
for a way to avoid that.- Parameters:
string
- the string to insert
-
getString
Gets the string that is atposition
in this StringList.If this StringList does not contain
position
items,null
is 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 atposition
from this StringList.position
must be smaller than the current length of the list.- Specified by:
removeAt
in interfaceListModelJavaListMutable<StringObject>
- Parameters:
position
- the position of the string that is to be removed
-
splice
Changes this StringList by removingnRemovals
strings and addingadditions
to 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
position
andnRemovals
must be correct (ie:position
+nRemovals
must 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
Addsstring
to 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.Builder
object constructs aStringList
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withStringList.Builder.build()
.
-