gtk.combo_box

Module for [ComboBox] class

Types 3

A GtkComboBox is a widget that allows the user to choose from a list of valid choices. The GtkComboBox displays the selected choice. When activated, the GtkComboBox displays a popup which allows the user to make a new choice. The style in which the selected value is displayed, and the style of the popup is determined by the current theme. It may be similar to a Windows-style combo box.

The GtkComboBox uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since GtkComboBox implements the #GtkCellLayout interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.

To allow the user to enter values not in the model, the “has-entry” property allows the GtkComboBox to contain a #GtkEntry. This entry can be accessed by calling gtk.bin.Bin.getChild on the combo box.

For a simple list of textual choices, the model-view API of GtkComboBox can be a bit overwhelming. In this case, #GtkComboBoxText offers a simple alternative. Both GtkComboBox and #GtkComboBoxText can contain an entry.

CSS nodes

combobox
├── box.linked
│   ╰── button.combo
│       ╰── box
│           ├── cellview
│           ╰── arrow
╰── window.popup

A normal combobox contains a box with the .linked class, a button with the .combo class and inside those buttons, there are a cellview and an arrow.

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

A GtkComboBox with an entry has a single CSS node with name combobox. It contains a box with the .linked class. That box contains an entry and a button, both with the .combo class added. The button also contains another node with name arrow.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
ComboBox self() nothrowReturns `this`, for use in `with` statements.
ComboBoxGidBuilder builder() static nothrowGet builder for [gtk.combo_box.ComboBox] Returns: New builder object
int active() @property nothrowGet `active` property. Returns: The item which is currently active. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this property has th...
void active(int propval) @property nothrowSet `active` property. Params: propval = The item which is currently active. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this proper...
string activeId() @property nothrowGet `activeId` property. Returns: The value of the ID column of the active row.
void activeId(string propval) @property nothrowSet `activeId` property. Params: propval = The value of the ID column of the active row.
bool addTearoffs() @property nothrowGet `addTearoffs` property. Returns: The add-tearoffs property controls whether generated menus have tearoff menu items.
void addTearoffs(bool propval) @property nothrowSet `addTearoffs` property. Params: propval = The add-tearoffs property controls whether generated menus have tearoff menu items.
gtk.types.SensitivityType buttonSensitivity() @property nothrowGet `buttonSensitivity` property. Returns: Whether the dropdown button is sensitive when the model is empty.
void buttonSensitivity(gtk.types.SensitivityType propval) @property nothrowSet `buttonSensitivity` property. Params: propval = Whether the dropdown button is sensitive when the model is empty.
gtk.cell_area.CellArea cellArea() @property nothrowGet `cellArea` property. Returns: The #GtkCellArea used to layout cell renderers for this combo box.
int columnSpanColumn() @property nothrowGet `columnSpanColumn` property. Returns: If this is set to a non-negative value, it must be the index of a column of type `G_TYPE_INT` in the model. The value in that column for each item will det...
void columnSpanColumn(int propval) @property nothrowSet `columnSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `G_TYPE_INT` in the model. The value in that column for each item...
int entryTextColumn() @property nothrowGet `entryTextColumn` property. Returns: The column in the combo box's model to associate with strings from the entry if the combo was created with #GtkComboBox:has-entry = true.
void entryTextColumn(int propval) @property nothrowSet `entryTextColumn` property. Params: propval = The column in the combo box's model to associate with strings from the entry if the combo was created with #GtkComboBox:has-entry = true.
bool hasEntry() @property nothrowGet `hasEntry` property. Returns: Whether the combo box has an entry.
bool hasFrame() @property nothrowGet `hasFrame` property. Returns: The has-frame property controls whether a frame is drawn around the entry.
void hasFrame(bool propval) @property nothrowSet `hasFrame` property. Params: propval = The has-frame property controls whether a frame is drawn around the entry.
int idColumn() @property nothrowGet `idColumn` property. Returns: The column in the combo box's model that provides string IDs for the values in the model, if != -1.
void idColumn(int propval) @property nothrowSet `idColumn` property. Params: propval = The column in the combo box's model that provides string IDs for the values in the model, if != -1.
gtk.tree_model.TreeModel model() @property nothrowGet `model` property. Returns: The model from which the combo box takes the values shown in the list.
void model(gtk.tree_model.TreeModel propval) @property nothrowSet `model` property. Params: propval = The model from which the combo box takes the values shown in the list.
bool popupFixedWidth() @property nothrowGet `popupFixedWidth` property. Returns: Whether the popup's width should be a fixed width matching the allocated width of the combo box.
void popupFixedWidth(bool propval) @property nothrowSet `popupFixedWidth` property. Params: propval = Whether the popup's width should be a fixed width matching the allocated width of the combo box.
bool popupShown() @property nothrowGet `popupShown` property. Returns: Whether the combo boxes dropdown is popped up. Note that this property is mainly useful, because it allows you to connect to notify::popup-shown.
int rowSpanColumn() @property nothrowGet `rowSpanColumn` property. Returns: If this is set to a non-negative value, it must be the index of a column of type `G_TYPE_INT` in the model. The value in that column for each item will determ...
void rowSpanColumn(int propval) @property nothrowSet `rowSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `G_TYPE_INT` in the model. The value in that column for each item wi...
string tearoffTitle() @property nothrowGet `tearoffTitle` property. Returns: A title that may be displayed by the window manager when the popup is torn-off.
void tearoffTitle(string propval) @property nothrowSet `tearoffTitle` property. Params: propval = A title that may be displayed by the window manager when the popup is torn-off.
int wrapWidth() @property nothrowGet `wrapWidth` property. Returns: If wrap-width is set to a positive value, items in the popup will be laid out along multiple columns, starting a new row on reaching the wrap width.
void wrapWidth(int propval) @property nothrowSet `wrapWidth` property. Params: propval = If wrap-width is set to a positive value, items in the popup will be laid out along multiple columns, starting a new row on reaching the wrap width.
gtk.combo_box.ComboBox newWithArea(gtk.cell_area.CellArea area) static nothrowCreates a new empty #GtkComboBox using area to layout cells.
gtk.combo_box.ComboBox newWithAreaAndEntry(gtk.cell_area.CellArea area) static nothrowCreates a new empty #GtkComboBox with an entry.
gtk.combo_box.ComboBox newWithEntry() static nothrowCreates a new empty #GtkComboBox with an entry. Returns: A new #GtkComboBox.
gtk.combo_box.ComboBox newWithModel(gtk.tree_model.TreeModel model) static nothrowCreates a new #GtkComboBox with the model initialized to model.
gtk.combo_box.ComboBox newWithModelAndEntry(gtk.tree_model.TreeModel model) static nothrowCreates a new empty #GtkComboBox with an entry and with the model initialized to model.
int getActive() nothrowReturns the index of the currently active item, or -1 if there’s no active item. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this ...
string getActiveId() nothrowReturns the ID of the active row of combo_box. This value is taken from the active row and the column specified by the #GtkComboBox:id-column property of combo_box (see [gtk.combo_box.ComboBox.set...
bool getActiveIter(out gtk.tree_iter.TreeIter iter) nothrowSets iter to point to the currently active item, if any item is active. Otherwise, iter is left unchanged.
bool getAddTearoffs() nothrowGets the current value of the :add-tearoffs property. Returns: the current value of the :add-tearoffs property.
gtk.types.SensitivityType getButtonSensitivity() nothrowReturns whether the combo box sets the dropdown button sensitive or not when there are no items in the model. Returns: [gtk.types.SensitivityType.On] if the dropdown button is sensitive when the mo...
int getColumnSpanColumn() nothrowReturns the column with column span information for combo_box. Returns: the column span column.
int getEntryTextColumn() nothrowReturns the column which combo_box is using to get the strings from to display in the internal entry. Returns: A column in the data source model of combo_box.
bool getFocusOnClick() nothrowReturns whether the combo box grabs focus when it is clicked with the mouse. See [gtk.combo_box.ComboBox.setFocusOnClick]. Returns: true if the combo box grabs focus when it is clicked with the mouse.
bool getHasEntry() nothrowReturns whether the combo box has an entry. Returns: whether there is an entry in combo_box.
int getIdColumn() nothrowReturns the column which combo_box is using to get string IDs for values from. Returns: A column in the data source model of combo_box.
gtk.tree_model.TreeModel getModel() nothrowReturns the #GtkTreeModel which is acting as data source for combo_box. Returns: A #GtkTreeModel which was passed during construction.
atk.object.ObjectWrap getPopupAccessible() nothrowGets the accessible object corresponding to the combo box’s popup.
bool getPopupFixedWidth() nothrowGets whether the popup uses a fixed width matching the allocated width of the combo box. Returns: true if the popup uses a fixed width
int getRowSpanColumn() nothrowReturns the column with row span information for combo_box. Returns: the row span column.
string getTitle() nothrowGets the current title of the menu in tearoff mode. See [gtk.combo_box.ComboBox.setAddTearoffs]. Returns: the menu’s title in tearoff mode. This is an internal copy of the string which must not b...
int getWrapWidth() nothrowReturns the wrap width which is used to determine the number of columns for the popup menu. If the wrap width is larger than 1, the combo box is in table mode. Returns: the wrap width.
void popdown() nothrowHides the menu or dropdown list of combo_box.
void popup() nothrowPops up the menu or dropdown list of combo_box.
void popupForDevice(gdk.device.Device device) nothrowPops up the menu or dropdown list of combo_box, the popup window will be grabbed so only device and its associated pointer/keyboard are the only #GdkDevices able to send events to it.
void setActive(int index) nothrowSets the active item of combo_box to be the item at index.
bool setActiveId(string activeId = null) nothrowChanges the active row of combo_box to the one that has an ID equal to active_id, or unsets the active row if active_id is null. Rows having a null ID string cannot be made active by this function.
void setActiveIter(gtk.tree_iter.TreeIter iter = null) nothrowSets the current active item to be the one referenced by iter, or unsets the active item if iter is null.
void setAddTearoffs(bool addTearoffs) nothrowSets whether the popup menu should have a tearoff menu item.
void setButtonSensitivity(gtk.types.SensitivityType sensitivity) nothrowSets whether the dropdown button of the combo box should be always sensitive ([gtk.types.SensitivityType.On]), never sensitive ([gtk.types.SensitivityType.Off]) or only if there is at least one ite...
void setColumnSpanColumn(int columnSpan) nothrowSets the column with column span information for combo_box to be column_span. The column span column contains integers which indicate how many columns an item should span.
void setEntryTextColumn(int textColumn) nothrowSets the model column which combo_box should use to get strings from to be text_column. The column text_column in the model of combo_box must be of type `G_TYPE_STRING`.
void setFocusOnClick(bool focusOnClick) nothrowSets whether the combo box will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed ...
void setIdColumn(int idColumn) nothrowSets the model column which combo_box should use to get string IDs for values from. The column id_column in the model of combo_box must be of type `G_TYPE_STRING`.
void setModel(gtk.tree_model.TreeModel model = null) nothrowSets the model used by combo_box to be model. Will unset a previously set model (if applicable). If model is null, then it will unset the model.
void setPopupFixedWidth(bool fixed) nothrowSpecifies whether the popup’s width should be a fixed width matching the allocated width of the combo box.
void setRowSeparatorFunc(gtk.types.TreeViewRowSeparatorFunc func) nothrowSets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is null, no separators are drawn. This is the default value.
void setRowSpanColumn(int rowSpan) nothrowSets the column with row span information for combo_box to be row_span. The row span column contains integers which indicate how many rows an item should span.
void setTitle(string title) nothrowSets the menu’s title in tearoff mode.
void setWrapWidth(int width) nothrowSets the wrap width of combo_box to be width. The wrap width is basically the preferred number of columns when you want the popup to be layed out in a table.
gulong connectChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox))) && Parameters!T.length < 2) nothrowConnect to `Changed` signal.
gulong connectFormatEntryText(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == string) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.combo_box.ComboBox))) && Parameters!T.length < 3) nothrowConnect to `FormatEntryText` signal.
gulong connectMoveActive(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.ScrollType))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.combo_box.ComboBox))) && Parameters!T.length < 3) nothrowConnect to `MoveActive` signal.
gulong connectPopdown(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox))) && Parameters!T.length < 2) nothrowConnect to `Popdown` signal.
gulong connectPopup(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox))) && Parameters!T.length < 2) nothrowConnect to `Popup` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new empty #GtkComboBox. Returns: A new #GtkComboBox.

