Package: gtk

Class gtk:drop-down

Superclasses

Documented Subclasses

None

Direct Slots

enable-search
The enable-search property of type :boolean (Read / Write)
Whether to show a search entry in the popup. Note that search requires the expression property to be set.
Default value: false
expression
The expression property of type gtk:expression (Read / Write)
The expression to evaluate to obtain strings to match against the search term See the enable-search property. If the factory property is not set, the expression is also used to bind strings to labels produced by a default factory.
Default value: NULL
factory
The factory property of type gtk:list-item-factory (Read / Write)
The factory for populating list items.
header-factory
The header-factory property of type gtk:list-item-factory (Read / Write)
The factory for creating header widgets for the popup. Since 4.12
list-factory
The list-factory property of type gtk:list-item-factory (Read / Write)
The factory for populating list items in the popup. If this is not set, the factory property is used.
model
The model property of type g:list-model (Read / Write)
The model for the displayed items.
search-match-mode
The search-match-mode property of type gtk:string-filter-match-mode (Read / Write)
The match mode for the search filter. Since 4.12
Default value: :prefix
selected
The selected property of type :uint (Read / Write)
The position of the selected item in model, or gtk:+invalid-list-position+ if no item is selected.
Default value: gtk:+invalid-list-position+
selected-item
The selected-item property of type g:object (Read)
The selected item.
show-arrow
The show-arrow property of type :boolean (Read / Write)
Whether to show an arrow within the dropdown. Since 4.6
Default value: true

Details

The gtk:drop-down widget is a widget that allows the user to choose an item from a list of options. The gtk:drop-down widget displays the selected choice.


Figure: GtkDropDown


The options are given to the gtk:drop-down widget in the form of a g:list-model object, and how the individual options are represented is determined by a gtk:list-item-factory object. The default factory displays simple strings, and adds a checkmark to the selected item in the popup.

To set your own factory, use the gtk:drop-down-factory function. It is possible to use a separate factory for the items in the popup, with the gtk:drop-down-list-factory function.

The gtk:drop-down widget knows how to obtain strings from the items in a gtk:string-list object. For other models, you have to provide an expression to find the strings via the gtk:drop-down-expression function.

The gtk:drop-down widget can optionally allow search in the popup, which is useful if the list of options is long. To enable the search entry, use the gtk:drop-down-enable-search function.

To learn more about the list widget framework, see the List Widget overview.

Examples

This is a UI definition example for gtk:drop-down widget 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 gtk:drop-down widget is created in this manner, or with the gtk:drop-down-new-from-strings function, for instance, the object returned from the gtk:drop-down-selected-item function will be a gtk:string-object object.

CSS nodes

The gtk:drop-down implementation has a single CSS node with name dropdown, with the button and popover nodes as children.

Accessibility

The gtk:drop-down implementation uses the :combo-box role of the gtk:accessible-role enumeration.

Signals

The "activate" signal
lambda (dropdown)    :action      
dropdown
The gtk:drop-down widget.
The signal is an action signal. Emitting it causes the popup to appear. The default handler is invoked before any handlers added using the g:signal-connect function. Since 4.6
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2026-04-12