StringListProtocol
public protocol StringListProtocol : ListModelProtocol, ObjectProtocol, BuildableProtocol
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
<object class="GtkStringList">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
The StringListProtocol
protocol exposes the methods and properties of an underlying GtkStringList
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see StringList
.
Alternatively, use StringListRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkStringList
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
string_list_ptr
Default implementationTyped pointer to the underlying
GtkStringList
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkStringList
instance.Declaration
Swift
var string_list_ptr: UnsafeMutablePointer<GtkStringList>! { get }
-
Required Initialiser for types conforming to
StringListProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
append(string:
Extension method) Appends
string
toself
.The
string
will be copied. See [methodGtk.StringList.take
] for a way to avoid that.Declaration
Swift
@inlinable func append(string: UnsafePointer<CChar>!)
-
getString(position:
Extension method) Gets the string that is at
position
inself
.If
self
does not containposition
items,nil
is returned.This function returns the const char *. To get the object wrapping it, use
g_list_model_get_item()
.Declaration
Swift
@inlinable func getString(position: Int) -> String!
-
remove(position:
Extension method) Removes the string at
position
fromself
.position
must be smaller than the current length of the list.Declaration
Swift
@inlinable func remove(position: Int)
-
splice(position:
Extension methodnRemovals: additions: ) Changes
self
by removingn_removals
strings and addingadditions
to it.This function is more efficient than [method
Gtk.StringList.append
] and [methodGtk.StringList.remove
], because it only emits theitems-changed
signal once for the change.This function copies the strings in
additions
.The parameters
position
andn_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).Declaration
Swift
@inlinable func splice(position: Int, nRemovals: Int, additions: UnsafePointer<UnsafePointer<CChar>?>! = nil)
-
take(string:
Extension method) Adds
string
to self at the end, and takes ownership of it.This variant of [method
Gtk.StringList.append
] is convenient for formatting strings:gtk_string_list_take (self, g_strdup_print ("`d` dollars", lots));
Declaration
Swift
@inlinable func take(string: UnsafeMutablePointer<CChar>!)