Class Sidebar.Builder<B extends Sidebar.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, BuilderInterface
Enclosing class:
Sidebar

public static class Sidebar.Builder<B extends Sidebar.Builder<B>> extends Widget.Builder<B> implements Accessible.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
Since:
1.9
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public Sidebar build()
      Finish building the Sidebar object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to Sidebar.
      Overrides:
      build in class Widget.Builder<B extends Sidebar.Builder<B>>
      Returns:
      a new instance of Sidebar with the properties that were set in the Builder object.
    • setDropPreload

      public B setDropPreload(boolean dropPreload)

      Whether the drop data should be preloaded on hover.

      See Gtk.DropTarget:preload.

      Parameters:
      dropPreload - the value for the drop-preload property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
    • setFilter

      public B setFilter(Filter filter)

      The item filter.

      Can be used to implement search within the sidebar.

      Use Sidebar:placeholder to provide an empty state.

      Parameters:
      filter - the value for the filter property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
    • setMenuModel

      public B setMenuModel(MenuModel menuModel)

      Context menu model for the items.

      When a context menu is shown for an item, it will be constructed from the provided menu model. Use the Sidebar::setup-menu signal to set up the menu actions for the particular item.

      Sidebar:menu-model will be preferred over this model if set.

      Parameters:
      menuModel - the value for the menu-model property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
    • setMode

      public B setMode(SidebarMode mode)

      Determines the sidebar's look and behavior.

      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.

      Parameters:
      mode - the value for the mode property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
    • setPlaceholder

      public B setPlaceholder(Widget placeholder)

      The placeholder widget.

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

      Parameters:
      placeholder - the value for the placeholder property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
    • setSelected

      public B setSelected(int selected)

      The index of the currently selected item.

      If set to Gtk.INVALID_LIST_POSITION, no item is selected.

      If Sidebar:mode is set to Adw.SidebarMode.page, the selection is invisible, but still tracked, indicating which item will be selected once the mode is changed to Adw.SidebarMode.sidebar.

      See also: Sidebar:selected-item.

      Parameters:
      selected - the value for the selected property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
    • onActivated

      public B onActivated(Sidebar.ActivatedCallback handler)
      Emitted when an item at index has been activated.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
      See Also:
    • onDrop

      public B onDrop(Sidebar.DropCallback handler)

      Emitted when content is dropped onto the item at index.

      The content must be of one of the types set up via Sidebar.setupDropTarget(Set, Type[]).

      See Gtk.DropTarget::drop.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onDropEnter

      public B onDropEnter(Sidebar.DropEnterCallback handler)

      Emitted when the pointer enters the item at index.

      Applications can use this to set their default drop action even when Sidebar:drop-preload is set to FALSE.

      See Gtk.DropTarget::enter.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
      See Also:
    • onDropValueLoaded

      public B onDropValueLoaded(Sidebar.DropValueLoadedCallback handler)

      Emitted when the dropped content is preloaded for the item at index.

      In order for data to be preloaded, Sidebar:drop-preload must be set to TRUE.

      The content must be of one of the types set up via Sidebar.setupDropTarget(Set, Type[]).

      See Gtk.DropTarget:value.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.9
      See Also:
    • onSetupMenu

      public B onSetupMenu(Sidebar.SetupMenuCallback handler)

      Emitted when a context menu is opened or closed for item.

      If the menu has been closed, item will be set to NULL.

      It can be used to set up menu actions before showing the menu, for example disable actions not applicable to item.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: