Class Toast.Builder<B extends Toast.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
BuilderInterface
Enclosing class:
Toast

public static class Toast.Builder<B extends Toast.Builder<B>> extends GObject.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

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

    • build

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

      public B setActionName(String actionName)

      The name of the associated action.

      It will be activated when clicking the button.

      See Toast:action-target.

      Parameters:
      actionName - the value for the action-name property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setActionTarget

      public B setActionTarget(Variant actionTarget)
      The parameter for action invocations.
      Parameters:
      actionTarget - the value for the action-target property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setButtonLabel

      public B setButtonLabel(String buttonLabel)

      The label to show on the button.

      Underlines in the button text can be used to indicate a mnemonic.

      If set to NULL, the button won't be shown.

      See Toast:action-name.

      Parameters:
      buttonLabel - the value for the button-label property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setCustomTitle

      public B setCustomTitle(Widget customTitle)

      The custom title widget.

      It will be displayed instead of the title if set. In this case, Toast:title is ignored.

      Setting a custom title will unset Toast:title.

      Parameters:
      customTitle - the value for the custom-title property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.2
    • setPriority

      public B setPriority(ToastPriority priority)

      The priority of the toast.

      Priority controls how the toast behaves when another toast is already being displayed.

      If the priority is Adw.ToastPriority.normal, the toast will be queued.

      If the priority is Adw.ToastPriority.high, the toast will be displayed immediately, pushing the previous toast into the queue instead.

      Parameters:
      priority - the value for the priority property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setTimeout

      public B setTimeout(int timeout)

      The timeout of the toast, in seconds.

      If timeout is 0, the toast is displayed indefinitely until manually dismissed.

      Toasts cannot disappear while being hovered, pressed (on touchscreen), or have keyboard focus inside them.

      Parameters:
      timeout - the value for the timeout property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setTitle

      public B setTitle(String title)

      The title of the toast.

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

      Setting a title will unset Toast:custom-title.

      If Toast:custom-title is set, it will be used instead.

      Parameters:
      title - the value for the title property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setUseMarkup

      public B setUseMarkup(boolean useMarkup)

      Whether to use Pango markup for the toast title.

      See also Pango#parseMarkup.

      Parameters:
      useMarkup - the value for the use-markup property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.4
    • onButtonClicked

      public B onButtonClicked(Toast.ButtonClickedCallback handler)

      Emitted after the button has been clicked.

      It can be used as an alternative to setting an action.

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

      public B onDismissed(Toast.DismissedCallback handler)
      Emitted when the toast has been dismissed.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: