Adw.ViewSwitcherSidebar

g Adw.ViewSwitcherSidebar Adw.ViewSwitcherSidebar GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible 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.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Adw.ViewSwitcherSidebar

Subclasses:

None

Methods

Inherited:

Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (18), Gtk.Buildable (1)

Structs:

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

class

new ()

get_filter ()

get_mode ()

get_placeholder ()

get_stack ()

set_filter (filter)

set_mode (mode)

set_placeholder (placeholder)

set_stack (stack)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (7), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (35), Gtk.Accessible (1)

Name

Type

Flags

Short Description

filter

Gtk.Filter

r/w/en

mode

Adw.SidebarMode

r/w/en

placeholder

Gtk.Widget

r/w/en

stack

Adw.ViewStack

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

activated

Emitted when an item has been activated.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Adw.ViewSwitcherSidebar(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

Structure:

Adw.ViewSwitcherSidebarClass

An adaptive sidebar that controls an [class`ViewStack`].

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

AdwViewSwitcherSidebar is a view switcher implemented using a [class`Sidebar`], in a similar fashion to [class`Gtk`.StackSidebar].

AdwViewSwitcherSidebar items have an icon, a label, as well as an unread dot or a badge.

Unlike other switchers, AdwViewSwitcherSidebar supports grouping pages into sections, using the [property`ViewStackPage`:py:data::starts-section<Adw.ViewSwitcherSidebar.props.starts_section>] and [property`ViewStackPage`:py:data::section-title<Adw.ViewSwitcherSidebar.props.section_title>] properties.

Like [class`Sidebar`], AdwViewSwitcherSidebar is adaptive and can behave as a sidebar or a page, via the [property`ViewSwitcherSidebar`:py:data::mode<Adw.ViewSwitcherSidebar.props.mode>] property.

<picture> <source srcset=”view-switcher-sidebar-modes-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”view-switcher-sidebar-modes.png” alt=”view-switcher-sidebar-modes”> </picture>

Connect to the [signal`ViewSwitcherSidebar`:py:func:::activated<Adw.ViewSwitcherSidebar.signals.activated>] signal to run code when an item has been activated. This can be used to toggle the visible pane when used in a split view.

Like AdwSidebar, AdwViewSwitcherSidebar supports filtering items via the [property`ViewSwitcherSidebar`:py:data::filter<Adw.ViewSwitcherSidebar.props.filter>] property.

Use [property`ViewSwitcherSidebar`:py:data::placeholder<Adw.ViewSwitcherSidebar.props.placeholder>] to provide an empty state widget. It will be shown when all items have been filtered out, or the sidebar has no items otherwise.

CSS nodes

AdwViewSwitcherSidebar has a single CSS node with name view-switcher-sidebar.

See also: [class`ViewSwitcher`], [class`ViewSwitcherBar`], [class`InlineViewSwitcher`].

New in version 1.9.

classmethod new()
Returns:

the newly created AdwViewSwitcherSidebar

Return type:

Gtk.Widget

Creates a new AdwViewSwitcherSidebar.

New in version 1.9.

get_filter()
Returns:

the item filter

Return type:

Gtk.Filter or None

Gets the item filter for self.

New in version 1.9.

get_mode()
Returns:

the current mode

Return type:

Adw.SidebarMode

Gets self's look and behavior.

See [method`Sidebar`.get_mode].

New in version 1.9.

get_placeholder()
Returns:

the placeholder widget

Return type:

Gtk.Widget or None

Gets the placeholder widget for self.

New in version 1.9.

get_stack()
Returns:

The stack of self

Return type:

Adw.ViewStack or None

Gets the stack self controls.

New in version 1.9.

set_filter(filter)
Parameters:

filter (Gtk.Filter or None) – the item filter

Sets the item filter for self.

Can be used to implement search within the sidebar.

Use [property`ViewSwitcherSidebar`:py:data::placeholder<Adw.ViewSwitcherSidebar.props.placeholder>] to provide an empty state.

See [method`Sidebar`.set_filter].

New in version 1.9.

set_mode(mode)
Parameters:

mode (Adw.SidebarMode) – the new mode

Sets self's look and behavior.

If set to [enum`Adw`.SidebarMode.sidebar], behaves like a sidebar: with a sidebar style and a persistent selection.

If set to [enum`Adw`.SidebarMode.page], behaves like a page of boxed lists. In this mode, the selection is invisible and only tracked to determine the initially selected item once switched back to sidebar mode.

The page mode is intended to be used with [class`NavigationSplitView`] when collapsed, as the sidebar pane becomes a page there.

When used with [class`OverlaySplitView`], the sidebar should stay in sidebar mode, as the sidebar pane is still a sidebar when collapsed.

See [method`Sidebar`.set_mode].

New in version 1.9.

set_placeholder(placeholder)
Parameters:

placeholder (Gtk.Widget or None) – the placeholder widget

Sets the placeholder widget for self.

This widget will be shown if self has no items, or all of its items have been filtered out by [property`ViewSwitcherSidebar`:py:data::filter<Adw.ViewSwitcherSidebar.props.filter>].

See [method`Sidebar`.set_placeholder].

New in version 1.9.

set_stack(stack)
Parameters:

stack (Adw.ViewStack or None) – a stack

Sets the stack to control.

New in version 1.9.

Signal Details

Adw.ViewSwitcherSidebar.signals.activated(view_switcher_sidebar)
Signal Name:

activated

Flags:

RUN_LAST

Parameters:

view_switcher_sidebar (Adw.ViewSwitcherSidebar) – The object which received the signal

Emitted when an item has been activated.

New in version 1.9.

Property Details

Adw.ViewSwitcherSidebar.props.filter
Name:

filter

Type:

Gtk.Filter

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The item filter.

Can be used to implement search within the sidebar.

Use [property`ViewSwitcherSidebar`:py:data::placeholder<Adw.ViewSwitcherSidebar.props.placeholder>] to provide an empty state.

See [property`Sidebar`:py:data::filter<Adw.ViewSwitcherSidebar.props.filter>].

New in version 1.9.

Adw.ViewSwitcherSidebar.props.mode
Name:

mode

Type:

Adw.SidebarMode

Default Value:

Adw.SidebarMode.SIDEBAR

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Determines the sidebar’s look and behavior.

If set to [enum`Adw`.SidebarMode.sidebar], behaves like a sidebar: with a sidebar style and a persistent selection.

If set to [enum`Adw`.SidebarMode.page], behaves like a page of boxed lists.

The page mode is intended to be used with [class`NavigationSplitView`] when collapsed, as the sidebar pane becomes a page there.

When used with [class`OverlaySplitView`], the sidebar should stay in sidebar mode, as the sidebar pane is still a sidebar when collapsed.

See [property`Sidebar`:py:data::mode<Adw.ViewSwitcherSidebar.props.mode>].

New in version 1.9.

Adw.ViewSwitcherSidebar.props.placeholder
Name:

placeholder

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The placeholder widget.

This widget will be shown if the sidebar has no items, or all of its items have been filtered out by [property`ViewSwitcherSidebar`:py:data::filter<Adw.ViewSwitcherSidebar.props.filter>].

See [property`Sidebar`:py:data::placeholder<Adw.ViewSwitcherSidebar.props.placeholder>].

New in version 1.9.

Adw.ViewSwitcherSidebar.props.stack
Name:

stack

Type:

Adw.ViewStack

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The stack the sidebar controls.

New in version 1.9.