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
GtkComboBoxText
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
combo_box_text_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn 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:
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
property
the property to get the value for
Return Value
the value of the named property
-
append(id:
Extension methodtext: ) Appends
text
to the list of strings stored incombo_box
. Ifid
is non-nil
then 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
text
to 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
, ornil
if none is selected. Ifcombo_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:
Extension methodid: text: ) Inserts
text
atposition
in the list of strings stored incombo_box
. Ifid
is non-nil
then it is used as the ID of the row. SeeGtkComboBox:id-column
.If
position
is negative thentext
is appended.Declaration
Swift
@inlinable func insert(position: Int, id: UnsafePointer<gchar>? = nil, text: UnsafePointer<gchar>!)
-
insertText(position:
Extension methodtext: ) Inserts
text
atposition
in the list of strings stored incombo_box
.If
position
is negative thentext
is appended.This is the same as calling
gtk_combo_box_text_insert()
with anil
ID string.Declaration
Swift
@inlinable func insertText(position: Int, text: UnsafePointer<gchar>!)
-
prepend(id:
Extension methodtext: ) Prepends
text
to the list of strings stored incombo_box
. Ifid
is non-nil
then 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
text
to 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
position
fromcombo_box
.Declaration
Swift
@inlinable func remove(position: Int)
-
removeAll()
Extension methodRemoves all the text entries from the combo box.
Declaration
Swift
@inlinable func removeAll()
-
activeText
Extension methodReturns the currently active string in
combo_box
, ornil
if none is selected. Ifcombo_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 }