ComboBoxTextProtocol
public protocol ComboBoxTextProtocol : ComboBoxProtocol
A GtkComboBoxText is a simple variant of GtkComboBox that hides
the model-view complexity for simple text-only use cases.
To create a GtkComboBoxText, use gtk_combo_box_text_new() or
gtk_combo_box_text_new_with_entry().
You can add items to a GtkComboBoxText with
gtk_combo_box_text_append_text(), gtk_combo_box_text_insert_text()
or gtk_combo_box_text_prepend_text() and remove options with
gtk_combo_box_text_remove().
If the GtkComboBoxText contains an entry (via the “has-entry” property),
its contents can be retrieved using gtk_combo_box_text_get_active_text().
The entry itself can be accessed by calling gtk_bin_get_child() on the
combo box.
You should not call gtk_combo_box_set_model() or attempt to pack more cells
into this combo box via its GtkCellLayout 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:
<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>
CSS nodes
(plain Language Example):
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.
-
Untyped pointer to the underlying
GtkComboBoxTextinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
combo_box_text_ptrDefault implementationTyped pointer to the underlying
GtkComboBoxTextinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkComboBoxTextinstance.Declaration
Swift
var combo_box_text_ptr: UnsafeMutablePointer<GtkComboBoxText>! { get } -
Required Initialiser for types conforming to
ComboBoxTextProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ComboBoxTextPropertyNamesource 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 : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a ComboBoxText property
Declaration
Swift
@inlinable func get(property: ComboBoxTextPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) 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
propertythe property to get the value for
Return Value
the value of the named property
-
append(id:Extension methodtext: ) Appends
textto the list of strings stored incombo_box. Ifidis non-nilthen it is used as the ID of the row.This is the same as calling
gtk_combo_box_text_insert()with a position of -1.Declaration
Swift
@inlinable func append(id: UnsafePointer<gchar>? = nil, text: UnsafePointer<gchar>!) -
append(text:Extension method) Appends
textto the list of strings stored incombo_box.This is the same as calling
gtk_combo_box_text_insert_text()with a position of -1.Declaration
Swift
@inlinable func append(text: UnsafePointer<gchar>!) -
getActiveText()Extension methodReturns the currently active string in
combo_box, ornilif none is selected. Ifcombo_boxcontains 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:Extension methodid: text: ) Inserts
textatpositionin the list of strings stored incombo_box. Ifidis non-nilthen it is used as the ID of the row. SeeGtkComboBox:id-column.If
positionis negative thentextis appended.Declaration
Swift
@inlinable func insert(position: Int, id: UnsafePointer<gchar>? = nil, text: UnsafePointer<gchar>!) -
insertText(position:Extension methodtext: ) Inserts
textatpositionin the list of strings stored incombo_box.If
positionis negative thentextis appended.This is the same as calling
gtk_combo_box_text_insert()with anilID string.Declaration
Swift
@inlinable func insertText(position: Int, text: UnsafePointer<gchar>!) -
prepend(id:Extension methodtext: ) Prepends
textto the list of strings stored incombo_box. Ifidis non-nilthen it is used as the ID of the row.This is the same as calling
gtk_combo_box_text_insert()with a position of 0.Declaration
Swift
@inlinable func prepend(id: UnsafePointer<gchar>? = nil, text: UnsafePointer<gchar>!) -
prepend(text:Extension method) Prepends
textto the list of strings stored incombo_box.This is the same as calling
gtk_combo_box_text_insert_text()with a position of 0.Declaration
Swift
@inlinable func prepend(text: UnsafePointer<gchar>!) -
remove(position:Extension method) Removes the string at
positionfromcombo_box.Declaration
Swift
@inlinable func remove(position: Int) -
removeAll()Extension methodRemoves all the text entries from the combo box.
Declaration
Swift
@inlinable func removeAll() -
activeTextExtension methodReturns the currently active string in
combo_box, ornilif none is selected. Ifcombo_boxcontains 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 }
View on GitHub
Install in Dash
ComboBoxTextProtocol Protocol Reference