Klasse Dialog

Alle implementierten Schnittstellen:
PointerInterface
Bekannte direkte Unterklassen:
AboutDialog, AlertDialog, PreferencesDialog

public class Dialog extends Widget
An adaptive dialog container.

<picture>
<source srcset="dialog-floating-dark.png" media="(prefers-color-scheme: dark)">
<img src="dialog-floating.png" alt="dialog-floating">
</picture>
<picture>
<source srcset="dialog-bottom-dark.png" media="(prefers-color-scheme: dark)">
<img src="dialog-bottom.png" alt="dialog-bottom">
</picture>

`AdwDialog` is similar to a window, but is shown within another window. It
can be used with [class@Window] and [class@ApplicationWindow], use
[method@Dialog.present] to show it.

`AdwDialog` is not resizable. Use the [property@Dialog:content-width] and
[property@Dialog:content-height] properties to set its size, or set
[property@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.
[property@Dialog:presentation-mode] can be used to change that.

`AdwDialog` can be closed via [method@Dialog.close].

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

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

Use [method@Dialog.force_close] 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
[class@BottomSheet] for persistent and more tightly integrated bottom sheets.

## Header Bar Integration

When placed inside an `AdwDialog`, [class@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
[property@HeaderBar:show-start-title-buttons] and
[property@HeaderBar:show-end-title-buttons] to `FALSE` to remove it if it's
unwanted.

## Breakpoints

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

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

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.Dialog.html

  • Felddetails

  • Konstruktordetails

    • Dialog

      public Dialog(PointerContainer pointer)
    • Dialog

      public Dialog()
      Creates a new `AdwDialog`.
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • addBreakpoint

      public void addBreakpoint(@Nonnull Breakpoint breakpoint)
      Adds @breakpoint to @self.
      Parameter:
      breakpoint - the breakpoint to add
    • close

      public boolean close()
      Attempts to close @self.

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

      See also: [method@Dialog.force_close].
      Gibt zurück:
      whether @self was successfully closed
    • forceClose

      public void forceClose()
      Closes @self.

      Unlike [method@Dialog.close], it succeeds even if [property@Dialog:can-close]
      is set to `FALSE`.
    • getCanClose

      public boolean getCanClose()
      Gets whether @self can be closed.
      Gibt zurück:
      whether the dialog can be closed
    • getChild

      public Widget getChild()
      Gets the child widget of @self.
      Gibt zurück:
      the child widget of @self
    • getContentHeight

      public int getContentHeight()
      Gets the height of the dialog's contents.
      Gibt zurück:
      the content height
    • getContentWidth

      public int getContentWidth()
      Gets the width of the dialog's contents.
      Gibt zurück:
      the content width
    • getCurrentBreakpoint

      public Breakpoint getCurrentBreakpoint()
      Gets the current breakpoint.
      Gibt zurück:
      the current breakpoint
    • getDefaultWidget

      public Widget getDefaultWidget()
      Gets the default widget for @self.
      Gibt zurück:
      the default widget
    • getFocus

      public Widget getFocus()
      Gets the focus widget for @self.
      Gibt zurück:
      the focus widget
    • getFollowsContentSize

      public boolean getFollowsContentSize()
      Gets whether to size content of @self automatically.
      Gibt zurück:
      whether to size content automatically
    • getPresentationMode

      public int getPresentationMode()
      Gets presentation mode for @self.
      Gibt zurück:
      the presentation mode
    • getTitle

      public Str getTitle()
      Gets the title of @self.
      Gibt zurück:
      the title
    • present

      public void present(@Nullable Widget parent)
      Presents @self within @parent's window.

      If @self is already shown, raises it to the top instead.

      If the window is an [class@Window] or [class@ApplicationWindow], the dialog
      will be shown within it. Otherwise, it will be a separate window.
      Parameter:
      parent - a widget within the toplevel
    • setCanClose

      public void setCanClose(boolean can_close)
      Sets whether @self can be closed.

      If set to `FALSE`, the close button, shortcuts and
      [method@Dialog.close] will result in [signal@Dialog::close-attempt] being
      emitted instead, and bottom sheet close swipe will be disabled.
      [method@Dialog.force_close] still works.
      Parameter:
      can_close - whether to allow closing
    • setChild

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

      public void setContentHeight(int content_height)
      Sets the height of the dialog's contents.

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

      See also: [property@Gtk.Window:default-height]
      Parameter:
      content_height - the content height
    • setContentWidth

      public void setContentWidth(int content_width)
      Sets the width of the dialog's contents.

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

      See also: [property@Gtk.Window:default-width]
      Parameter:
      content_width - the content width
    • setDefaultWidget

      public void setDefaultWidget(@Nullable Widget default_widget)
      Sets the default widget for @self.

      It's activated when the user presses Enter.
      Parameter:
      default_widget - the default widget
    • 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
      [method@Gtk.Widget.grab_focus] instead of this function.
      Parameter:
      focus - the focus widget
    • setFollowsContentSize

      public void setFollowsContentSize(boolean follows_content_size)
      Sets whether to size content of @self automatically.

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

      See also: [property@Gtk.Window:resizable]
      Parameter:
      follows_content_size - whether to size content automatically
    • setPresentationMode

      public void setPresentationMode(int presentation_mode)
      Sets presentation mode for @self.

      When set to `ADW_DIALOG_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_DIALOG_FLOATING` or `ADW_DIALOG_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.
      Parameter:
      presentation_mode - the new presentation mode
    • setTitle

      public void setTitle(@Nonnull Str title)
      Sets the title of @self.
      Parameter:
      title - the new title
    • setTitle

      public void setTitle(String title)
      Sets the title of @self.
      Parameter:
      title - the new title
    • onCloseAttempt

      public SignalHandler onCloseAttempt(Dialog.OnCloseAttempt signal)
      Connect to signal "close-attempt".
      See Dialog.OnCloseAttempt.onCloseAttempt() for signal description.
      Field SIGNAL_ON_CLOSE_ATTEMPT contains original signal name and can be used as resource reference.
      Parameter:
      signal - callback function (lambda).
      Gibt zurück:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onClosed

      public SignalHandler onClosed(Dialog.OnClosed signal)
      Connect to signal "closed".
      See Dialog.OnClosed.onClosed() for signal description.
      Field SIGNAL_ON_CLOSED contains original signal name and can be used as resource reference.
      Parameter:
      signal - callback function (lambda).
      Gibt zurück:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Setzt außer Kraft:
      asAccessible in Klasse Widget
      Gibt zurück:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Setzt außer Kraft:
      asBuildable in Klasse Widget
      Gibt zurück:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Setzt außer Kraft:
      asConstraintTarget in Klasse Widget
      Gibt zurück:
      ConstraintTarget
    • asShortcutManager

      public ShortcutManager asShortcutManager()
      Implements interface ShortcutManager. Call this to get access to interface functions.
      Gibt zurück:
      ShortcutManager
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()