ComboBoxText

A GtkComboBoxText is a simple variant of GtkComboBox for text-only use cases.

An example GtkComboBoxText

GtkComboBoxText hides the model-view complexity of GtkComboBox.

To create a GtkComboBoxText, use [ctor@Gtk.ComboBoxText.new] or [ctor@Gtk.ComboBoxText.new_with_entry].

You can add items to a GtkComboBoxText with [method@Gtk.ComboBoxText.append_text], [method@Gtk.ComboBoxText.insert_text] or [method@Gtk.ComboBoxText.prepend_text] and remove options with [method@Gtk.ComboBoxText.remove].

If the GtkComboBoxText contains an entry (via the [property@Gtk.ComboBox:has-entry] property), its contents can be retrieved using [method@Gtk.ComboBoxText.get_active_text].

You should not call [method@Gtk.ComboBox.set_model] or attempt to pack more cells into this combo box via its [interface@Gtk.CellLayout] 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”.

Here is a UI definition fragment specifying GtkComboBoxText items:

<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>

CSS nodes

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

GtkComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.

Constructors

this
this(GtkComboBoxText* gtkComboBoxText, bool ownedRef)

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

append
void append(string id, string text)

Appends @text to the list of strings stored in @combo_box.

appendText
void appendText(string text)

Appends @text to the list of strings stored in @combo_box.

getActiveText
string getActiveText()

Returns the currently active string in @combo_box.

getComboBoxTextStruct
GtkComboBoxText* getComboBoxTextStruct(bool transferOwnership)

Get the main Gtk struct

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.

insertText
void insertText(int position, string text)

Inserts @text at @position in the list of strings stored in @combo_box.

prepend
void prepend(string id, string text)

Prepends @text to the list of strings stored in @combo_box.

prependText
void prependText(string text)

Prepends @text to the list of strings stored in @combo_box.

remove
void remove(int position)

Removes the string at @position from @combo_box.

removeAll
void removeAll()

Removes all the text entries from the combo box.

Static functions

getType
GType getType()

Variables

gtkComboBoxText
GtkComboBoxText* gtkComboBoxText;

the main Gtk struct

Inherited Members

From ComboBox

gtkComboBox
GtkComboBox* gtkComboBox;

the main Gtk struct

getComboBoxStruct
GtkComboBox* getComboBoxStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

__anonymous
mixin CellEditableT!(GtkComboBox)
Undocumented in source.
__anonymous
mixin CellLayoutT!(GtkComboBox)
Undocumented in source.
getType
GType getType()
getActive
int getActive()

Returns the index of the currently active item.

getActiveId
string getActiveId()

Returns the ID of the active row of @combo_box.

getActiveIter
bool getActiveIter(TreeIter iter)

Sets @iter to point to the currently active item.

getButtonSensitivity
GtkSensitivityType getButtonSensitivity()

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

getChild
Widget getChild()

Gets the child widget of @combo_box.

getEntryTextColumn
int getEntryTextColumn()

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

getHasEntry
bool getHasEntry()

Returns whether the combo box has an entry.

getIdColumn
int getIdColumn()

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

getModel
TreeModelIF getModel()

Returns the GtkTreeModel of @combo_box.

getPopupFixedWidth
bool getPopupFixedWidth()

Gets whether the popup uses a fixed width.

getRowSeparatorFunc
GtkTreeViewRowSeparatorFunc getRowSeparatorFunc()

Returns the current row separator function.

popdown
void popdown()

Hides the menu or dropdown list of @combo_box.

popup
void popup()

Pops up the menu or dropdown list of @combo_box.

popupForDevice
void popupForDevice(Device device)

Pops up the menu of @combo_box.

setActive
void setActive(int index)

Sets the active item of @combo_box to be the item at @index.

setActiveId
bool setActiveId(string activeId)

Changes the active row of @combo_box to the one that has an ID equal to @active_id.

setActiveIter
void setActiveIter(TreeIter iter)

Sets the current active item to be the one referenced by @iter.

setButtonSensitivity
void setButtonSensitivity(GtkSensitivityType sensitivity)

Sets whether the dropdown button of the combo box should update its sensitivity depending on the model contents.

setChild
void setChild(Widget child)

Sets the child widget of @combo_box.

setEntryTextColumn
void setEntryTextColumn(int textColumn)

Sets the model column which @combo_box should use to get strings from to be @text_column.

setIdColumn
void setIdColumn(int idColumn)

Sets the model column which @combo_box should use to get string IDs for values from.

setModel
void setModel(TreeModelIF model)

Sets the model used by @combo_box to be @model.

setPopupFixedWidth
void setPopupFixedWidth(bool fixed)

Specifies whether the popup’s width should be a fixed width.

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.

addOnChanged
gulong addOnChanged(void delegate(ComboBox) dlg, ConnectFlags connectFlags)

Emitted when the active item is changed.

addOnFormatEntryText
gulong addOnFormatEntryText(string delegate(string, ComboBox) dlg, ConnectFlags connectFlags)

Emitted to allow changing how the text in a combo box's entry is displayed.

addOnMoveActive
gulong addOnMoveActive(void delegate(GtkScrollType, ComboBox) dlg, ConnectFlags connectFlags)

Emitted to move the active selection.

addOnPopdown
gulong addOnPopdown(bool delegate(ComboBox) dlg, ConnectFlags connectFlags)

Emitted to popdown the combo box list.

addOnPopup
gulong addOnPopup(void delegate(ComboBox) dlg, ConnectFlags connectFlags)

Emitted to popup the combo box list.

Meta