ComboBox

Description 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_get_child() 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. 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 GtkOptionMenu, or similar to a Windows-style combo box. Unlike its predecessors GtkCombo and GtkOptionMenu, 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. In addition to the model-view API, GtkComboBox offers a simple API which is suitable for text-only combo boxes, and hides the complexity of managing the data in a model. It consists of the functions gtk_combo_box_new_text(), gtk_combo_box_append_text(), gtk_combo_box_insert_text(), gtk_combo_box_prepend_text(), gtk_combo_box_remove_text() and gtk_combo_box_get_active_text().

class ComboBox : Bin , CellLayoutIF , CellEditableIF {}

Constructors

this
this(GtkComboBox* gtkComboBox)

Sets our main struct and passes it to the parent class

this
this(bool text)

Creates a new empty GtkComboBox. If text is true then constructs a new text combo box, which is a GtkComboBox just displaying strings. If you use this function to create a text combo box, you should only manipulate its data source with the following convenience functions: gtk_combo_box_append_text(), gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and gtk_combo_box_remove_text(). Since 2.4

this
this(TreeModelIF model)

Creates a new GtkComboBox with the model initialized to model. Since 2.4

Members

Functions

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 a GtkComboBoxEntry, as well as when selecting an item from the GtkComboBoxEntry's list. Since 2.4

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

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

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

appendText
void appendText(string text)

Warning gtk_combo_box_append_text has been deprecated since version 2.24 and should not be used in newly-written code. Use GtkComboBoxText Appends string to the list of strings stored in combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text(). 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

getActiveIter
int getActiveIter(TreeIter iter)

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

getActiveText
string getActiveText()

Warning gtk_combo_box_get_active_text has been deprecated since version 2.24 and should not be used in newly-written code. If you used this with a GtkComboBox constructed with gtk_combo_box_new_text() then you should now use GtkComboBoxText and gtk_combo_box_text_get_active_text() instead. Or if you used this with a GtkComboBoxEntry then you should now use GtkComboBox with "has-entry" as TRUE and use gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combobox))). Returns the currently active string in combo_box or NULL if none is selected. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text() and with GtkComboBoxEntrys. Since 2.6

getAddTearoffs
int getAddTearoffs()

Gets the current value of the :add-tearoffs property.

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

getColumnSpanColumn
int getColumnSpanColumn()

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

getComboBoxStruct
GtkComboBox* getComboBoxStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
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

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

getHasEntry
int getHasEntry()

Returns whether the combo box has an entry. Since 2.24

getIndex
int getIndex(string text)
getModel
TreeModelIF getModel()

Returns the GtkTreeModel which is acting as data source for combo_box. 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

getRowSpanColumn
int getRowSpanColumn()

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

getStruct
void* getStruct()

the main Gtk struct as a void*

getTitle
string getTitle()

Gets the current title of the menu in tearoff mode. See gtk_combo_box_set_add_tearoffs(). Since 2.10

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

insertText
void insertText(int position, string text)

Warning gtk_combo_box_insert_text has been deprecated since version 2.24 and should not be used in newly-written code. Use GtkComboBoxText Inserts string at position in the list of strings stored in combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text(). 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

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

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

Warning gtk_combo_box_prepend_text has been deprecated since version 2.24 and should not be used in newly-written code. Use GtkComboBoxText Prepends string to the list of strings stored in combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text(). Since 2.4

removeText
void removeText(int position)

Warning gtk_combo_box_remove_text has been deprecated since version 2.24 and should not be used in newly-written code. Use GtkComboBoxText Removes the string at position from combo_box. Note that you can only use this function with combo boxes constructed with gtk_combo_box_new_text(). Since 2.4

setActive
void setActive(int index)

Sets the active item of combo_box to be the item at index. 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

setActiveText
void setActiveText(string text, bool insert)
setAddTearoffs
void setAddTearoffs(int addTearoffs)

Sets whether the popup menu should have a tearoff menu item. 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

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

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

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

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

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

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

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
setTitle
void setTitle(string title)

Sets the menu's title in tearoff mode. Since 2.10

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

Mixins

__anonymous
mixin CellLayoutT!(GtkComboBox)
Undocumented in source.
__anonymous
mixin CellEditableT!(GtkComboBox)
Undocumented in source.

Static functions

