Package ch.bailu.gtk.gtk
Class StringList
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.StringList
- All Implemented Interfaces:
PointerInterface
`GtkStringList` is a list model that wraps an array of strings.
The objects in the model have a "string" property.
`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`
```xml
<object class="GtkStringList">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
```
The objects in the model have a "string" property.
`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`
```xml
<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 classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionStringList
(PointerContainer pointer) StringList
(Strs strings) Creates a new `GtkStringList` with the given @strings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends @string to @self.void
Appends @string to @self.Implements interfaceBuildable
.Implements interfaceListModel
.static ClassHandler
static int
static long
static TypeSystem.TypeSize
getString
(int position) Gets the string that is at @position in @self.static long
static TypeSystem.TypeSize
void
remove
(int position) Removes the string at @position from @self.void
Changes @self by removing @n_removals strings and adding @additions
to it.void
Adds @string to self at the end, and takes
ownership of it.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
StringList
-
StringList
Creates a new `GtkStringList` with the given @strings.- Parameters:
strings
- The strings to put in the model
-
-
Method Details
-
getClassHandler
-
append
Appends @string to @self.
The @string will be copied. See
[method@Gtk.StringList.take] for a way to avoid that.- Parameters:
string
- the string to insert
-
append
Appends @string to @self.
The @string will be copied. See
[method@Gtk.StringList.take] for a way to avoid that.- Parameters:
string
- the string to insert
-
getString
Gets the string that is at @position in @self.
If @self 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
-
remove
public void remove(int position) Removes the string at @position from @self.
@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 @self by removing @n_removals strings and adding @additions
to it.
This function is more efficient than [method@Gtk.StringList.append]
and [method@Gtk.StringList.remove], because it only emits the
::items-changed signal once for the change.
This function copies the strings in @additions.
The parameters @position and @n_removals must be correct (ie:
@position + @n_removals 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 changen_removals
- the number of strings to removeadditions
- The strings to add
-
take
Adds @string to self at the end, and takes
ownership of it.
This variant of [method@Gtk.StringList.append]
is convenient for formatting strings:
```c
gtk_string_list_take (self, g_strdup_print ("%d dollars", lots));
```- Parameters:
string
- the string to insert
-
asListModel
Implements interfaceListModel
. Call this to get access to interface functions.- Returns:
ListModel
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Returns:
Buildable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-