ComboBoxText

A GtkComboBoxText is a simple variant of GtkComboBox that hides the model-view complexity for simple text-only use cases.

To create a GtkComboBoxText, use gtk_combo_box_text_new() or gtk_combo_box_text_new_with_entry().

You can add items to a GtkComboBoxText with gtk_combo_box_text_append_text(), gtk_combo_box_text_insert_text() or gtk_combo_box_text_prepend_text() and remove options with gtk_combo_box_text_remove().

If the GtkComboBoxText contains an entry (via the 'has-entry' property), its contents can be retrieved using gtk_combo_box_text_get_active_text(). The entry itself can be accessed by calling gtk_bin_get_child() on the combo box.

You should not call gtk_combo_box_set_model() or attempt to pack more cells into this combo box via its GtkCellLayout interface.

GtkComboBoxText as GtkBuildable

The GtkComboBoxText implementation of the GtkBuildable 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".

class ComboBoxText : ComboBox {}

Constructors

this
this(GtkComboBoxText* gtkComboBoxText)

Sets our main struct and passes it to the parent class

this
this(bool entry)

Creates a new ComboBoxText, which is a ComboBox just displaying strings.

Members

Functions

addOnChanged
void addOnChanged(void delegate(ComboBoxText) dlg, ConnectFlags connectFlags)

The changed signal is emitted when the active item is changed. The can be due to the user selecting a different item from the list, or due to a call to gtk_combo_box_set_active_iter(). It will also be emitted while typing into the entry of a combo box with an entry. Since 2.4

addOnFormatEntryText
void addOnFormatEntryText(string delegate(string, ComboBoxText) dlg, ConnectFlags connectFlags)

For combo boxes that are created with an entry (See GtkComboBox:has-entry). A signal which allows you to change how the text displayed in a combo box's entry is displayed. Connect a signal handler which returns an allocated string representing path. That string will then be used to set the text in the combo box's entry. The default signal handler uses the text from the GtkComboBox::entry-text-column model column. Here's an example signal handler which fetches data from the model and displays it in the entry. Since 3.4

addOnMoveActive
void addOnMoveActive(void delegate(GtkScrollType, ComboBoxText) dlg, ConnectFlags connectFlags)

The ::move-active signal is a keybinding signal which gets emitted to move the active selection. Since 2.12

addOnPopdown
void addOnPopdown(bool delegate(ComboBoxText) dlg, ConnectFlags connectFlags)

The ::popdown signal is a keybinding signal which gets emitted to popdown the combo box list. The default bindings for this signal are Alt+Up and Escape. Since 2.12

addOnPopup
void addOnPopup(void delegate(ComboBoxText) dlg, ConnectFlags connectFlags)

The ::popup signal is a keybinding signal which gets emitted to popup the combo box list. The default binding for this signal is Alt+Down. Since 2.12 See Also GtkComboBoxText, GtkTreeModel, GtkCellRenderer

append
void append(string id, string text)

Appends text to the list of strings stored in combo_box. If id is non-NULL then it is used as the ID of the row. This is the same as calling gtk_combo_box_text_insert() with a position of -1. Since 2.24

appendText
void appendText(string text)

Appends text to the list of strings stored in combo_box. This is the same as calling gtk_combo_box_text_insert_text() with a position of -1. Since 2.24

getActiveText
string getActiveText()

Returns the currently active string in combo_box, or NULL if none is selected. If combo_box contains an entry, this function will return its contents (which will not necessarily be an item from the list). Since 2.24

getComboBoxTextStruct
GtkComboBoxText* getComboBoxTextStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getIndex
int getIndex(string text)
getStruct
void* getStruct()

the main Gtk struct as a void*

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

Inserts text at position in the list of strings stored in combo_box. If id is non-NULL then it is used as the ID of the row. See "id-column". If position is negative then text is appended.

insertText
void insertText(int position, string text)

Inserts text at position in the list of strings stored in combo_box. If position is negative then text is appended. This is the same as calling gtk_combo_box_text_insert() with a NULL ID string. Since 2.24

prepend
void prepend(string id, string text)

Prepends text to the list of strings stored in combo_box. If id is non-NULL then it is used as the ID of the row. This is the same as calling gtk_combo_box_text_insert() with a position of 0. Since 2.24

prependOrReplaceText
void prependOrReplaceText(string text)
prependText
void prependText(string text)

Prepends text to the list of strings stored in combo_box. This is the same as calling gtk_combo_box_text_insert_text() with a position of 0. Since 2.24

remove
void remove(int position)

Removes the string at position from combo_box. Since 2.24

removeAll
void removeAll()

Removes all the text entries from the combo box.

setActiveText
void setActiveText(string text, bool insert)
setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

