1.24 <AdwDialog>

Class: <AdwDialog>

It derives from <GtkWidget>.

An adaptive dialog container.

<AdwDialog> is similar to a window, but is shown within another window. It can be used with Window and ApplicationWindow, use Dialog.present 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 Dialog.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, "close-attempt" gets emitted instead.

Use 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 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 widget:width-request and widget:height-request properties must be set manually.

Fields

parent-instance

Properties

Property: dialog:can-close self

Whether the dialog can be closed.

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

Its value is a boolean.

Set it with (set! (dialog:can-close self) value).

Property: dialog:child self

The child widget of the <AdwDialog>.

Its value is a <GtkWidget>, or #f.

Set it with (set! (dialog:child self) value).

Property: dialog:content-height self

The height of the dialog’s contents.

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

See also: window:default-height

Its value is a 32-bit integer.

Set it with (set! (dialog:content-height self) value).

Property: dialog:content-width self

The width of the dialog’s contents.

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

See also: window:default-width

Its value is a 32-bit integer.

Set it with (set! (dialog:content-width self) value).

Property: dialog:current-breakpoint self

The current breakpoint.

Its value is a <AdwBreakpoint>, or #f.

It is read only.

Property: dialog:default-widget self

The default widget.

It’s activated when the user presses Enter.

Its value is a <GtkWidget>, or #f.

Set it with (set! (dialog:default-widget self) value).

Property: dialog:focus-widget self

The focus widget.

Its value is a <GtkWidget>, or #f.

Set it with (set! (dialog:focus-widget self) value).

Property: dialog:follows-content-size self

Whether to size content 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: window:resizable

Its value is a boolean.

Set it with (set! (dialog:follows-content-size self) value).

Property: dialog:presentation-mode self

The dialog’s presentation mode.

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.

Its value is a <AdwDialogPresentationMode> (or, to set it, one of its symbols).

Set it with (set! (dialog:presentation-mode self) value).

Property: dialog:title self

The title of the dialog.

Its value is a string, or #f.

Set it with (set! (dialog:title self) value).

Procedures

Method: dialog:add-breakpoint self breakpoint
Method: add-breakpoint self breakpoint

Adds breakpoint to self.

self

Passed: a <AdwDialog>.

a dialog

breakpoint

Passed: a <AdwBreakpoint>.

the breakpoint to add

Method: dialog:close? self ⇒ %return
Method: close? self ⇒ %return

Attempts to close self.

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

See also: Dialog.force_close.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a boolean.

whether self was successfully closed

Method: dialog:force-close self
Method: force-close self

Closes self.

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

self

Passed: a <AdwDialog>.

a dialog

Method: dialog:get-can-close? self ⇒ %return
Method: get-can-close? self ⇒ %return

Gets whether self can be closed.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a boolean.

whether the dialog can be closed

Method: dialog:get-child self ⇒ %return
Method: get-child self ⇒ %return

Gets the child widget of self.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a <GtkWidget>, or #f.

the child widget of self

Method: dialog:get-content-height self ⇒ %return
Method: get-content-height self ⇒ %return

Gets the height of the dialog’s contents.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a 32-bit integer.

the content height

Method: dialog:get-content-width self ⇒ %return
Method: get-content-width self ⇒ %return

Gets the width of the dialog’s contents.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a 32-bit integer.

the content width

Method: dialog:get-current-breakpoint self ⇒ %return
Method: get-current-breakpoint self ⇒ %return

Gets the current breakpoint.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a <AdwBreakpoint>, or #f.

the current breakpoint

Method: dialog:get-default-widget self ⇒ %return
Method: get-default-widget self ⇒ %return

Gets the default widget for self.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a <GtkWidget>, or #f.

the default widget

Method: dialog:get-focus self ⇒ %return
Method: get-focus self ⇒ %return

Gets the focus widget for self.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a <GtkWidget>, or #f.

the focus widget

Method: dialog:get-follows-content-size? self ⇒ %return
Method: get-follows-content-size? self ⇒ %return

