ComboRow

class ComboRow(**properties: Any)

Superclasses: ActionRow, PreferencesRow, ListBoxRow, Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Actionable, Buildable, ConstraintTarget

A ListBoxRow used to choose from a list of items.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/combo-row.png

The AdwComboRow widget allows the user to choose from a list of valid choices. The row displays the selected choice. When activated, the row displays a popover which allows the user to make a new choice.

Example of an AdwComboRow UI definition:

<object class="AdwComboRow">
  <property name="title" translatable="yes">Combo Row</property>
  <property name="model">
    <object class="GtkStringList">
      <items>
        <item translatable="yes">Foo</item>
        <item translatable="yes">Bar</item>
        <item translatable="yes">Baz</item>
      </items>
    </object>
  </property>
</object>

The selected and selected_item properties can be used to keep track of the selected item and react to their changes.

AdwComboRow mirrors DropDown, see that widget for details.

AdwComboRow is activatable if a model is set.

CSS nodes

AdwComboRow has a main CSS node with name row and the .combo style class.

Its popover has the node named popover with the .menu style class, it contains a ScrolledWindow, which in turn contains a ListView, both are accessible via their regular nodes.

Accessibility

AdwComboRow uses the GTK_ACCESSIBLE_ROLE_COMBO_BOX role.

Constructors

class ComboRow
classmethod new() Widget

Creates a new AdwComboRow.

Methods

class ComboRow

Gets whether search is enabled.

If set to TRUE, a search entry will be shown in the popup that allows to search for items in the list.

Search requires expression to be set.

Added in version 1.4.

get_expression() Expression | None

Gets the expression used to obtain strings from items.

get_factory() ListItemFactory | None

Gets the factory for populating list items.

get_list_factory() ListItemFactory | None

Gets the factory for populating list items in the popup.

get_model() ListModel | None

Gets the model that provides the displayed items.

get_selected() int

Gets the position of the selected item.

get_selected_item() Object | None

Gets the selected item.

get_use_subtitle() bool

Gets whether to use the current value as the subtitle.

Sets whether to enable search.

If set to TRUE, a search entry will be shown in the popup that allows to search for items in the list.

Search requires expression to be set.

Added in version 1.4.

Parameters:

enable_search – whether to enable search

set_expression(expression: Expression | None = None) None

Sets the expression used to obtain strings from items.

The expression must have a value type of G_TYPE_STRING.

It’s used to bind strings to labels produced by the default factory if factory is not set, or when use_subtitle is set to TRUE.

Parameters:

expression – an expression

set_factory(factory: ListItemFactory | None = None) None

Sets the factory for populating list items.

This factory is always used for the item in the row. It is also used for items in the popup unless list_factory is set.

Parameters:

factory – the factory to use

set_list_factory(factory: ListItemFactory | None = None) None

Sets the factory for populating list items in the popup.

If this is not set, factory is used.

Parameters:

factory – the factory to use

set_model(model: ListModel | None = None) None

Sets the model that provides the displayed items.

Parameters:

model – the model to use

set_selected(position: int) None

Selects the item at the given position.

Parameters:

position – the position of the item to select, or INVALID_LIST_POSITION

set_use_subtitle(use_subtitle: bool) None

Sets whether to use the current value as the subtitle.

If you use a custom list item factory, you will need to give the row a name conversion expression with expression.

If set to TRUE, you should not access subtitle.

The subtitle is interpreted as Pango markup if use_markup is set to TRUE.

Parameters:

use_subtitle – whether to use the current value as the subtitle

Properties

class ComboRow

Whether to show a search entry in the popup.

If set to TRUE, a search entry will be shown in the popup that allows to search for items in the list.

Search requires expression to be set.

Added in version 1.4.

props.expression: Expression

An expression used to obtain strings from items.

The expression must have a value type of G_TYPE_STRING.

It’s used to bind strings to labels produced by the default factory if factory is not set, or when use_subtitle is set to TRUE.

props.factory: ListItemFactory

Factory for populating list items.

This factory is always used for the item in the row. It is also used for items in the popup unless list_factory is set.

props.list_factory: ListItemFactory

The factory for populating list items in the popup.

If this is not set, factory is used.

props.model: ListModel

The model that provides the displayed items.

props.selected: int

The position of the selected item.

If no item is selected, the property has the value INVALID_LIST_POSITION

props.selected_item: Object

The selected item.

props.use_subtitle: bool

Whether to use the current value as the subtitle.

If you use a custom list item factory, you will need to give the row a name conversion expression with expression.

If set to TRUE, you should not access subtitle.

The subtitle is interpreted as Pango markup if use_markup is set to TRUE.

Fields

class ComboRow
parent_instance