callBackChanged
void callBackChanged(GtkComboBox* widgetStruct, ComboBoxText _comboBoxText)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackFormatEntryText
void callBackFormatEntryText(GtkComboBox* comboStruct, gchar* path, ComboBoxText _comboBoxText)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackMoveActive
void callBackMoveActive(GtkComboBox* widgetStruct, GtkScrollType scrollType, ComboBoxText _comboBoxText)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPopdown
gboolean callBackPopdown(GtkComboBox* buttonStruct, ComboBoxText _comboBoxText)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPopup
void callBackPopup(GtkComboBox* widgetStruct, ComboBoxText _comboBoxText)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;

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.

gtkComboBoxText
GtkComboBoxText* gtkComboBoxText;

the main Gtk struct

onChangedListeners
void delegate(ComboBoxText)[] onChangedListeners;
Undocumented in source.
onFormatEntryTextListeners
string delegate(string, ComboBoxText)[] onFormatEntryTextListeners;
Undocumented in source.
onMoveActiveListeners
void delegate(GtkScrollType, ComboBoxText)[] onMoveActiveListeners;
Undocumented in source.
onPopdownListeners
bool delegate(ComboBoxText)[] onPopdownListeners;
Undocumented in source.
onPopupListeners
void delegate(ComboBoxText)[] onPopupListeners;
Undocumented in source.

Inherited Members

From ComboBox

gtkComboBox
GtkComboBox* gtkComboBox;

the main Gtk struct

getComboBoxStruct
GtkComboBox* getComboBoxStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
__anonymous
mixin CellLayoutT!(GtkComboBox)
Undocumented in source.
__anonymous
mixin CellEditableT!(GtkComboBox)
Undocumented in source.
connectedSignals
int[string] connectedSignals;
onChangedListeners
void delegate(ComboBox)[] onChangedListeners;
Undocumented in source.
addOnChanged
void addOnChanged(void delegate(ComboBox) dlg, ConnectFlags connectFlags)

The changed signal is emitted when the active item is changed. The can be due to the user selecting a different item from the list, or due to a call to gtk_combo_box_set_active_iter(). It will also be emitted while typing into the entry of a combo box with an entry. Since 2.4

