adw.view_switcher

Module for [ViewSwitcher] class

Types 3

An adaptive view switcher.

view-switcher

An adaptive view switcher designed to switch between multiple views contained in a class@ViewStack in a similar fashion to [gtk.stack_switcher.StackSwitcher].

[adw.view_switcher.ViewSwitcher] buttons always have an icon and a label. They can be displayed side by side, or icon on top of the label. This can be controlled via the property@ViewSwitcher:policy property.

[adw.view_switcher.ViewSwitcher] is intended to be used in a header bar together with class@ViewSwitcherBar at the bottom of the window, and a class@Breakpoint showing the view switcher bar on narrow sizes, while removing the view switcher from the header bar, as follows:

<object class="AdwWindow">
 <property name="width-request">360</property>
 <property name="height-request">200</property>
 <child>
   <object class="AdwBreakpoint">
     <condition>max-width: 550sp</condition>
     <setter object="switcher_bar" property="reveal">True</setter>
     <setter object="header_bar" property="title-widget"/>
   </object>
 </child>
 <property name="content">
   <object class="AdwToolbarView">
     <child type="top">
       <object class="AdwHeaderBar" id="header_bar">
         <property name="title-widget">
           <object class="AdwViewSwitcher">
             <property name="stack">stack</property>
             <property name="policy">wide</property>
           </object>
         </property>
       </object>
     </child>
     <property name="content">
       <object class="AdwViewStack" id="stack"/>
     </property>
     <child type="bottom">
       <object class="AdwViewSwitcherBar" id="switcher_bar">
         <property name="stack">stack</property>
       </object>
     </child>
   </object>
 </property>
</object>

It's recommended to set property@ViewSwitcher:policy to [adw.types.ViewSwitcherPolicy.Wide] in this case.

You may have to adjust the breakpoint condition for your specific pages.

CSS nodes

[adw.view_switcher.ViewSwitcher] has a single CSS node with name viewswitcher. It can have the style classes .wide and .narrow, matching its policy.

Accessibility

[adw.view_switcher.ViewSwitcher] uses the [gtk.types.AccessibleRole.TabList] role and uses the [gtk.types.AccessibleRole.Tab] for its buttons.

Methods
GType _gType() @property
ViewSwitcher self()Returns `this`, for use in `with` statements.
ViewSwitcherGidBuilder builder()Get builder for [adw.view_switcher.ViewSwitcher] Returns: New builder object
adw.types.ViewSwitcherPolicy policy() @propertyGet `policy` property. Returns: The policy to determine which mode to use.
void policy(adw.types.ViewSwitcherPolicy propval) @propertySet `policy` property. Params: propval = The policy to determine which mode to use.
adw.view_stack.ViewStack stack() @propertyGet `stack` property. Returns: The stack the view switcher controls.
void stack(adw.view_stack.ViewStack propval) @propertySet `stack` property. Params: propval = The stack the view switcher controls.
adw.types.ViewSwitcherPolicy getPolicy()Gets the policy of self. Returns: the policy of self
adw.view_stack.ViewStack getStack()Gets the stack controlled by self. Returns: the stack
void setPolicy(adw.types.ViewSwitcherPolicy policy)Sets the policy of self.
void setStack(adw.view_stack.ViewStack stack = null)Sets the stack controlled by self.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [adw.viewswitcher.ViewSwitcher]. Returns: the newly created [adw.viewswitcher.ViewSwitcher]
Methods
T policy(adw.types.ViewSwitcherPolicy propval)Set `policy` property. Params: propval = The policy to determine which mode to use. Returns: Builder instance for fluent chaining
T stack(adw.view_stack.ViewStack propval)Set `stack` property. Params: propval = The stack the view switcher controls. Returns: Builder instance for fluent chaining

Fluent builder for [adw.view_switcher.ViewSwitcher]