Class Dialog

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, ShortcutManager, Proxy
Direct Known Subclasses:
AboutDialog, AlertDialog, PreferencesDialog, ShortcutsDialog

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

An adaptive dialog container.

dialog-floating dialog-bottom

AdwDialog is similar to a window, but is shown within another window. It can be used with Window and ApplicationWindow, use present(Widget) to show it.

AdwDialog is not resizable. Use the Dialog:content-width and Dialog:content-height properties to set its size, or set Dialog:follows-content-size to TRUE to make the dialog track the content's size as it changes. AdwDialog can never be larger than its parent window.

AdwDialog can be presented as a centered floating window or a bottom sheet. By default it's automatic depending on the available size. Dialog:presentation-mode can be used to change that.

AdwDialog can be closed via close().

When presented as a bottom sheet, AdwDialog can also be closed via swiping it down.

The Dialog:can-close can be used to prevent closing. In that case, Dialog::close-attempt gets emitted instead.

Use forceClose() to close the dialog even when can-close is set to FALSE.

AdwDialog is transient and doesn't integrate with the window below it, for example it's not possible to collapse it into a bottom bar. See BottomSheet for persistent and more tightly integrated bottom sheets.

Header Bar Integration

When placed inside an AdwDialog, HeaderBar will display the dialog title instead of window title. It will also adjust the decoration layout to ensure it always has a close button and nothing else. Set HeaderBar:show-start-title-buttons and HeaderBar:show-end-title-buttons to FALSE to remove it if it's unwanted.

Breakpoints

AdwDialog can be used with Breakpoint the same way as BreakpointBin. Refer to that widget's documentation for details.

Like AdwBreakpointBin, if breakpoints are used, AdwDialog doesn't have a minimum size, and Gtk.Widget:width-request and Gtk.Widget:height-request properties must be set manually.

