Class StringList<T extends GObject>
- All Implemented Interfaces:
Proxy
,ListModelJavaList<T>
,Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
,ListModel<T>
,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
Modifier and TypeClassDescriptionstatic class
StringList.Builder<B extends StringList.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
StringList.StringListClass<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.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModelImpl, ListModel.ListModelInterface
-
Constructor Summary
ConstructorDescriptionCallsStringList(java.lang.String[])
with strings =null
StringList
(@Nullable String[] strings) Creates a newGtkStringList
with the givenstrings
.StringList
(MemorySegment address) Create a StringList proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appendsstring
to this StringList.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
removeString
(int position) Removes the string atposition
from this StringList.void
Changes this StringList by removingnRemovals
strings and addingadditions
to it.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, 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
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
-
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
public StringList()CallsStringList(java.lang.String[])
with strings =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. -
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
-
removeString
public void removeString(int position) Removes the string atposition
from this StringList.position
must be smaller than the current length of the list.- 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(java.lang.String)
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(java.lang.String)
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()
.
-