Adw.ComboRow

g Adw.ActionRow Adw.ActionRow Adw.ComboRow Adw.ComboRow Adw.ActionRow->Adw.ComboRow Adw.PreferencesRow Adw.PreferencesRow Adw.PreferencesRow->Adw.ActionRow GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.ListBoxRow Gtk.ListBoxRow Gtk.Actionable->Gtk.ListBoxRow Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.ListBoxRow->Adw.PreferencesRow Gtk.Widget->Gtk.ListBoxRow

Subclasses:

None

Methods

Inherited:

Adw.ActionRow (17), Adw.PreferencesRow (9), Gtk.ListBoxRow (12), Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Actionable (5)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

get_enable_search ()

get_expression ()

get_factory ()

get_list_factory ()

get_model ()

get_selected ()

get_selected_item ()

get_use_subtitle ()

set_enable_search (enable_search)

set_expression (expression)

set_factory (factory)

set_list_factory (factory)

set_model (model)

set_selected (position)

set_use_subtitle (use_subtitle)

Virtual Methods

Inherited:

Adw.ActionRow (1), Gtk.ListBoxRow (1), Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.Actionable (4)

Properties

Inherited:

Adw.ActionRow (6), Adw.PreferencesRow (4), Gtk.ListBoxRow (3), Gtk.Widget (34), Gtk.Accessible (1), Gtk.Actionable (2)

Name

Type

Flags

Short Description

enable-search

bool

r/w/en

expression

Gtk.Expression

r/w/en

Expression to determine strings to search for

factory

Gtk.ListItemFactory

r/w/en

list-factory

Gtk.ListItemFactory

r/w/en

model

Gio.ListModel

r/w/en

selected

int

r/w/en

selected-item

GObject.Object

r

use-subtitle

bool

r/w/en

Signals

Inherited:

Adw.ActionRow (1), Gtk.ListBoxRow (1), Gtk.Widget (13), GObject.Object (1)

Fields

Inherited:

Adw.ActionRow (1), Gtk.ListBoxRow (1), Gtk.Widget (13), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Adw.ActionRow

r

Class Details

class Adw.ComboRow(**kwargs)
Bases:

Adw.ActionRow

Abstract:

No

Structure:

Adw.ComboRowClass

A [class`Gtk`.ListBoxRow] used to choose from a list of items.

<picture> <source srcset=”combo-row-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”combo-row.png” alt=”combo-row”> </picture>

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: ``xml <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 [property`ComboRow`:py:data::selected<Adw.ComboRow.props.selected>] and [property`ComboRow`:py:data::selected-item<Adw.ComboRow.props.selected_item>] properties can be used to keep track of the selected item and react to their changes.

AdwComboRow mirrors [class`Gtk`.DropDown], see that widget for details.

