Handy.ComboRow

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.ListBoxRow Gtk.ListBoxRow Gtk.Actionable->Gtk.ListBoxRow Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.ListBoxRow Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Handy.PreferencesRow Handy.PreferencesRow Gtk.ListBoxRow->Handy.PreferencesRow Gtk.Widget->Gtk.Container Handy.ActionRow Handy.ActionRow Handy.ComboRow Handy.ComboRow Handy.ActionRow->Handy.ComboRow Handy.PreferencesRow->Handy.ActionRow

Subclasses:

None

Methods

Inherited:

Handy.ActionRow (15), Handy.PreferencesRow (5), Gtk.ListBoxRow (10), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Actionable (5)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

bind_model (model, create_list_widget_func, create_current_widget_func, *user_data)

bind_name_model (model, get_name_func, *user_data)

get_model ()

get_selected_index ()

get_use_subtitle ()

set_for_enum (enum_type, get_name_func, *user_data)

set_get_name_func (get_name_func, *user_data)

set_selected_index (selected_index)

set_use_subtitle (use_subtitle)

Virtual Methods

Inherited:

Handy.ActionRow (1), Gtk.ListBoxRow (1), Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Actionable (4)

Properties

Inherited:

Handy.ActionRow (5), Handy.PreferencesRow (2), Gtk.ListBoxRow (2), Gtk.Container (3), Gtk.Widget (39), Gtk.Actionable (2)

Name

Type

Flags

Short Description

selected-index

int

r/w/en

The index of the selected item

use-subtitle

bool

r/w/en

Set the current value as the subtitle

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Handy.ActionRow (1), Gtk.ListBoxRow (1), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Fields

Inherited:

Handy.ActionRow (1), Gtk.ListBoxRow (1), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Handy.ActionRow

r

Class Details

class Handy.ComboRow(**kwargs)
Bases:

Handy.ActionRow

Abstract:

No

Structure:

Handy.ComboRowClass

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

The HdyComboRow 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.

The [class`ComboRow`] uses the model-view pattern; the list of valid choices is specified in the form of a [iface`Gio`.ListModel], and the display of the choices can be adapted to the data in the model via widget creation functions.

HdyComboRow is [property`Gtk`.ListBoxRow:activatable] if a model is set.

CSS nodes

HdyComboRow has a main CSS node with name row.

Its popover has the node name popover with the .combo style class, it contains a [class`Gtk`.ScrolledWindow], which in turn contains a [class`Gtk`.ListBox], both are accessible via their regular nodes.

A checkmark of node and style class image.checkmark in the popover denotes the current item.

New in version 1.0.

classmethod new()
Returns:

the newly created HdyComboRow

Return type:

Gtk.Widget

Creates a new HdyComboRow.

New in version 1.0.

bind_model(model, create_list_widget_func, create_current_widget_func, *user_data)
Parameters:
  • model (Gio.ListModel or None) – the [iface`Gio`.ListModel] to be bound to self

  • create_list_widget_func (Gtk.ListBoxCreateWidgetFunc or None) – a function that creates widgets for items to display in the list, or NULL in case you also passed NULL as model

  • create_current_widget_func (Gtk.ListBoxCreateWidgetFunc or None) – a function that creates widgets for items to display as the selected item, or NULL in case you also passed NULL as model

  • user_data (object or None) – user data passed to create_list_widget_func and create_current_widget_func

Binds model to self.

If self was already bound to a model, that previous binding is destroyed.

The contents of self are cleared and then filled with widgets that represent items from model. self is updated whenever model changes. If model is NULL, self is left empty.

New in version 1.0.

bind_name_model(model, get_name_func, *user_data)
Parameters:
  • model (Gio.ListModel or None) – the [iface`Gio`.ListModel] to be bound to self

  • get_name_func (Handy.ComboRowGetNameFunc or None) – a function that creates names for items, or NULL in case you also passed NULL as model

  • user_data (object or None) – user data passed to get_name_func

Binds model to self.

If self was already bound to a model, that previous binding is destroyed.

The contents of self are cleared and then filled with widgets that represent items from model. self is updated whenever model changes. If model is NULL, self is left empty.

This is more convenient to use than [method`ComboRow`.bind_model] if you want to represent items of the model with names.

New in version 1.0.

get_model()
Returns:

the [iface`Gio`.ListModel] bound to self

Return type:

Gio.ListModel or None

Gets the model bound to self.

New in version 1.0.

get_selected_index()
Returns:

the index of the selected item, or -1 if no item is selected

Return type:

int

Gets the index of the selected item in its [iface`Gio`.ListModel].

New in version 1.0.

get_use_subtitle()
Returns:

whether the current value of self should be displayed as its subtitle

Return type:

bool

Gets whether the current value of self should be displayed as its subtitle.

New in version 1.0.

set_for_enum(enum_type, get_name_func, *user_data)
Parameters:

Creates a model for enum_type and binds it to self.

The items of the model will be [class`EnumValueObject`] objects.

If self was already bound to a model, that previous binding is destroyed.

The contents of self are cleared and then filled with widgets that represent items from model. self is updated whenever model changes. If model is NULL, self is left empty.

This is more convenient to use than [method`ComboRow`.bind_name_model] if you want to represent values of an enumeration with names.

See [func`enum_value_row_name`].

New in version 1.0.

set_get_name_func(get_name_func, *user_data)
Parameters:
  • get_name_func (Handy.ComboRowGetNameFunc or None) – a function that creates names for items, or NULL in case you also passed NULL as model

  • user_data (object or None) – user data passed to get_name_func

Sets a closure to convert items into names.

See [property`ComboRow`:py:data::use-subtitle<Handy.ComboRow.props.use_subtitle>].

New in version 1.0.

set_selected_index(selected_index)
Parameters:

selected_index (int) – the index of the selected item

Sets the index of the selected item in its [iface`Gio`.ListModel].

New in version 1.0.

set_use_subtitle(use_subtitle)
Parameters:

use_subtitle (bool) – TRUE to set the current value as the subtitle

Sets whether the current value of self should be displayed as its subtitle.

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

New in version 1.0.

Property Details

Handy.ComboRow.props.selected_index
Name:

selected-index

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The index of the selected item in its [iface`Gio`.ListModel].

New in version 1.0.

Handy.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 widget creation function, you will need to give the row a name conversion closure with [method`ComboRow`.set_get_name_func].

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

New in version 1.0.