gtk.ComboBox



class ComboBox : gtk.Bin.Bin, gtk.CellEditableIF.CellEditableIF, gtk.CellLayoutIF.CellLayoutIF;
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.

# 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 bx with the .linked class and that box contains an entry and a button, both with the .combo class added. The button also contains another node with name arrow.

protected GtkComboBox* gtkComboBox ;
the main Gtk struct

GtkComboBox* getComboBoxStruct ();
Get the main Gtk struct

protected void* getStruct ();
the main Gtk struct as a void*

this(GtkComboBox* gtkComboBox, bool ownedRef = false);
Sets our main struct and passes it to the parent class.

this(bool entry = true);
Creates a new empty GtkComboBox.

Params:
bool entry If true, create an empty ComboBox with an entry.

Throws:
ConstructionException GTK+ fails to create the object.

this(TreeModelIF model, bool entry = true);
Creates a new GtkComboBox with the model initialized to model.

Params:
TreeModelIF model A GtkTreeModel.
bool entry If true, create an empty ComboBox with an entry.

Throws:
ConstructionException GTK+ fails to create the object.

this(CellArea area, bool entry = true);
Creates a new empty GtkComboBox using area to layout cells.

Params:
CellArea area the GtkCellArea to use to layout cell renderers.
bool entry If true, create an empty ComboBox with an entry.

Throws:
ConstructionException GTK+ fails to create the object.

static GType getType ();


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.

Return:
An integer which is the index of the currently active item, or -1 if there’s no active item.

Since:
2.4

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 #GtkComboBox: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 #GtkComboBox: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.

Return:
the ID of the active row, or %NULL

Since:
3.0

bool getActiveIter (out TreeIter iter);
Sets @iter to point to the current active item, if it exists.

Params:
TreeIter iter The uninitialized #GtkTreeIter

Return:
%TRUE, if @iter was set

Since:
2.4

bool getAddTearoffs ();
Gets the current value of the :add-tearoffs property.

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

GtkSensitivityType getButtonSensitivity ();
Returns whether the combo box sets the dropdown button sensitive or not when there are no items in the model.

Return:
%GTK_SENSITIVITY_ON if the dropdown button is sensitive when the model is empty, %GTK_SENSITIVITY_OFF if the button is always insensitive or %GTK_SENSITIVITY_AUTO if it is only sensitive as long as the model has one item to be selected.

Since:
2.14

int getColumnSpanColumn ();
Returns the column with column span information for @combo_box.

Return:
the column span column.

Since:
2.6

int getEntryTextColumn ();
Returns the column which @combo_box is using to get the strings from to display in the internal entry.

Return:
A column in the data source model of @combo_box.

Since:
2.24

bool getFocusOnClick ();
Returns whether the combo box grabs focus when it is clicked with the mouse. See gtk_combo_box_set_focus_on_click().

Deprecated:
Use gtk_widget_get_focus_on_click() instead

Return:
%TRUE if the combo box grabs focus when it is clicked with the mouse.

Since:
2.6

bool getHasEntry ();
Returns whether the combo box has an entry.

Return:
whether there is an entry in @combo_box.

Since:
2.24

int getIdColumn ();
Returns the column which @combo_box is using to get string IDs for values from.

Return:
A column in the data source model of @combo_box.

Since:
3.0

TreeModelIF getModel ();
Returns the #GtkTreeModel which is acting as data source for @combo_box.

Return:
A #GtkTreeModel which was passed during construction.

Since:
2.4

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.

Return:
the accessible object corresponding to the combo box’s popup.

Since:
2.6

bool getPopupFixedWidth ();
Gets whether the popup uses a fixed width matching the allocated width of the combo box.

Return:
%TRUE if the popup uses a fixed width

Since:
3.0

GtkTreeViewRowSeparatorFunc getRowSeparatorFunc ();
Returns the current row separator function.

Return:
the current row separator function.

Since:
2.6

int getRowSpanColumn ();
Returns the column with row span information for @combo_box.

Return:
the row span column.

Since:
2.6

string getTitle ();
Gets the current title of the menu in tearoff mode. See gtk_combo_box_set_add_tearoffs().

