`GtkDropDown` is a widget that allows the user to choose an item from a list of options.
![An example GtkDropDown](drop-down.png)
The `GtkDropDown` displays the selected choice.
The options are given to `GtkDropDown` in the form of `GListModel` and how the individual options are represented is determined by a [
[email protected]]. The default factory displays simple strings.
`GtkDropDown` knows how to obtain strings from the items in a [[email protected]]; for other models, you have to provide an expression
to find the strings via [[email protected]_expression].
`GtkDropDown` can optionally allow search in the popup, which is useful if the list of options is long. To enable the search entry, use [
[email protected]_enable_search].
Here is a UI definition example for `GtkDropDown` with a simple model: ```xml <object class="GtkDropDown"> <property
name="model"> <object class="GtkStringList"> <items> <item translatable="yes">Factory</item> <item
translatable="yes">Home</item> <item translatable="yes">Subway</item> </items> </object> <
/property> </object> ```
CSS nodes
`GtkDropDown` has a single CSS node with name dropdown, with the button and popover nodes as children.
Accessibility
`GtkDropDown` uses the gtk_accessible_role_combo_box role.
- public bool get_enable_search ()
Returns whether search is enabled.
- public unowned Expression? get_expression ()
Gets the expression set that is used to obtain strings from items.
- public unowned ListItemFactory? get_factory ()
Gets the factory that's currently used to populate list items.
- public unowned ListItemFactory? get_list_factory ()
Gets the factory that's currently used to populate list items in the
popup.
- public unowned ListModel? get_model ()
Gets the model that provides the displayed items.
- public uint get_selected ()
Gets the position of the selected item.
- public unowned Object? get_selected_item ()
Gets the selected item.
- public bool get_show_arrow ()
Returns whether to show an arrow within the widget.
- public void set_enable_search (bool enable_search)
Sets whether a search entry will be shown in the popup that allows to
search for items in the list.
- public void set_expression (Expression? expression)
Sets the expression that gets evaluated to obtain strings from items.
- public void set_factory (ListItemFactory? factory)
Sets the `GtkListItemFactory` to use for populating list items.
- public void set_list_factory (ListItemFactory? factory)
Sets the `GtkListItemFactory` to use for populating list items in the
popup.
- public void set_model (ListModel? model)
Sets the `GListModel` to use.
- public void set_selected (uint position)
Selects the item at the given position.
- public void set_show_arrow (bool show_arrow)
Sets whether an arrow will be displayed within the widget.