Adw.Dialog

g Adw.Dialog Adw.Dialog GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Adw.Dialog

Subclasses:

Adw.AboutDialog, Adw.AlertDialog, Adw.PreferencesDialog

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

add_breakpoint (breakpoint)

close ()

force_close ()

get_can_close ()

get_child ()

get_content_height ()

get_content_width ()

get_current_breakpoint ()

get_default_widget ()

get_focus ()

get_follows_content_size ()

get_presentation_mode ()

get_title ()

present (parent)

set_can_close (can_close)

set_child (child)

set_content_height (content_height)

set_content_width (content_width)

set_default_widget (default_widget)

set_focus (focus)

set_follows_content_size (follows_content_size)

set_presentation_mode (presentation_mode)

set_title (title)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

do_close_attempt ()

do_closed ()

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

can-close

bool

r/w/en

child

Gtk.Widget

r/w/en

content-height

int

r/w/en

content-width

int

r/w/en

current-breakpoint

Adw.Breakpoint

r

default-widget

Gtk.Widget

r/w/en

focus-widget

Gtk.Widget

r/w/en

follows-content-size

bool

r/w/en

presentation-mode

Adw.DialogPresentationMode

r/w/en

title

str

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

close-attempt

Emitted when the close button or shortcut is used, or [method`Dialog`.close] is called while [property`Dialog`:py:data::can-close<Adw.Dialog.props.can_close>] is set to FALSE.

closed

Emitted when the dialog is successfully closed.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gtk.Widget

r

Class Details

class Adw.Dialog(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

Structure:

Adw.DialogClass

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`:py:data::content-width<Adw.Dialog.props.content_width>] and [property`Dialog`:py:data::content-height<Adw.Dialog.props.content_height>] properties to set its size, or set [property`Dialog`:py:data::follows-content-size<Adw.Dialog.props.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`:py:data::presentation-mode<Adw.Dialog.props.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`:py:data::can-close<Adw.Dialog.props.can_close>] can be used to prevent closing. In that case, [signal`Dialog`:py:func:::close-attempt<Adw.Dialog.signals.close_attempt>] gets emitted instead.

Use [method`Dialog`.force_close] to close the dialog even when can-close is set to FALSE.

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`:py:data::show-start-title-buttons<Adw.Dialog.props.show_start_title_buttons>] and [property`HeaderBar`:py:data::show-end-title-buttons<Adw.Dialog.props.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.

New in version 1.5.

classmethod new()
Returns:

the new created AdwDialog

Return type:

Adw.Dialog

Creates a new AdwDialog.

New in version 1.5.

add_breakpoint(breakpoint)
Parameters:

breakpoint (Adw.Breakpoint) – the breakpoint to add

Adds breakpoint to self.

New in version 1.5.

close()
Returns:

whether self was successfully closed

Return type:

bool

Attempts to close self.

If the [property`Dialog`:py:data::can-close<Adw.Dialog.props.can_close>] property is set to FALSE, the [signal`Dialog`:py:func:::close-attempt<Adw.Dialog.signals.close_attempt>] signal is emitted.

See also: [method`Dialog`.force_close].

New in version 1.5.

force_close()

Closes self.

Unlike [method`Dialog`.close], it succeeds even if [property`Dialog`:py:data::can-close<Adw.Dialog.props.can_close>] is set to FALSE.

New in version 1.5.

get_can_close()
Returns:

whether the dialog can be closed

Return type:

bool

Gets whether self can be closed.

New in version 1.5.

get_child()
Returns:

the child widget of self

Return type:

Gtk.Widget or None

Gets the child widget of self.

New in version 1.5.

get_content_height()
Returns:

the content height

Return type:

int

Gets the height of the dialog’s contents.

New in version 1.5.

get_content_width()
Returns:

the content width

Return type:

int

Gets the width of the dialog’s contents.

New in version 1.5.

get_current_breakpoint()
Returns:

the current breakpoint

Return type:

Adw.Breakpoint or None

Gets the current breakpoint.

New in version 1.5.

get_default_widget()
Returns:

the default widget

Return type:

Gtk.Widget or None

Gets the default widget for self.

New in version 1.5.

get_focus()
Returns:

the focus widget

Return type:

Gtk.Widget or None

Gets the focus widget for self.

New in version 1.5.

get_follows_content_size()
Returns:

whether to size content automatically

Return type:

bool

Gets whether to size content of self automatically.

New in version 1.5.

get_presentation_mode()
Returns:

the presentation mode

Return type:

Adw.DialogPresentationMode

Gets presentation mode for self.

New in version 1.5.

get_title()
Returns:

the title

Return type:

str

Gets the title of self.

New in version 1.5.

present(parent)
Parameters:

parent (Gtk.Widget or None) – a widget within the toplevel

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.

New in version 1.5.

set_can_close(can_close)
Parameters:

can_close (bool) – whether to allow closing

Sets whether self can be closed.

If set to FALSE, the close button, shortcuts and [method`Dialog`.close] will result in [signal`Dialog`:py:func:::close-attempt<Adw.Dialog.signals.close_attempt>] being emitted instead, and bottom sheet close swipe will be disabled. [method`Dialog`.force_close] still works.

New in version 1.5.

set_child(child)
Parameters:

child (Gtk.Widget or None) – the child widget

Sets the child widget of self.

New in version 1.5.

set_content_height(content_height)
Parameters:

content_height (int) – the 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]