AdwComboRow is [property`Gtk`.ListBoxRow: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 [class`Gtk`.ScrolledWindow], which in turn contains a [class`Gtk`.ListView], both are accessible via their regular nodes.

Accessibility

AdwComboRow uses the GTK_ACCESSIBLE_ROLE_COMBO_BOX role.

classmethod new()
Returns:

the newly created AdwComboRow

Return type:

Gtk.Widget

Creates a new AdwComboRow.

Returns:

whether the popup includes a search entry

Return type:

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 [property`ComboRow`:py:data::expression<Adw.ComboRow.props.expression>] to be set.

New in version 1.4.

get_expression()
Returns:

the expression used to obtain strings from items

Return type:

Gtk.Expression or None

Gets the expression used to obtain strings from items.

get_factory()
Returns:

the factory in use

Return type:

Gtk.ListItemFactory or None

Gets the factory for populating list items.

get_list_factory()
Returns:

the factory in use

Return type:

Gtk.ListItemFactory or None

Gets the factory for populating list items in the popup.

get_model()
Returns:

The model in use

Return type:

Gio.ListModel or None

Gets the model that provides the displayed items.

get_selected()
Returns:

the position of the selected item, or [const`Gtk`.INVALID_LIST_POSITION] if no item is selected

Return type:

int

Gets the position of the selected item.

get_selected_item()
Returns:

the selected item

Return type:

GObject.Object or None

Gets the selected item.

get_use_subtitle()
Returns:

whether to use the current value as the subtitle

Return type:

bool

Gets whether to use the current value as the subtitle.

Parameters:

enable_search (bool) – whether to enable search

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 [property`ComboRow`:py:data::expression<Adw.ComboRow.props.expression>] to be set.

New in version 1.4.

set_expression(expression)
Parameters:

expression (Gtk.Expression or None) – an expression

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 [property`ComboRow`:py:data::factory<Adw.ComboRow.props.factory>] is not set, or when [property`ComboRow`:py:data::use-subtitle<Adw.ComboRow.props.use_subtitle>] is set to TRUE.

set_factory(factory)
Parameters:

factory (Gtk.ListItemFactory or None) – the factory to use

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 [property`ComboRow`:py:data::list-factory<Adw.ComboRow.props.list_factory>] is set.

set_list_factory(factory)
Parameters:

factory (Gtk.ListItemFactory or None) – the factory to use

Sets the factory for populating list items in the popup.

If this is not set, [property`ComboRow`:py:data::factory<Adw.ComboRow.props.factory>] is used.

set_model(model)
Parameters:

model (Gio.ListModel or None) – the model to use

Sets the model that provides the displayed items.

set_selected(position)
Parameters:

position (int) – the position of the item to select, or [const`Gtk`.INVALID_LIST_POSITION]

Selects the item at the given position.

set_use_subtitle(use_subtitle)
Parameters:

use_subtitle (bool) – whether to use the current value as the subtitle

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 [property`ComboRow`:py:data::expression<Adw.ComboRow.props.expression>].

If set to TRUE, you should not access [property`ActionRow`:py:data::subtitle<Adw.ComboRow.props.subtitle>].

The subtitle is interpreted as Pango markup if [property`PreferencesRow`:py:data::use-markup<Adw.ComboRow.props.use_markup>] is set to TRUE.

Property Details

Name:

enable-search

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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 [property`ComboRow`:py:data::expression<Adw.ComboRow.props.expression>] to be set.

New in version 1.4.

Adw.ComboRow.props.expression
Name:

expression

Type:

Gtk.Expression

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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 [property`ComboRow`:py:data::factory<Adw.ComboRow.props.factory>] is not set, or when [property`ComboRow`:py:data::use-subtitle<Adw.ComboRow.props.use_subtitle>] is set to TRUE.

Adw.ComboRow.props.factory
Name:

factory

Type:

Gtk.ListItemFactory

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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 [property`ComboRow`:py:data::list-factory<Adw.ComboRow.props.list_factory>] is set.

Adw.ComboRow.props.list_factory
Name:

list-factory

Type:

Gtk.ListItemFactory

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The factory for populating list items in the popup.

If this is not set, [property`ComboRow`:py:data::factory<Adw.ComboRow.props.factory>] is used.

Adw.ComboRow.props.model
Name:

model

Type:

Gio.ListModel

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The model that provides the displayed items.

Adw.ComboRow.props.selected
Name:

selected

Type:

int

Default Value:

4294967295

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The position of the selected item.

If no item is selected, the property has the value [const`Gtk`.INVALID_LIST_POSITION]

Adw.ComboRow.props.selected_item
Name:

selected-item

Type:

GObject.Object

Default Value:

None

Flags:

READABLE

The selected item.

Adw.ComboRow.props.use_subtitle
Name:

use-subtitle

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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 [property`ComboRow`:py:data::expression<Adw.ComboRow.props.expression>].

If set to TRUE, you should not access [property`ActionRow`:py:data::subtitle<Adw.ComboRow.props.subtitle>].

The subtitle is interpreted as Pango markup if [property`PreferencesRow`:py:data::use-markup<Adw.ComboRow.props.use_markup>] is set to TRUE.