Since:
1.5
  • Constructor Details

    • Dialog

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

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

    • getType

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

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

      protected Dialog 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
    • addBreakpoint

      public void addBreakpoint(Breakpoint breakpoint)
      Adds breakpoint to self.
      Parameters:
      breakpoint - the breakpoint to add
      Since:
      1.5
    • close

      public boolean close()

      Attempts to close self.

      If the Dialog:can-close property is set to FALSE, the Dialog::close-attempt signal is emitted.

      See also: forceClose().

      Returns:
      whether this Dialog was successfully closed
      Since:
      1.5
    • forceClose

      public void forceClose()

      Closes self.

      Unlike close(), it succeeds even if Dialog:can-close is set to FALSE.

      Since:
      1.5
    • getCanClose

      public boolean getCanClose()
      Gets whether this Dialog can be closed.
      Returns:
      whether the dialog can be closed
      Since:
      1.5
    • getChild

      public @Nullable Widget getChild()
      Gets the child widget of self.
      Returns:
      the child widget of this Dialog
      Since:
      1.5
    • getContentHeight

      public int getContentHeight()
      Gets the height of the dialog's contents.
      Returns:
      the content height
      Since:
      1.5
    • getContentWidth

      public int getContentWidth()
      Gets the width of the dialog's contents.
      Returns:
      the content width
      Since:
      1.5
    • getCurrentBreakpoint

      public @Nullable Breakpoint getCurrentBreakpoint()
      Gets the current breakpoint.
      Returns:
      the current breakpoint
      Since:
      1.5
    • getDefaultWidget

      public @Nullable Widget getDefaultWidget()
      Gets the default widget for self.
      Returns:
      the default widget
      Since:
      1.5
    • getFocus

      public @Nullable Widget getFocus()
      Gets the focus widget for self.
      Returns:
      the focus widget
      Since:
      1.5
    • getFollowsContentSize

      public boolean getFollowsContentSize()
      Gets whether to size content of this Dialog automatically.
      Returns:
      whether to size content automatically
      Since:
      1.5
    • getPresentationMode

      public DialogPresentationMode getPresentationMode()
      Gets presentation mode for self.
      Returns:
      the presentation mode
      Since:
      1.5
    • getTitle

      public String getTitle()
      Gets the title of self.
      Returns:
      the title
      Since:
      1.5
    • present

      public void present(@Nullable Widget parent)

      Presents this Dialog within parent's window.

      If this Dialog is already shown, raises it to the top instead.

      If the window is an Window or ApplicationWindow, the dialog will be shown within it. Otherwise, it will be a separate window.

      Parameters:
      parent - a widget within the toplevel
      Since:
      1.5
    • setCanClose

      public void setCanClose(boolean canClose)

      Sets whether this Dialog can be closed.

      If set to FALSE, the close button, shortcuts and close() will result in Dialog::close-attempt being emitted instead, and bottom sheet close swipe will be disabled. forceClose() still works.

      Parameters:
      canClose - whether to allow closing
      Since:
      1.5
    • setChild

      public void setChild(@Nullable Widget child)
      Sets the child widget of self.
      Parameters:
      child - the child widget
      Since:
      1.5
    • setContentHeight

      public void setContentHeight(int contentHeight)

      Sets the height of the dialog's contents.

      Set it to -1 to reset it to the content's natural height.

      See also: Gtk.Window:default-height

      Parameters:
      contentHeight - the content height
      Since:
      1.5
    • setContentWidth

      public void setContentWidth(int contentWidth)

      Sets the width of the dialog's contents.

      Set it to -1 to reset it to the content's natural width.

      See also: Gtk.Window:default-width

      Parameters:
      contentWidth - the content width
      Since:
      1.5
    • setDefaultWidget

      public void setDefaultWidget(@Nullable Widget defaultWidget)

      Sets the default widget for self.

      It's activated when the user presses Enter.

      Parameters:
      defaultWidget - the default widget
      Since:
      1.5
    • setFocus

      public void setFocus(@Nullable Widget focus)

      Sets the focus widget for self.

      If focus is not the current focus widget, and is focusable, sets it as the focus widget for the dialog.

      If focus is NULL, unsets the focus widget for this dialog. To set the focus to a particular widget in the dialog, it is usually more convenient to use Widget#grabFocus instead of this function.

      Parameters:
      focus - the focus widget
      Since:
      1.5
    • setFollowsContentSize

      public void setFollowsContentSize(boolean followsContentSize)

      Sets whether to size content of this Dialog automatically.

      If set to TRUE, always use the content's natural size instead of Dialog:content-width and Dialog:content-height. If the content resizes, the dialog will immediately resize as well.

      See also: Gtk.Window:resizable

      Parameters:
      followsContentSize - whether to size content automatically
      Since:
      1.5
    • setPresentationMode

      public void setPresentationMode(DialogPresentationMode presentationMode)

      Sets presentation mode for self.

      When set to Adw.DialogPresentationMode.auto, the dialog appears as a bottom sheet when the following condition is met: max-width: 450px or max-height: 360px, and as a floating window otherwise.

      Set it to Adw.DialogPresentationMode.floating or Adw.DialogPresentationMode.bottom-sheet to always present it a floating window or a bottom sheet respectively, regardless of available size.

      Presentation mode does nothing for dialogs presented as a window.

      Parameters:
      presentationMode - the new presentation mode
      Since:
      1.5
    • setTitle

      public void setTitle(String title)
      Sets the title of self.
      Parameters:
      title - the new title
      Since:
      1.5
    • closeAttempt

      protected void closeAttempt()
    • closed

      protected void closed()
    • onCloseAttempt

      Emitted when the close button or shortcut is used, or close() is called while Dialog:can-close is set to FALSE.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      1.5
      See Also:
    • emitCloseAttempt

      public void emitCloseAttempt()
      Emits the "close-attempt" signal. See onCloseAttempt(Dialog.CloseAttemptCallback).
    • onClosed

      Emitted when the dialog is successfully closed.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      1.5
      See Also:
    • emitClosed

      public void emitClosed()
      Emits the "closed" signal. See onClosed(Dialog.ClosedCallback).
    • builder

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