ComboBoxTextProtocol

public protocol ComboBoxTextProtocol : ComboBoxProtocol

A GtkComboBoxText is a simple variant of GtkComboBox for text-only use cases.

An example GtkComboBoxText

GtkComboBoxText hides the model-view complexity of GtkComboBox.

To create a GtkComboBoxText, use [ctorGtk.ComboBoxText.new] or [ctorGtk.ComboBoxText.new_with_entry].

You can add items to a GtkComboBoxText with [methodGtk.ComboBoxText.append_text], [methodGtk.ComboBoxText.insert_text] or [methodGtk.ComboBoxText.prepend_text] and remove options with [methodGtk.ComboBoxText.remove].

If the GtkComboBoxText contains an entry (via the [propertyGtk.ComboBox:has-entry] property), its contents can be retrieved using [methodGtk.ComboBoxText.get_active_text].

You should not call [methodGtk.ComboBox.set_model] or attempt to pack more cells into this combo box via its [ifaceGtk.CellLayout] interface.

GtkComboBoxText as GtkBuildable

The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element can specify the “id” corresponding to the appended text and also supports the regular translation attributes “translatable”, “context” and “comments”.

Here is a UI definition fragment specifying GtkComboBoxText items:

&lt;object class="GtkComboBoxText"&gt;
  &lt;items&gt;
    &lt;item translatable="yes" id="factory"&gt;Factory&lt;/item&gt;
    &lt;item translatable="yes" id="home"&gt;Home&lt;/item&gt;
    &lt;item translatable="yes" id="subway"&gt;Subway&lt;/item&gt;
  &lt;/items&gt;
&lt;/object&gt;

CSS nodes

combobox
╰── box.linked
    ├── entry.combo
    ├── button.combo
    ╰── window.popup

GtkComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.

The ComboBoxTextProtocol protocol exposes the methods and properties of an underlying GtkComboBoxText 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 ComboBoxText. Alternatively, use ComboBoxTextRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkComboBoxText instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkComboBoxText instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkComboBoxText instance.

    Declaration

    Swift

    var combo_box_text_ptr: UnsafeMutablePointer<GtkComboBoxText>! { get }
  • Required Initialiser for types conforming to ComboBoxTextProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

ComboBoxText Class

  • Bind a ComboBoxTextPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: ComboBoxTextPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a ComboBoxText property

    Declaration

    Swift

    @inlinable
    func get(property: ComboBoxTextPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a ComboBoxText property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: ComboBoxTextPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

ComboBoxText Class: ComboBoxTextProtocol extension (methods and fields)

  • append(id:text:) Extension method

    Appends text to the list of strings stored in combo_box.

    If id is non-nil then it is used as the ID of the row.

    This is the same as calling [methodGtk.ComboBoxText.insert] with a position of -1.

    Declaration

    Swift

    @inlinable
    func append(id: UnsafePointer<CChar>? = nil, text: UnsafePointer<CChar>!)
  • append(text:) Extension method

    Appends text to the list of strings stored in combo_box.

    This is the same as calling [methodGtk.ComboBoxText.insert_text] with a position of -1.

    Declaration

    Swift

    @inlinable
    func append(text: UnsafePointer<CChar>!)
  • getActiveText() Extension method

    Returns the currently active string in combo_box.

    If no row is currently selected, nil is returned. If combo_box contains an entry, this function will return its contents (which will not necessarily be an item from the list).

    Declaration

    Swift

    @inlinable
    func getActiveText() -> String!
  • insert(position:id:text:) Extension method

    Inserts text at position in the list of strings stored in combo_box.

    If id is non-nil then it is used as the ID of the row. See [propertyGtk.ComboBox:id-column].

    If position is negative then text is appended.

    Declaration

    Swift

    @inlinable
    func insert(position: Int, id: UnsafePointer<CChar>? = nil, text: UnsafePointer<CChar>!)
  • insertText(position:text:) Extension method

    Inserts text at position in the list of strings stored in combo_box.

    If position is negative then text is appended.

    This is the same as calling [methodGtk.ComboBoxText.insert] with a nil ID string.

    Declaration

    Swift

    @inlinable
    func insertText(position: Int, text: UnsafePointer<CChar>!)
  • prepend(id:text:) Extension method

    Prepends text to the list of strings stored in combo_box.

    If id is non-nil then it is used as the ID of the row.

    This is the same as calling [methodGtk.ComboBoxText.insert] with a position of 0.

    Declaration

    Swift

    @inlinable
    func prepend(id: UnsafePointer<CChar>? = nil, text: UnsafePointer<CChar>!)
  • prepend(text:) Extension method

    Prepends text to the list of strings stored in combo_box.

    This is the same as calling [methodGtk.ComboBoxText.insert_text] with a position of 0.

    Declaration

    Swift

    @inlinable
    func prepend(text: UnsafePointer<CChar>!)
  • remove(position:) Extension method

    Removes the string at position from combo_box.

    Declaration

    Swift

    @inlinable
    func remove(position: Int)
  • removeAll() Extension method

    Removes all the text entries from the combo box.

    Declaration

    Swift

    @inlinable
    func removeAll()
  • activeText Extension method

    Returns the currently active string in combo_box.

    If no row is currently selected, nil is returned. If combo_box contains an entry, this function will return its contents (which will not necessarily be an item from the list).

    Declaration

    Swift

    @inlinable
    var activeText: String! { get }