callBackChanged
void callBackChanged(GtkComboBox* widgetStruct, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackMoveActive
void callBackMoveActive(GtkComboBox* widgetStruct, GtkScrollType scrollType, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPopdown
gboolean callBackPopdown(GtkComboBox* buttonStruct, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPopup
void callBackPopup(GtkComboBox* widgetStruct, ComboBox _comboBox)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;
gtkComboBox
GtkComboBox* gtkComboBox;

the main Gtk struct

maxCount
int maxCount;
Undocumented in source.
onChangedListeners
void delegate(ComboBox)[] onChangedListeners;
Undocumented in source.
onMoveActiveListeners
void delegate(GtkScrollType, ComboBox)[] onMoveActiveListeners;
Undocumented in source.
onPopdownListeners
bool delegate(ComboBox)[] onPopdownListeners;
Undocumented in source.
onPopupListeners
void delegate(ComboBox)[] onPopupListeners;
Undocumented in source.

Inherited Members

From Bin

gtkBin
GtkBin* gtkBin;

the main Gtk struct

getBinStruct
GtkBin* getBinStruct()
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.
getChild
Widget getChild()

Gets the child of the GtkBin, or NULL if the bin contains no child widget. The returned widget does not have a reference added, so you do not need to unref it.

From CellLayoutIF

getCellLayoutTStruct
GtkCellLayout* getCellLayoutTStruct()
Undocumented in source.
getStruct
void* getStruct()

the main Gtk struct as a void*

packStart
void packStart(CellRenderer cell, int expand)

Packs the cell into the beginning of cell_layout. If expand is FALSE, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is TRUE. Note that reusing the same cell renderer is not supported. Since 2.4

packEnd
void packEnd(CellRenderer cell, int expand)

Adds the cell to the end of cell_layout. If expand is FALSE, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is TRUE. Note that reusing the same cell renderer is not supported. Since 2.4

getCells
ListG getCells()

Returns the cell renderers which have been added to cell_layout. Since 2.12

reorder
void reorder(CellRenderer cell, int position)

Re-inserts cell at position. Note that cell has already to be packed into cell_layout for this to function properly. Since 2.4

clear
void clear()

Unsets all the mappings on all renderers on cell_layout and removes all renderers from cell_layout. Since 2.4

addAttribute
void addAttribute(CellRenderer cell, string attribute, int column)

Adds an attribute mapping to the list in cell_layout. The column is the column of the model to get a value from, and the attribute is the parameter on cell to be set from the value. So for example if column 2 of the model contains strings, you could have the "text" attribute of a GtkCellRendererText get its values from column 2. Since 2.4

setCellDataFunc
void setCellDataFunc(CellRenderer cell, GtkCellLayoutDataFunc func, void* funcData, GDestroyNotify destroy)

Sets the GtkCellLayoutDataFunc to use for cell_layout. This function is used instead of the standard attributes mapping for setting the column value, and should set the value of cell_layout's cell renderer(s) as appropriate. func may be NULL to remove and older one. Since 2.4

clearAttributes
void clearAttributes(CellRenderer cell)

Clears all existing attributes previously set with gtk_cell_layout_set_attributes(). Since 2.4

From CellEditableIF

getCellEditableTStruct
GtkCellEditable* getCellEditableTStruct()
Undocumented in source.
getStruct
void* getStruct()

the main Gtk struct as a void*

onEditingDoneListeners
void delegate(CellEditableIF)[] onEditingDoneListeners()
addOnEditingDone
void addOnEditingDone(void delegate(CellEditableIF) dlg, ConnectFlags connectFlags)

This signal is a sign for the cell renderer to update its value from the cell_editable. Implementations of GtkCellEditable are responsible for emitting this signal when they are done editing, e.g. GtkEntry is emitting it when the user presses Enter. gtk_cell_editable_editing_done() is a convenience method for emitting GtkCellEditable::editing-done.

onRemoveWidgetListeners
void delegate(CellEditableIF)[] onRemoveWidgetListeners()
Undocumented in source.
addOnRemoveWidget
void addOnRemoveWidget(void delegate(CellEditableIF) dlg, ConnectFlags connectFlags)

This signal is meant to indicate that the cell is finished editing, and the widget may now be destroyed. Implementations of GtkCellEditable are responsible for emitting this signal when they are done editing. It must be emitted after the "editing-done" signal, to give the cell renderer a chance to update the cell's value before the widget is removed. gtk_cell_editable_remove_widget() is a convenience method for emitting GtkCellEditable::remove-widget.

startEditing
void startEditing(Event event)

Begins editing on a cell_editable. event is the GdkEvent that began the editing process. It may be NULL, in the instance that editing was initiated through programatic means.

editingDone
void editingDone()

Emits the "editing-done" signal.

removeWidget
void removeWidget()

Emits the "remove-widget" signal.

Meta