Class SidebarItem

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class SidebarItem extends GObject

An item within SidebarSection.

Sidebar items must have a title, set via SidebarItem:title.

Sidebar items should, but are not required to, have an icon. Icons can be set from an icon name, via SidebarItem:icon-name, or a Paintable, via SidebarItem:icon-paintable.

Items can also have subtitles, set with the SidebarItem:subtitle property. Subtitles should be used sparingly.

To add a tooltip, use SidebarItem:tooltip. Tooltips always use Pango markup.

Items can have an arbitrary suffix widget, set with the SidebarItem:suffix properties. It will be displayed at the end of its row, or before the arrow in the Adw.SidebarMode.page mode.

To hide or disable the item, use the SidebarItem:visible and SidebarItem:enabled properties respectively.

To access the items's section, use SidebarItem:section.

It's also possible to access the index of the item in both the section and the sidebar, using getSectionIndex() and getIndex() respectively.

Dragging content over sidebar items activates them by default. To disable this behavior, set SidebarItem:drag-motion-activate to FALSE.

AdwSidebarItem is derivable, and applications that need to associate each page with data can store it in the items themselves this way.

Since:
1.9
  • Constructor Details

    • SidebarItem

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

      public SidebarItem(String title)
      Creates a new AdwSidebarItem with title as its title.
      Parameters:
      title - the item title
      Since:
      1.9
    • SidebarItem

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

    • getType

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

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

      protected SidebarItem 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 GObject
      Returns:
      the instance as if it were its parent type
    • getDragMotionActivate

      public boolean getDragMotionActivate()
      Gets whether this SidebarItem will be activated on pointer motion during Drag-and-Drop.
      Returns:
      whether to enable the item on drag motion
      Since:
      1.9
    • getEnabled

      public boolean getEnabled()
      Gets whether this SidebarItem is enabled.
      Returns:
      whether the item is enabled
      Since:
      1.9
    • getIconName

      public @Nullable String getIconName()
      Gets the icon name for item.
      Returns:
      the icon name
      Since:
      1.9
    • getIconPaintable

      public @Nullable Paintable getIconPaintable()
      Gets the paintable used as the icon for item.
      Returns:
      the icon paintable
      Since:
      1.9
    • getIndex

      public int getIndex()

      Gets index of this SidebarItem within its Sidebar.

      If this SidebarItem is within a section, but that section is not in a sidebar, index will be within the section only.

      If this SidebarItem is not within a section, the index will be 0.

      The item can later be retrieved by passing this index into Sidebar.getItem(int).

      Returns:
      the index of this SidebarItem
      Since:
      1.9
    • getSection

      public @Nullable SidebarSection getSection()
      Gets the section this SidebarItem is in.
      Returns:
      the section of this SidebarItem
      Since:
      1.9
    • getSectionIndex

      public int getSectionIndex()

      Gets index of this SidebarItem within its SidebarSection.

      If this SidebarItem is not within a section, the index will be 0.

      The item can later be retrieved by passing this index into SidebarSection.getItem(int).

      Returns:
      the index of this SidebarItem
      Since:
      1.9
    • getSubtitle

      public @Nullable String getSubtitle()
      Gets the subtitle of self.
      Returns:
      the subtitle
      Since:
      1.9
    • getSuffix

      public @Nullable Widget getSuffix()
      Gets the suffix widget for self.
      Returns:
      the suffix widget
      Since:
      1.9
    • getTitle

      public @Nullable String getTitle()
      Gets the title of self.
      Returns:
      the title
      Since:
      1.9
    • getTooltip

      public @Nullable String getTooltip()
      Gets the tooltip of self.
      Returns:
      the tooltip
      Since:
      1.9
    • getUseUnderline

      public boolean getUseUnderline()
      Gets whether an underline in the title indicates a mnemonic.
      Returns:
      whether an underline in the text indicates a mnemonic
      Since:
      1.9
    • getVisible

      public boolean getVisible()
      Gets whether this SidebarItem is visible.
      Returns:
      whether the item is visible
      Since:
      1.9
    • setDragMotionActivate

      public void setDragMotionActivate(boolean dragMotionActivate)

      Sets whether to activate this SidebarItem on pointer motion during Drag-and-Drop.

      This is needed to be able to drag content into the page the item represents, when the sidebar is used as a page switcher. However, it may be unwanted when dropping content onto the item itself, so it can be disabled.

      Parameters:
      dragMotionActivate - whether to enable the item on drag motion
      Since:
      1.9
    • setEnabled

      public void setEnabled(boolean enabled)

      Sets whether this SidebarItem is enabled.

      See Gtk.Widget:sensitive.

      Parameters:
      enabled - whether to enable the item
      Since:
      1.9
    • setIconName

      public void setIconName(@Nullable String iconName)

      Sets the icon name for item.

      Mutually exclusive with SidebarItem:icon-paintable.

      Parameters:
      iconName - the icon name
      Since:
      1.9
    • setIconPaintable

      public void setIconPaintable(@Nullable Paintable paintable)

      Sets the paintable to use as the icon for item.

      Mutually exclusive with SidebarItem:icon-name.

      Parameters:
      paintable - the icon paintable
      Since:
      1.9
    • setSubtitle

      public void setSubtitle(@Nullable String subtitle)
      Sets the subtitle of self.
      Parameters:
      subtitle - the subtitle
      Since:
      1.9
    • setSuffix

      public void setSuffix(@Nullable Widget suffix)

      Sets the suffix widget for self.

      Suffix will be shown at the end of the item's row, or before the arrow in the Adw.SidebarMode.page mode.

      Parameters:
      suffix - the suffix widget
      Since:
      1.9
    • setTitle

      public void setTitle(@Nullable String title)
      Sets the title of self.
      Parameters:
      title - the title
      Since:
      1.9
    • setTooltip

      public void setTooltip(@Nullable String tooltip)

      Sets the tooltip of self.

      The tooltip can be marked up with the Pango text markup language.

      Parameters:
      tooltip - the tooltip
      Since:
      1.9
    • setUseUnderline

      public void setUseUnderline(boolean useUnderline)

      Sets whether an underline in the title indicates a mnemonic.

      The mnemonic can be used to activate the item.

      Parameters:
      useUnderline - whether an underline in the text indicates a mnemonic
      Since:
      1.9
    • setVisible

      public void setVisible(boolean visible)
      Sets whether this SidebarItem is visible.
      Parameters:
      visible - whether the item is visible
      Since:
      1.9
    • builder

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