Fluent builder implementation template for gtk.combo_box.ComboBox

Methods
T active(int propval) nothrowSet `active` property. Params: propval = The item which is currently active. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this proper...
T activeId(string propval) nothrowSet `activeId` property. Params: propval = The value of the ID column of the active row. Returns: Builder instance for fluent chaining
T addTearoffs(bool propval) nothrowSet `addTearoffs` property. Params: propval = The add-tearoffs property controls whether generated menus have tearoff menu items.
T buttonSensitivity(gtk.types.SensitivityType propval) nothrowSet `buttonSensitivity` property. Params: propval = Whether the dropdown button is sensitive when the model is empty. Returns: Builder instance for fluent chaining
T cellArea(gtk.cell_area.CellArea propval) nothrowSet `cellArea` property. Params: propval = The #GtkCellArea used to layout cell renderers for this combo box.
T columnSpanColumn(int propval) nothrowSet `columnSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `G_TYPE_INT` in the model. The value in that column for each item...
T entryTextColumn(int propval) nothrowSet `entryTextColumn` property. Params: propval = The column in the combo box's model to associate with strings from the entry if the combo was created with #GtkComboBox:has-entry = true. Returns: ...
T hasEntry(bool propval) nothrowSet `hasEntry` property. Params: propval = Whether the combo box has an entry. Returns: Builder instance for fluent chaining
T hasFrame(bool propval) nothrowSet `hasFrame` property. Params: propval = The has-frame property controls whether a frame is drawn around the entry. Returns: Builder instance for fluent chaining
T idColumn(int propval) nothrowSet `idColumn` property. Params: propval = The column in the combo box's model that provides string IDs for the values in the model, if != -1. Returns: Builder instance for fluent chaining
T model(gtk.tree_model.TreeModel propval) nothrowSet `model` property. Params: propval = The model from which the combo box takes the values shown in the list. Returns: Builder instance for fluent chaining
T popupFixedWidth(bool propval) nothrowSet `popupFixedWidth` property. Params: propval = Whether the popup's width should be a fixed width matching the allocated width of the combo box. Returns: Builder instance for fluent chaining
T rowSpanColumn(int propval) nothrowSet `rowSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `G_TYPE_INT` in the model. The value in that column for each item wi...
T tearoffTitle(string propval) nothrowSet `tearoffTitle` property. Params: propval = A title that may be displayed by the window manager when the popup is torn-off. Returns: Builder instance for fluent chaining
T wrapWidth(int propval) nothrowSet `wrapWidth` property. Params: propval = If wrap-width is set to a positive value, items in the popup will be laid out along multiple columns, starting a new row on reaching the wrap width. Retu...

Fluent builder for gtk.combo_box.ComboBox

Methods
ComboBox build() nothrowCreate object from builder. Returns: New object