MultiLayoutView#

Added in version 1.6.

class MultiLayoutView(**properties: Any)#

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

A widget for switching between different layouts.

AdwMultiLayoutView contains layouts and children. Each child has an ID, each layout has slots inside it, each slot also has an ID. When switching layouts, children are inserted into slots with matching IDs. The visible property of each slot is updated to match that of the inserted child.

This can be useful for rearranging children when it’s difficult to do so otherwise, for example to move a child from a sidebar to a bottom bar.

The currently used layout can be switched using the layout or layout_name properties. For example, it can be done via a Breakpoint setter to change layouts depending on the window size.

AdwMultiLayoutView as GtkBuildable#

The AdwMultiLayoutView implementation of the Buildable interface supports adding layouts via <child> element with the type attribute omitted.

It also supports setting children via <child type="ID">.

Example of an AdwMultiLayoutView UI definition that can display a secondary child as either a sidebar or a bottom sheet.

<object class="AdwMultiLayoutView">
  <child>
    <object class="AdwLayout">
      <property name="name">sidebar</property>
      <property name="content">
        <object class="AdwOverlaySplitView">
          <property name="sidebar">
            <object class="AdwLayoutSlot">
              <property name="id">secondary</property>
            </object>
          </property>
          <property name="content">
            <object class="AdwLayoutSlot">
              <property name="id">primary</property>
            </object>
          </property>
        </object>
      </property>
    </object>
  </child>
  <child>
    <object class="AdwLayout">
      <property name="name">bottom-sheet</property>
      <property name="content">
        <object class="AdwBottomSheet">
          <property name="open">True</property>
          <property name="content">
            <object class="AdwLayoutSlot">
              <property name="id">primary</property>
            </object>
          </property>
          <property name="sheet">
            <object class="AdwLayoutSlot">
              <property name="id">secondary</property>
            </object>
          </property>
        </object>
      </property>
    </object>
  </child>
  <child type="primary">
    <!-- ... -->
  </child>
  <child type="secondary">
    <!-- ... -->
  </child>
</object>

CSS nodes#

AdwMultiLayoutView has a single CSS node with name multi-layout-view.

Constructors#

class MultiLayoutView
classmethod new() Widget#

Creates a new AdwMultiLayoutView.

Added in version 1.6.

Methods#

class MultiLayoutView
add_layout(layout: Layout) None#

Adds layout to self.

Added in version 1.6.

Parameters:

layout – the layout to add

get_child(id: str) Widget | None#

Gets the child for id to self.

Added in version 1.6.

Parameters:

id – the id of the child

get_layout() Layout | None#

Gets the currently used layout of self.

Added in version 1.6.

get_layout_by_name(name: str) Layout | None#

Gets layout with the name name from self, or NULL if it doesn’t exist.

See name.

Added in version 1.6.

Parameters:

name – the name of the layout

get_layout_name() str | None#

Returns the name of the currently used layout of self.

Added in version 1.6.

remove_layout(layout: Layout) None#

Removes layout from self.

Added in version 1.6.

Parameters:

layout – the layout to add

set_child(id: str, child: Widget) None#

Sets child as the child for id in self.

When changing layouts, it will be inserted into the slot with id.

Added in version 1.6.

Parameters:
  • id – the id of the child

  • child – the child to set

set_layout(layout: Layout) None#

Makes layout the current layout of self.

Added in version 1.6.

Parameters:

layout – a layout in self

set_layout_name(name: str) None#

Makes the layout with name the current layout of self.

See name.

Added in version 1.6.

Parameters:

name – the name of the layout

Properties#

class MultiLayoutView
props.layout: Layout#

The type of the None singleton.

Added in version 1.6.

props.layout_name: str#

The type of the None singleton.

Added in version 1.6.