It derives from <GtkWidget>.
Allows the user to choose an item from a list of options.
The <GtkDropDown> displays the
[selected]drop-down:selected
choice.
The options are given to <GtkDropDown> in the
form of <GListModel> and how the individual
options are represented is determined by a
<GtkListItemFactory>. The default factory
displays simple strings, and adds a checkmark to the selected item in
the popup.
To set your own factory, use drop-down:set-factory. It is possible to use a separate
factory for the items in the popup, with drop-down:set-list-factory.
<GtkDropDown> knows how to obtain strings from
the items in a <GtkStringList>; for other
models, you have to provide an expression to find the strings via
drop-down:set-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 drop-down:set-enable-search.
Here is a UI definition example for <GtkDropDown>
with a simple model:
<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>
If a <GtkDropDown> is created in this manner, or
with drop-down:new-from-strings,
for instance, the object returned from drop-down:get-selected-item will be a
<GtkStringObject>.
To learn more about the list widget framework, see the overview.
<GtkDropDown> has a single CSS node with name
dropdown, with the button and popover nodes as children.
<GtkDropDown> uses the
Gtk.AccessibleRole.combo_box role.
Whether to show a search entry in the popup.
Note that search requires drop-down:expression to be set.
Its value is a boolean.
Set it with (set! (drop-down:enable-search self) value).
An expression to evaluate to obtain strings to match against the search term.
See drop-down:enable-search for how to enable search. If
drop-down:factory is not set,
the expression is also used to bind strings to labels produced by a
default factory.
Its value is a <GtkExpression>, or #f.
Set it with (set! (drop-down:expression self) value).
Factory for populating list items.
Its value is a <GtkListItemFactory>, or
#f.
Set it with (set! (drop-down:factory self) value).
The factory for creating header widgets for the popup.
Its value is a <GtkListItemFactory>, or
#f.
Set it with (set! (drop-down:header-factory self) value).
The factory for populating list items in the popup.
If this is not set, drop-down:factory is used.
Its value is a <GtkListItemFactory>, or
#f.
Set it with (set! (drop-down:list-factory self) value).
Model for the displayed items.
Its value is a <GListModel>, or #f.
Set it with (set! (drop-down:model self) value).
The match mode for the search filter.
Its value is a
<GtkStringFilterMatchMode> (or, to
set it, one of its symbols).
Set it with (set! (drop-down:search-match-mode self) value).
The position of the selected item.
If no item is selected, the property has the value
GTK_INVALID_LIST_POSITION.
Its value is an unsigned 32-bit integer.
Set it with (set! (drop-down:selected self) value).
The selected item.
Its value is a <GObject>, or #f.
It is read only.
Whether to show an arrow within the GtkDropDown widget.
Its value is a boolean.
Set it with (set! (drop-down:show-arrow self) value).
Returns whether search is enabled.
Passed: a <GtkDropDown>.
Returned: a boolean.
#t if the popup includes a search entry
Gets the expression set that is used to obtain strings from items.
Passed: a <GtkDropDown>.
Returned: a <GtkExpression>, or #f.
Gets the factory that’s currently used to populate list items.
The factory returned by this function is always used for the item in the
button. It is also used for items in the popup if drop-down:list-factory is not set.
Passed: a <GtkDropDown>.
Returned: a <GtkListItemFactory>, or
#f.
The factory in use
Gets the factory that’s currently used to create header widgets for the popup.
Passed: a <GtkDropDown>.
Returned: a <GtkListItemFactory>, or
#f.
The factory in use
Gets the factory that’s currently used to populate list items in the popup.
Passed: a <GtkDropDown>.
Returned: a <GtkListItemFactory>, or
#f.
The factory in use
Gets the model that provides the displayed items.
Passed: a <GtkDropDown>.
Returned: a <GListModel>, or #f.
The model in use
Returns the match mode that the search filter is using.
Passed: a <GtkDropDown>.
Returned: a
<GtkStringFilterMatchMode>.
the match mode of the search filter
Gets the position of the selected item.
Passed: a <GtkDropDown>.
Returned: an unsigned 32-bit integer.
the position of the selected item, or GTK_INVALID_LIST_POSITION
if no item is selected
Gets the selected item. If no item is selected, #f is returned.
Passed: a <GtkDropDown>.
Returned: a <GObject>, or #f.
The selected item
Returns whether to show an arrow within the widget.
Passed: a <GtkDropDown>.
Returned: a boolean.
#t if an arrow will be shown.
Creates a new <GtkDropDown>.
You may want to call drop-down:set-factory to set up a way to map its items to
widgets.
Passed, or left out: a <GListModel>, or
#f.
the model to use
Passed, or left out: a <GtkExpression>, or
#f.
the expression to use
Returned: a <GtkWidget>.
a new <GtkDropDown>
Creates a new <GtkDropDown> that is populated
with the strings.
Passed: a list or vector, each a string.
The strings to put in the dropdown
Returned: a <GtkWidget>.
a new <GtkDropDown>
Sets whether a search entry will be shown in the popup that allows to search for items in the list.
Note that drop-down:expression must be set for search to work.
Passed: a <GtkDropDown>.
Passed: a boolean.
whether to enable search
Sets the expression that gets evaluated to obtain strings from items.
This is used for search in the popup. The expression must have a value
type of G_TYPE_STRING.
Passed: a <GtkDropDown>.
Passed, or left out: a <GtkExpression>, or
#f.
Sets the <GtkListItemFactory> to use for
populating list items.
Passed: a <GtkDropDown>.
Passed, or left out: a
<GtkListItemFactory>, or #f.
the factory to use
Sets the <GtkListItemFactory> to use for
creating header widgets for the popup.
Passed: a <GtkDropDown>.
Passed, or left out: a
<GtkListItemFactory>, or #f.
the factory to use
Sets the <GtkListItemFactory> to use for
populating list items in the popup.
Passed: a <GtkDropDown>.
Passed, or left out: a
<GtkListItemFactory>, or #f.
the factory to use
Sets the <GListModel> to use.
Passed: a <GtkDropDown>.
Passed, or left out: a <GListModel>, or
#f.
the model to use
Sets the match mode for the search filter.
Passed: a <GtkDropDown>.
Passed: a
<GtkStringFilterMatchMode>, or one
of its symbols.
the new match mode
Selects the item at the given position.
Passed: a <GtkDropDown>.
Passed: an unsigned 32-bit integer.
the position of the item to select, or GTK_INVALID_LIST_POSITION
Sets whether an arrow will be displayed within the widget.
Passed: a <GtkDropDown>.
Passed: a boolean.
whether to show an arrow within the widget
Connect a handler with (connect object drop-down:activate
handler). It is called as (handler self).
Emitted to when the drop down is activated.
The ::activate signal on <GtkDropDown> is
an action signal and emitting it causes the drop down to pop up its
dropdown.
Passed: a <GtkDropDown>.