Return:
the menu’s title in tearoff mode. This is an internal copy of the string which must not be freed.

Since:
2.10

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.

Return:
the wrap width.

Since:
2.6

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

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

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.

Params:
Device device a #GdkDevice

Since:
3.0

void setActive (int index);
Sets the active item of @combo_box to be the item at @index.

Params:
int index An index in the model passed during construction, or -1 to have no active item

Since:
2.4

bool 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 #GtkComboBox:id-column property of @combo_box is unset or if no row has the given ID then the function does nothing and returns %FALSE.

Params:
string activeId the ID of the row to select, or %NULL

Return:
%TRUE if a row with a matching ID was found. If a %NULL @active_id was given to unset the active row, the function always returns %TRUE.

Since:
3.0

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.

Params:
TreeIter iter The #GtkTreeIter, or %NULL

Since:
2.4

void setAddTearoffs (bool addTearoffs);
Sets whether the popup menu should have a tearoff menu item.

Params:
bool addTearoffs %TRUE to add tearoff menu items

Since:
2.6

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

Params:
GtkSensitivityType sensitivity specify the sensitivity of the dropdown button

Since:
2.14

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.

Params:
int columnSpan A column in the model passed during construction

Since:
2.4

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 #GtkComboBox:has-entry as %TRUE.

Params:
int textColumn A column in @model to get the strings from for the internal entry

Since:
2.24

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 from the main area of the application.

Deprecated:
Use gtk_widget_set_focus_on_click() instead

Params:
bool focusOnClick whether the combo box grabs focus when clicked with the mouse

Since:
2.6

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.

Params:
int idColumn A column in @model to get string IDs for values from

Since:
3.0

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.

Params:
TreeModelIF model A #GtkTreeModel

Since:
2.4

void setPopupFixedWidth (bool fixed);
Specifies whether the popup’s width should be a fixed width matching the allocated width of the combo box.

Params:
bool fixed whether to use a fixed popup width

Since:
3.0

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.

Params:
GtkTreeViewRowSeparatorFunc func a #GtkTreeViewRowSeparatorFunc
void* data user data to pass to @func, or %NULL
GDestroyNotify destroy destroy notifier for @data, or %NULL

Since:
2.6

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.

Params:
int rowSpan A column in the model passed during construction.

Since:
2.4

void setTitle (string title);
Sets the menu’s title in tearoff mode.

Params:
string title a title for the menu in tearoff mode

Since:
2.10

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.

Params:
int width Preferred number of columns

Since:
2.4

gulong addOnChanged (void delegate(ComboBox) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
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

gulong addOnFormatEntryText (string delegate(string, ComboBox) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
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. |[ static gchar* format_entry_text_callback (GtkComboBox *combo, const gchar *path, gpointer user_data) { GtkTreeIter iter; GtkTreeModel model; gdouble value;

model = gtk_combo_box_get_model (combo);

gtk_tree_model_get_iter_from_string (model, &iter, path); gtk_tree_model_get (model, &iter, THE_DOUBLE_VALUE_COLUMN, &value, -1);

return g_strdup_printf ("%g", value); } ]|

Params:
path the GtkTreePath string from the combo box's current model to format text for

Return:
a newly allocated string representing @path for the current GtkComboBox model.

Since:
3.4

gulong addOnMoveActive (void delegate(GtkScrollType, ComboBox) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
The ::move-active signal is a [keybinding signal][GtkBindingSignal] which gets emitted to move the active selection.

Params:
scrollType a #GtkScrollType

Since:
2.12

gulong addOnPopdown (bool delegate(ComboBox) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
The ::popdown signal is a [keybinding signal][GtkBindingSignal] which gets emitted to popdown the combo box list.

The default bindings for this signal are Alt+Up and Escape.

Since:
2.12

gulong addOnPopup (void delegate(ComboBox) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
The ::popup signal is a [keybinding signal][GtkBindingSignal] which gets emitted to popup the combo box list.

The default binding for this signal is Alt+Down.

Since:
2.12

Page was generated with on Fri Jan 6 23:09:19 2017