Class ViewSwitcherSidebar

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public final class ViewSwitcherSidebar extends Widget implements Accessible, Buildable, ConstraintTarget

An adaptive sidebar that controls an ViewStack.

view-switcher-sidebar

AdwViewSwitcherSidebar is a view switcher implemented using a Sidebar, in a similar fashion to 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 ViewStackPage:starts-section and ViewStackPage:section-title properties.

Like Sidebar, AdwViewSwitcherSidebar is adaptive and can behave as a sidebar or a page, via the ViewSwitcherSidebar:mode property.

view-switcher-sidebar-modes

Connect to the ViewSwitcherSidebar::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 ViewSwitcherSidebar:filter property.

Use ViewSwitcherSidebar: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: ViewSwitcher, ViewSwitcherBar, InlineViewSwitcher.

Since:
1.9
  • Constructor Details

    • ViewSwitcherSidebar

      public ViewSwitcherSidebar(MemorySegment address)
      Create a ViewSwitcherSidebar instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ViewSwitcherSidebar

      public ViewSwitcherSidebar()
      Create a new ViewSwitcherSidebar.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ViewSwitcherSidebar class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ViewSwitcherSidebar asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • getFilter

      public @Nullable Filter getFilter()
      Gets the item filter for self.
      Returns:
      the item filter
      Since:
      1.9
    • getMode

      public SidebarMode getMode()

      Gets self's look and behavior.

      See Sidebar.getMode().

      Returns:
      the current mode
      Since:
      1.9
    • getPlaceholder

      public @Nullable Widget getPlaceholder()
      Gets the placeholder widget for self.
      Returns:
      the placeholder widget
      Since:
      1.9
    • getStack

      public @Nullable ViewStack getStack()
      Gets the stack this ViewSwitcherSidebar controls.
      Returns:
      The stack of this ViewSwitcherSidebar
      Since:
      1.9
    • setFilter

      public void setFilter(@Nullable Filter filter)

      Sets the item filter for self.

      Can be used to implement search within the sidebar.

      Use ViewSwitcherSidebar:placeholder to provide an empty state.

      See Sidebar.setFilter(Filter).

      Parameters:
      filter - the item filter
      Since:
      1.9
    • setMode

      public void setMode(SidebarMode mode)

      Sets self's look and behavior.

      view-switcher-sidebar-modes

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

      If set to 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 NavigationSplitView when collapsed, as the sidebar pane becomes a page there.

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

      See Sidebar.setMode(SidebarMode).

      Parameters:
      mode - the new mode
      Since:
      1.9
    • setPlaceholder

      public void setPlaceholder(@Nullable Widget placeholder)

      Sets the placeholder widget for self.

      This widget will be shown if this ViewSwitcherSidebar has no items, or all of its items have been filtered out by ViewSwitcherSidebar:filter.

      See Sidebar.setPlaceholder(Widget).

      Parameters:
      placeholder - the placeholder widget
      Since:
      1.9
    • setStack

      public void setStack(@Nullable ViewStack stack)
      Sets the stack to control.
      Parameters:
      stack - a stack
      Since:
      1.9
    • onActivated

      Emitted when an item has been activated.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      1.9
      See Also:
    • emitActivated

      public void emitActivated()
      Emits the "activated" signal. See onActivated(ViewSwitcherSidebar.ActivatedCallback).
    • builder

      public static ViewSwitcherSidebar.Builder<? extends ViewSwitcherSidebar.Builder> builder()
      A ViewSwitcherSidebar.Builder object constructs a ViewSwitcherSidebar with the specified properties. Use the various set...() methods to set properties, and finish construction with ViewSwitcherSidebar.Builder.build().
      Returns:
      the builder object