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
GtkStringListinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
string_list_ptrDefault implementationTyped pointer to the underlying
GtkStringListinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkStringListinstance.Declaration
Swift
var string_list_ptr: UnsafeMutablePointer<GtkStringList>! { get } -
Required Initialiser for types conforming to
StringListProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
append(string:Extension method) Appends
stringtoself.The
stringwill 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
positioninself.If
selfdoes not containpositionitems,nilis 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
positionfromself.positionmust be smaller than the current length of the list.Declaration
Swift
@inlinable func remove(position: Int) -
splice(position:Extension methodnRemovals: additions: ) Changes
selfby removingn_removalsstrings and addingadditionsto it.This function is more efficient than [method
Gtk.StringList.append] and [methodGtk.StringList.remove], because it only emits theitems-changedsignal once for the change.This function copies the strings in
additions.The parameters
positionandn_removalsmust be correct (ie:position+n_removalsmust 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
stringto 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>!)
View on GitHub
Install in Dash
StringListProtocol Protocol Reference