ComboBoxText

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 property@Gtk.ComboBox:has-entry 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.

More...

Constructors

this
this()

Creates a new gtk.combo_box_text.ComboBoxText.

Members

Functions

append
void append(string id, string text)

Appends text to the list of strings stored in combo_box.

appendText
void appendText(string text)

Appends text to the list of strings stored in combo_box.

getActiveText
string getActiveText()

Returns the currently active string in combo_box.

insert
void insert(int position, string id, string text)

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

insertText
void insertText(int position, string text)

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

prepend
void prepend(string id, string text)

Prepends text to the list of strings stored in combo_box.

prependText
void prependText(string text)

Prepends text to the list of strings stored in combo_box.

remove
void remove(int position)

Removes the string at position from combo_box.

removeAll
void removeAll()

Removes all the text entries from the combo box.

Static functions

newWithEntry
gtk.combo_box_text.ComboBoxText newWithEntry()

Creates a new gtk.combo_box_text.ComboBoxText with an entry.

Inherited Members

From ComboBox

newWithEntry
gtk.combo_box.ComboBox newWithEntry()

Creates a new empty gtk.combo_box.ComboBox with an entry.

newWithModel
gtk.combo_box.ComboBox newWithModel(gtk.tree_model.TreeModel model)

Creates a new gtk.combo_box.ComboBox with a model.

newWithModelAndEntry
gtk.combo_box.ComboBox newWithModelAndEntry(gtk.tree_model.TreeModel model)

Creates a new empty gtk.combo_box.ComboBox with an entry and a model.

getActive
int getActive()

Returns the index of the currently active item.

getActiveId
string getActiveId()

Returns the ID of the active row of combo_box.

getActiveIter
bool getActiveIter(gtk.tree_iter.TreeIter iter)

Sets iter to point to the currently active item.

getButtonSensitivity
gtk.types.SensitivityType getButtonSensitivity()

Returns whether the combo box sets the dropdown button sensitive or not when there are no items in the model.

getChild
gtk.widget.Widget getChild()

Gets the child widget of combo_box.

getEntryTextColumn
int getEntryTextColumn()

Returns the column which combo_box is using to get the strings from to display in the internal entry.

getHasEntry
bool getHasEntry()

Returns whether the combo box has an entry.

getIdColumn
int getIdColumn()

Returns the column which combo_box is using to get string IDs for values from.

getModel
gtk.tree_model.TreeModel getModel()

Returns the gtk.tree_model.TreeModel of combo_box.

getPopupFixedWidth
bool getPopupFixedWidth()

Gets whether the popup uses a fixed width.

popdown
void popdown()

Hides the menu or dropdown list of combo_box.

popup
void popup()

Pops up the menu or dropdown list of combo_box.

popupForDevice
void popupForDevice(gdk.device.Device device)

Pops up the menu of combo_box.

setActive
void setActive(int index)

Sets the active item of combo_box to be the item at index.

setActiveId
bool setActiveId(string activeId)

Changes the active row of combo_box to the one that has an ID equal to active_id.

setActiveIter
void setActiveIter(gtk.tree_iter.TreeIter iter)

Sets the current active item to be the one referenced by iter.

setButtonSensitivity
void setButtonSensitivity(gtk.types.SensitivityType sensitivity)

Sets whether the dropdown button of the combo box should update its sensitivity depending on the model contents.

setChild
void setChild(gtk.widget.Widget child)

Sets the child widget of combo_box.

setEntryTextColumn
void setEntryTextColumn(int textColumn)

Sets the model column which combo_box should use to get strings from to be text_column.

setIdColumn
void setIdColumn(int idColumn)

Sets the model column which combo_box should use to get string IDs for values from.

setModel
void setModel(gtk.tree_model.TreeModel model)

Sets the model used by combo_box to be model.

setPopupFixedWidth
void setPopupFixedWidth(bool fixed)

Specifies whether the popup’s width should be a fixed width.

setRowSeparatorFunc
void setRowSeparatorFunc(gtk.types.TreeViewRowSeparatorFunc func)

Sets the row separator function, which is used to determine whether a row should be drawn as a separator.

connectActivate
ulong connectActivate(T callback, Flag!"After" after)

Connect to Activate signal.

connectChanged
ulong connectChanged(T callback, Flag!"After" after)

Connect to Changed signal.

connectFormatEntryText
ulong connectFormatEntryText(T callback, Flag!"After" after)

Connect to FormatEntryText signal.

connectMoveActive
ulong connectMoveActive(T callback, Flag!"After" after)

Connect to MoveActive signal.

connectPopdown
ulong connectPopdown(T callback, Flag!"After" after)

Connect to Popdown signal.

connectPopup
ulong connectPopup(T callback, Flag!"After" after)

Connect to Popup signal.

Detailed Description

Deprecated: Use gtk.drop_down.DropDown with a gtk.string_list.StringList instead