The
gtk-combo-box-text widget is a simple variant of the
gtk-combo-box widget that hides the model-view complexity for
simple text-only use cases.
To create a
gtk-combo-box-text widget, use the functions
gtk-combo-box-text-new or
gtk-combo-box-text-new-with-entry.
You can add items to a
gtk-combo-box-text widget with the functions
gtk-combo-box-text-append-text,
gtk-combo-box-text-insert-text or
gtk-combo-box-text-prepend-text and remove options with the function
gtk-combo-box-text-remove.
If the
gtk-combo-box-text widget contains an entry via the
has-entry property, its contents can be retrieved using the function
gtk-combo-box-text-active-text. The entry itself can be accessed by calling the function
gtk-bin-child on the combo box.
You should not call the function
gtk-combo-box-model or attempt to pack more cells into this combo box via its
gtk-cell-layout
interface.
GtkComboBoxText as GtkBuildable
The
gtk-combo-box-text implementation of the
gtk-buildable 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".
Example: A UI definition fragment specifying
gtk-combo-box-text
items
<object class="GtkComboBoxText">
<items>
<item translatable="yes">Factory</item>
<item translatable="yes">Home</item>
<item translatable="yes">Subway</item>
</items>
</object>
CSS nodes
combobox
╰── box.linked
├── entry.combo
├── button.combo
╰── window.popup
The
gtk-combo-box-text implementation has a single CSS node with name
combobox. It adds the
.combo style class to the main CSS nodes of its entry and button children, and the
.linked class to the
node of its internal box.