gtk.combo_box_text

Module for [ComboBoxText] class

Types 3

A gtk.combo_box_text.ComboBoxText is a simple variant of gtk.combo_box.ComboBox for text-only use cases.

!An example GtkComboBoxText

gtk.combo_box_text.ComboBoxText hides the model-view complexity of gtk.combo_box.ComboBox.

To create a gtk.combo_box_text.ComboBoxText, use gtk.combo_box_text.ComboBoxText.new_ or gtk.combo_box_text.ComboBoxText.newWithEntry.

You can add items to a gtk.combo_box_text.ComboBoxText with gtk.combo_box_text.ComboBoxText.appendText, gtk.combo_box_text.ComboBoxText.insertText or gtk.combo_box_text.ComboBoxText.prependText and remove options with gtk.combo_box_text.ComboBoxText.remove.

If the gtk.combo_box_text.ComboBoxText contains an entry (via the gtk.combo_box.ComboBox.hasEntry property), its contents can be retrieved using gtk.combo_box_text.ComboBoxText.getActiveText.

You should not call gtk.combo_box.ComboBox.setModel or attempt to pack more cells into this combo box via its gtk.cell_layout.CellLayout interface.

GtkComboBoxText as GtkBuildable

The gtk.combo_box_text.ComboBoxText implementation of the gtk.buildable.Buildable 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 gtk.combo_box_text.ComboBoxText 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

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

gtk.combo_box_text.ComboBoxText 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.

Deprecated

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
ComboBoxText self() nothrowReturns `this`, for use in `with` statements.
ComboBoxTextGidBuilder builder() static nothrowGet builder for [gtk.combo_box_text.ComboBoxText] Returns: New builder object
gtk.combo_box_text.ComboBoxText newWithEntry() static nothrowCreates a new [gtk.combo_box_text.ComboBoxText] with an entry. Returns: a new [gtk.combo_box_text.ComboBoxText]
void append(string id, string text) nothrowAppends text to the list of strings stored in combo_box.
void appendText(string text) nothrowAppends text to the list of strings stored in combo_box.
string getActiveText() nothrowReturns the currently active string in combo_box.
void insert(int position, string id, string text) nothrowInserts text at position in the list of strings stored in combo_box.
void insertText(int position, string text) nothrowInserts text at position in the list of strings stored in combo_box.
void prepend(string id, string text) nothrowPrepends text to the list of strings stored in combo_box.
void prependText(string text) nothrowPrepends text to the list of strings stored in combo_box.
void remove(int position) nothrowRemoves the string at position from combo_box.
void removeAll() nothrowRemoves all the text entries from the combo box.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.combo_box_text.ComboBoxText]. Returns: A new [gtk.combo_box_text.ComboBoxText]
Methods
ComboBoxText build() nothrowCreate object from builder. Returns: New object