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 _gType() @property
ComboBox self()Returns `this`, for use in `with` statements.
ComboBoxGidBuilder builder()Get builder for [gtk.combo_box.ComboBox] Returns: New builder object
int active() @propertyGet `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) @propertySet `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() @propertyGet `activeId` property. Returns: The value of the ID column of the active row.
void activeId(string propval) @propertySet `activeId` property. Params: propval = The value of the ID column of the active row.
bool addTearoffs() @propertyGet `addTearoffs` property. Returns: The add-tearoffs property controls whether generated menus have tearoff menu items.
void addTearoffs(bool propval) @propertySet `addTearoffs` property. Params: propval = The add-tearoffs property controls whether generated menus have tearoff menu items.
gtk.types.SensitivityType buttonSensitivity() @propertyGet `buttonSensitivity` property. Returns: Whether the dropdown button is sensitive when the model is empty.
void buttonSensitivity(gtk.types.SensitivityType propval) @propertySet `buttonSensitivity` property. Params: propval = Whether the dropdown button is sensitive when the model is empty.
gtk.cell_area.CellArea cellArea() @propertyGet `cellArea` property. Returns: The #GtkCellArea used to layout cell renderers for this combo box.
int columnSpanColumn() @propertyGet `columnSpanColumn` property. Returns: If this is set to a non-negative value, it must be the index of a column of type `GTYPEINT` in the model. The value in that column for each item will deter...
void columnSpanColumn(int propval) @propertySet `columnSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `GTYPEINT` in the model. The value in that column for each item w...
int entryTextColumn() @propertyGet `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) @propertySet `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() @propertyGet `hasEntry` property. Returns: Whether the combo box has an entry.
bool hasFrame() @propertyGet `hasFrame` property. Returns: The has-frame property controls whether a frame is drawn around the entry.
void hasFrame(bool propval) @propertySet `hasFrame` property. Params: propval = The has-frame property controls whether a frame is drawn around the entry.
int idColumn() @propertyGet `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) @propertySet `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() @propertyGet `model` property. Returns: The model from which the combo box takes the values shown in the list.
void model(gtk.tree_model.TreeModel propval) @propertySet `model` property. Params: propval = The model from which the combo box takes the values shown in the list.
bool popupFixedWidth() @propertyGet `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) @propertySet `popupFixedWidth` property. Params: propval = Whether the popup's width should be a fixed width matching the allocated width of the combo box.
bool popupShown() @propertyGet `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() @propertyGet `rowSpanColumn` property. Returns: If this is set to a non-negative value, it must be the index of a column of type `GTYPEINT` in the model. The value in that column for each item will determin...
void rowSpanColumn(int propval) @propertySet `rowSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `GTYPEINT` in the model. The value in that column for each item will...
string tearoffTitle() @propertyGet `tearoffTitle` property. Returns: A title that may be displayed by the window manager when the popup is torn-off.
void tearoffTitle(string propval) @propertySet `tearoffTitle` property. Params: propval = A title that may be displayed by the window manager when the popup is torn-off.
int wrapWidth() @propertyGet `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) @propertySet `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)Creates a new empty #GtkComboBox using area to layout cells.
gtk.combo_box.ComboBox newWithAreaAndEntry(gtk.cell_area.CellArea area)Creates a new empty #GtkComboBox with an entry.
gtk.combo_box.ComboBox newWithEntry()Creates a new empty #GtkComboBox with an entry. Returns: A new #GtkComboBox.
gtk.combo_box.ComboBox newWithModel(gtk.tree_model.TreeModel model)Creates a new #GtkComboBox with the model initialized to model.
gtk.combo_box.ComboBox newWithModelAndEntry(gtk.tree_model.TreeModel model)Creates a new empty #GtkComboBox with an entry and with the model initialized to model.
int getActive()Returns 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()Returns the ID of the active row of combobox. This value is taken from the active row and the column specified by the #GtkComboBox:id-column property of combobox (see [gtk.combo_box.ComboBox.setId...
bool getActiveIter(out gtk.tree_iter.TreeIter iter)Sets iter to point to the currently active item, if any item is active. Otherwise, iter is left unchanged.
bool getAddTearoffs()Gets the current value of the :add-tearoffs property. Returns: the current value of the :add-tearoffs property.
gtk.types.SensitivityType getButtonSensitivity()Returns 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()Returns the column with column span information for combo_box. Returns: the column span column.
int getEntryTextColumn()Returns the column which combobox is using to get the strings from to display in the internal entry. Returns: A column in the data source model of combobox.
bool getFocusOnClick()Returns 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()Returns whether the combo box has an entry. Returns: whether there is an entry in combo_box.
int getIdColumn()Returns the column which combobox is using to get string IDs for values from. Returns: A column in the data source model of combobox.
gtk.tree_model.TreeModel getModel()Returns the #GtkTreeModel which is acting as data source for combo_box. Returns: A #GtkTreeModel which was passed during construction.
atk.object.ObjectWrap getPopupAccessible()Gets the accessible object corresponding to the combo box’s popup.
bool getPopupFixedWidth()Gets 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()Returns the column with row span information for combo_box. Returns: the row span column.
string getTitle()Gets 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()Returns 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()Hides the menu or dropdown list of combo_box.
void popup()Pops up the menu or dropdown list of combo_box.
void popupForDevice(gdk.device.Device device)Pops 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)Sets the active item of combo_box to be the item at index.
bool setActiveId(string activeId = null)Changes the active row of combobox to the one that has an ID equal to activeid, 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)Sets the current active item to be the one referenced by iter, or unsets the active item if iter is null.
void setAddTearoffs(bool addTearoffs)Sets whether the popup menu should have a tearoff menu item.
void setButtonSensitivity(gtk.types.SensitivityType sensitivity)Sets 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)Sets the column with column span information for combobox to be columnspan. The column span column contains integers which indicate how many columns an item should span.
void setEntryTextColumn(int textColumn)Sets the model column which combobox should use to get strings from to be textcolumn. The column textcolumn in the model of combobox must be of type `GTYPESTRING`.
void setFocusOnClick(bool focusOnClick)Sets 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)Sets the model column which combobox should use to get string IDs for values from. The column idcolumn in the model of combobox must be of type `GTYPE_STRING`.
void setModel(gtk.tree_model.TreeModel model = null)Sets 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)Specifies whether the popup’s width should be a fixed width matching the allocated width of the combo box.
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. If the row separator function is null, no separators are drawn. This is the default value.
void setRowSpanColumn(int rowSpan)Sets the column with row span information for combobox to be rowspan. The row span column contains integers which indicate how many rows an item should span.
void setTitle(string title)Sets the menu’s title in tearoff mode.
void setWrapWidth(int width)Sets 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)Connect 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)Connect 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)Connect 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)Connect 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)Connect to `Popup` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new empty #GtkComboBox. Returns: A new #GtkComboBox.
Methods
T active(int propval)Set `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)Set `activeId` property. Params: propval = The value of the ID column of the active row. Returns: Builder instance for fluent chaining
T addTearoffs(bool propval)Set `addTearoffs` property. Params: propval = The add-tearoffs property controls whether generated menus have tearoff menu items.
T buttonSensitivity(gtk.types.SensitivityType propval)Set `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)Set `cellArea` property. Params: propval = The #GtkCellArea used to layout cell renderers for this combo box.
T columnSpanColumn(int propval)Set `columnSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `GTYPEINT` in the model. The value in that column for each item w...
T entryTextColumn(int propval)Set `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)Set `hasEntry` property. Params: propval = Whether the combo box has an entry. Returns: Builder instance for fluent chaining
T hasFrame(bool propval)Set `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)Set `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)Set `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)Set `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)Set `rowSpanColumn` property. Params: propval = If this is set to a non-negative value, it must be the index of a column of type `GTYPEINT` in the model. The value in that column for each item will...
T tearoffTitle(string propval)Set `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)Set `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