Gets whether to size content of self automatically.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a boolean.

whether to size content automatically

Method: dialog:get-presentation-mode self ⇒ %return
Method: get-presentation-mode self ⇒ %return

Gets presentation mode for self.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a <AdwDialogPresentationMode>.

the presentation mode

Method: dialog:get-title self ⇒ %return
Method: get-title self ⇒ %return

Gets the title of self.

self

Passed: a <AdwDialog>.

a dialog

%return

Returned: a string.

the title

Procedure: dialog:new ⇒ %return

Creates a new <AdwDialog>.

%return

Returned: a <AdwDialog>.

the new created <AdwDialog>

Method: dialog:present self [parent]
Method: present self [parent]

Presents self within parent’s window.

If self 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.

self

Passed: a <AdwDialog>.

a dialog

parent

Passed, or left out: a <GtkWidget>, or #f.

a widget within the toplevel

Method: dialog:set-can-close self can-close
Method: set-can-close self can-close

Sets whether self can be closed.

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

self

Passed: a <AdwDialog>.

a dialog

can-close

Passed: a boolean.

whether to allow closing

Method: dialog:set-child self [child]
Method: set-child self [child]

Sets the child widget of self.

self

Passed: a <AdwDialog>.

a dialog

child

Passed, or left out: a <GtkWidget>, or #f.

the child widget

Method: dialog:set-content-height self content-height
Method: set-content-height self 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: window:default-height

self

Passed: a <AdwDialog>.

a dialog

content-height

Passed: a 32-bit integer.

the content height

Method: dialog:set-content-width self content-width
Method: set-content-width self 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: window:default-width

self

Passed: a <AdwDialog>.

a dialog

content-width

Passed: a 32-bit integer.

the content width

Method: dialog:set-default-widget self [default-widget]
Method: set-default-widget self [default-widget]

Sets the default widget for self.

It’s activated when the user presses Enter.

self

Passed: a <AdwDialog>.

a dialog

default-widget

Passed, or left out: a <GtkWidget>, or #f.

the default widget

Method: dialog:set-focus self [focus]
Method: set-focus self [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:grab-focus? instead of this function.

self

Passed: a <AdwDialog>.

a dialog

focus

Passed, or left out: a <GtkWidget>, or #f.

the focus widget

Method: dialog:set-follows-content-size self follows-content-size
Method: set-follows-content-size self follows-content-size

Sets whether to size content of self 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: window:resizable

self

Passed: a <AdwDialog>.

a dialog

follows-content-size

Passed: a boolean.

whether to size content automatically

Method: dialog:set-presentation-mode self presentation-mode
Method: set-presentation-mode self presentation-mode

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.

self

Passed: a <AdwDialog>.

a dialog

presentation-mode

Passed: a <AdwDialogPresentationMode>, or one of its symbols.

the new presentation mode

Method: dialog:set-title self title
Method: set-title self title

Sets the title of self.

self

Passed: a <AdwDialog>.

a dialog

title

Passed: a string.

the new title

Signals

Signal: dialog:close-attempt

Connect a handler with (connect object dialog:close-attempt handler). It is called as (handler self).

Emitted when the close button or shortcut is used, or Dialog.close is called while Dialog:can-close is set to FALSE.

self

Passed: a <AdwDialog>.

Signal: dialog:closed

Connect a handler with (connect object dialog:closed handler). It is called as (handler self).

Emitted when the dialog is successfully closed.

self

Passed: a <AdwDialog>.

Virtual methods

Virtual method: dialog:do-close-attempt implementor self

To override it in a new class, give register-type #:vfuncs `((close-attempt . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <AdwDialog>, or a class that derives from it, or its GType number.

self

Passed: a <AdwDialog>.

Virtual method: dialog:do-closed implementor self

To override it in a new class, give register-type #:vfuncs `((closed . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <AdwDialog>, or a class that derives from it, or its GType number.

self

Passed: a <AdwDialog>.