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

&lt;object class="GtkStringList"&gt;
  &lt;items&gt;
    &lt;item translatable="yes"&gt;Factory&lt;/item&gt;
    &lt;item translatable="yes"&gt;Home&lt;/item&gt;
    &lt;item translatable="yes"&gt;Subway&lt;/item&gt;
  &lt;/items&gt;
&lt;/object&gt;

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.

  • ptr

    Untyped pointer to the underlying GtkStringList instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • string_list_ptr Default implementation

    Typed 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)

StringList Class: StringListProtocol extension (methods and fields)

  • append(string:) Extension method

    Appends string to self.

    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 in self.

    If self does not contain position 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 from self.

    position must be smaller than the current length of the list.

    Declaration

    Swift

    @inlinable
    func remove(position: Int)
  • Changes self by removing n_removals strings and adding additions to it.

    This function is more efficient than [methodGtk.StringList.append] and [methodGtk.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).

    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 [methodGtk.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>!)