New in version 1.5.

set_content_width(content_width)
Parameters:

content_width (int) – the 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]

New in version 1.5.

set_default_widget(default_widget)
Parameters:

default_widget (Gtk.Widget or None) – the default widget

Sets the default widget for self.

It’s activated when the user presses Enter.

New in version 1.5.

set_focus(focus)
Parameters:

focus (Gtk.Widget or None) – the focus widget

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.

New in version 1.5.

set_follows_content_size(follows_content_size)
Parameters:

follows_content_size (bool) – whether to size content automatically

Sets whether to size content of self automatically.

If set to TRUE, always use the content’s natural size instead of [property`Dialog`:py:data::content-width<Adw.Dialog.props.content_width>] and [property`Dialog`:py:data::content-height<Adw.Dialog.props.content_height>]. If the content resizes, the dialog will immediately resize as well.

See also: [property`Gtk`.Window:resizable]

New in version 1.5.

set_presentation_mode(presentation_mode)
Parameters:

presentation_mode (Adw.DialogPresentationMode) – the new 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.

New in version 1.5.

set_title(title)
Parameters:

title (str) – the new title

Sets the title of self.

New in version 1.5.

do_close_attempt() virtual
do_closed() virtual

Signal Details

Adw.Dialog.signals.close_attempt(dialog)
Signal Name:

close-attempt

Flags:

RUN_LAST

Parameters:

dialog (Adw.Dialog) – The object which received the signal

Emitted when the close button or shortcut is used, or [method`Dialog`.close] is called while [property`Dialog`:py:data::can-close<Adw.Dialog.props.can_close>] is set to FALSE.

New in version 1.5.

Adw.Dialog.signals.closed(dialog)
Signal Name:

closed

Flags:

RUN_LAST

Parameters:

dialog (Adw.Dialog) – The object which received the signal

Emitted when the dialog is successfully closed.

New in version 1.5.

Property Details

Adw.Dialog.props.can_close
Name:

can-close

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the dialog can be closed.

If set to FALSE, the close button, shortcuts and [method`Dialog`.close] will result in [signal`Dialog`:py:func:::close-attempt<Adw.Dialog.signals.close_attempt>] being emitted instead, and bottom sheet close swipe will be disabled. [method`Dialog`.force_close] still works.

New in version 1.5.

Adw.Dialog.props.child
Name:

child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The child widget of the AdwDialog.

New in version 1.5.

Adw.Dialog.props.content_height
Name:

content-height

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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]

New in version 1.5.

Adw.Dialog.props.content_width
Name:

content-width

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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]

New in version 1.5.

Adw.Dialog.props.current_breakpoint
Name:

current-breakpoint

Type:

Adw.Breakpoint

Default Value:

None

Flags:

READABLE

The current breakpoint.

New in version 1.5.

Adw.Dialog.props.default_widget
Name:

default-widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The default widget.

It’s activated when the user presses Enter.

New in version 1.5.

Adw.Dialog.props.focus_widget
Name:

focus-widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The focus widget.

New in version 1.5.

Adw.Dialog.props.follows_content_size
Name:

follows-content-size

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to size content automatically.

If set to TRUE, always use the content’s natural size instead of [property`Dialog`:py:data::content-width<Adw.Dialog.props.content_width>] and [property`Dialog`:py:data::content-height<Adw.Dialog.props.content_height>]. If the content resizes, the dialog will immediately resize as well.

See also: [property`Gtk`.Window:resizable]

New in version 1.5.

Adw.Dialog.props.presentation_mode
Name:

presentation-mode

Type:

Adw.DialogPresentationMode

Default Value:

Adw.DialogPresentationMode.AUTO

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The dialog’s presentation mode.

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.

New in version 1.5.

Adw.Dialog.props.title
Name:

title

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The title of the dialog.

New in version 1.5.