ComboRow
Superclasses: ActionRow
, PreferencesRow
, ListBoxRow
, Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Actionable
, Buildable
, ConstraintTarget
A ListBoxRow
used to choose from a list of items.
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
Methods
- class ComboRow
- get_enable_search() bool
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.
- set_enable_search(enable_search: bool) None
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 whenuse_subtitle
is set toTRUE
.- 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 accesssubtitle
.The subtitle is interpreted as Pango markup if
use_markup
is set toTRUE
.- Parameters:
use_subtitle – whether to use the current value as the subtitle
Properties
- class ComboRow
- props.enable_search: bool
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 whenuse_subtitle
is set toTRUE
.
- 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.selected: int
The position of the selected item.
If no item is selected, the property has the value
INVALID_LIST_POSITION
- 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 accesssubtitle
.The subtitle is interpreted as Pango markup if
use_markup
is set toTRUE
.
Fields
- class ComboRow
- parent_instance