callBackChanged
void callBackChanged(GtkComboBox* widgetStruct, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
onFormatEntryTextListeners
string delegate(string, ComboBox)[] onFormatEntryTextListeners;
Undocumented in source.
addOnFormatEntryText
void addOnFormatEntryText(string delegate(string, ComboBox) dlg, ConnectFlags connectFlags)

For combo boxes that are created with an entry (See GtkComboBox:has-entry). A signal which allows you to change how the text displayed in a combo box's entry is displayed. Connect a signal handler which returns an allocated string representing path. That string will then be used to set the text in the combo box's entry. The default signal handler uses the text from the GtkComboBox::entry-text-column model column. Here's an example signal handler which fetches data from the model and displays it in the entry. Since 3.4

callBackFormatEntryText
void callBackFormatEntryText(GtkComboBox* comboStruct, gchar* path, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
onMoveActiveListeners
void delegate(GtkScrollType, ComboBox)[] onMoveActiveListeners;
Undocumented in source.
addOnMoveActive
void addOnMoveActive(void delegate(GtkScrollType, ComboBox) dlg, ConnectFlags connectFlags)

The ::move-active signal is a keybinding signal which gets emitted to move the active selection. Since 2.12

callBackMoveActive
void callBackMoveActive(GtkComboBox* widgetStruct, GtkScrollType scrollType, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
onPopdownListeners
bool delegate(ComboBox)[] onPopdownListeners;
Undocumented in source.
addOnPopdown
void addOnPopdown(bool delegate(ComboBox) dlg, ConnectFlags connectFlags)

The ::popdown signal is a keybinding signal which gets emitted to popdown the combo box list. The default bindings for this signal are Alt+Up and Escape. Since 2.12

callBackPopdown
gboolean callBackPopdown(GtkComboBox* buttonStruct, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
onPopupListeners
void delegate(ComboBox)[] onPopupListeners;
Undocumented in source.
addOnPopup
void addOnPopup(void delegate(ComboBox) dlg, ConnectFlags connectFlags)

The ::popup signal is a keybinding signal which gets emitted to popup the combo box list. The default binding for this signal is Alt+Down. Since 2.12 See Also GtkComboBoxText, GtkTreeModel, GtkCellRenderer

callBackPopup
void callBackPopup(GtkComboBox* widgetStruct, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
getWrapWidth
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. Since 2.6

setWrapWidth
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. Since 2.4

getRowSpanColumn
int getRowSpanColumn()

Returns the column with row span information for combo_box. Since 2.6

setRowSpanColumn
void setRowSpanColumn(int rowSpan)

Sets 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. Since 2.4

getColumnSpanColumn
int getColumnSpanColumn()

Returns the column with column span information for combo_box. Since 2.6

setColumnSpanColumn
void setColumnSpanColumn(int columnSpan)

Sets 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. Since 2.4

getActive
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 function returns gtk_tree_path_get_indices (path)[0], where path is the GtkTreePath of the active item. Since 2.4

setActive
void setActive(int index)

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

getActiveIter
int getActiveIter(TreeIter iter)

Sets iter to point to the current active item, if it exists. Since 2.4

setActiveIter
void setActiveIter(TreeIter iter)

Sets the current active item to be the one referenced by iter, or unsets the active item if iter is NULL. Since 2.4

getIdColumn
int getIdColumn()

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

setIdColumn
void setIdColumn(int idColumn)

Sets 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.

getActiveId
string getActiveId()

Returns the ID of the active row of combo_box. This value is taken from the active row and the column specified by the "id-column" property of combo_box (see gtk_combo_box_set_id_column()). The returned value is an interned string which means that you can compare the pointer by value to other interned strings and that you must not free it. If the "id-column" property of combo_box is not set, or if no row is active, or if the active row has a NULL ID value, then NULL is returned.

setActiveId
int setActiveId(string activeId)

Changes 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. If the "id-column" property of combo_box is unset or if no row has the given ID then the function does nothing and returns FALSE.

getModel
TreeModelIF getModel()

Returns the GtkTreeModel which is acting as data source for combo_box. Since 2.4

setModel
void setModel(TreeModelIF model)

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. Note that this function does not clear the cell renderers, you have to call gtk_cell_layout_clear() yourself if you need to set up different cell renderers for the new model. Since 2.4

popupForDevice
void popupForDevice(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.

popup
void popup()

Pops up the menu or dropdown list of combo_box. This function is mostly intended for use by accessibility technologies; applications should have little use for it. Since 2.4

popdown
void popdown()

Hides the menu or dropdown list of combo_box. This function is mostly intended for use by accessibility technologies; applications should have little use for it. Since 2.4

getPopupAccessible
ObjectAtk getPopupAccessible()

Gets the accessible object corresponding to the combo box's popup. This function is mostly intended for use by accessibility technologies; applications should have little use for it. Since 2.6

getRowSeparatorFunc
GtkTreeViewRowSeparatorFunc getRowSeparatorFunc()

Returns the current row separator function. Since 2.6

setRowSeparatorFunc
void setRowSeparatorFunc(GtkTreeViewRowSeparatorFunc func, void* data, GDestroyNotify destroy)

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. Since 2.6

setAddTearoffs
void setAddTearoffs(int addTearoffs)

Warning gtk_combo_box_set_add_tearoffs is deprecated and should not be used in newly-written code. 3.10 Sets whether the popup menu should have a tearoff menu item. Since 2.6

getAddTearoffs
int getAddTearoffs()

Warning gtk_combo_box_get_add_tearoffs is deprecated and should not be used in newly-written code. 3.10 Gets the current value of the :add-tearoffs property.

setTitle
void setTitle(string title)

Warning gtk_combo_box_set_title is deprecated and should not be used in newly-written code. 3.10 Sets the menu's title in tearoff mode. Since 2.10

getTitle
string getTitle()

Warning gtk_combo_box_get_title is deprecated and should not be used in newly-written code. 3.10 Gets the current title of the menu in tearoff mode. See gtk_combo_box_set_add_tearoffs(). Since 2.10

setFocusOnClick
void setFocusOnClick(int 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 from the main area of the application. Since 2.6

getFocusOnClick
int getFocusOnClick()

Returns whether the combo box grabs focus when it is clicked with the mouse. See gtk_combo_box_set_focus_on_click(). Since 2.6

setButtonSensitivity
void setButtonSensitivity(GtkSensitivityType sensitivity)

Sets whether the dropdown button of the combo box should be always sensitive (GTK_SENSITIVITY_ON), never sensitive (GTK_SENSITIVITY_OFF) or only if there is at least one item to display (GTK_SENSITIVITY_AUTO). Since 2.14

getButtonSensitivity
GtkSensitivityType getButtonSensitivity()

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

getHasEntry
int getHasEntry()

Returns whether the combo box has an entry. Since 2.24

setEntryTextColumn
void setEntryTextColumn(int textColumn)

Sets 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. This is only relevant if combo_box has been created with "has-entry" as TRUE. Since 2.24

getEntryTextColumn
int getEntryTextColumn()

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

setPopupFixedWidth
void setPopupFixedWidth(int fixed)

Specifies whether the popup's width should be a fixed width matching the allocated width of the combo box.

getPopupFixedWidth
int getPopupFixedWidth()

Gets whether the popup uses a fixed width matching the allocated width of the combo box.

Meta