Adw.Dialog¶
- Subclasses:
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
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 |
|
Emitted when the dialog is successfully closed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Adw.Dialog(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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>] toTRUE
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 toFALSE
.- 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>] toFALSE
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:
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:
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:
Gets whether self can be closed.
New in version 1.5.
- get_child()¶
- Returns:
the child widget of self
- Return type:
Gtk.Widget
orNone
Gets the child widget of self.
New in version 1.5.
- get_content_height()¶
- Returns:
the content height
- Return type:
Gets the height of the dialog’s contents.
New in version 1.5.
- get_content_width()¶
- Returns:
the content width
- Return type:
Gets the width of the dialog’s contents.
New in version 1.5.
- get_current_breakpoint()¶
- Returns:
the current breakpoint
- Return type:
Gets the current breakpoint.
New in version 1.5.
- get_default_widget()¶
- Returns:
the default widget
- Return type:
Gtk.Widget
orNone
Gets the default widget for self.
New in version 1.5.
- get_focus()¶
- Returns:
the focus widget
- Return type:
Gtk.Widget
orNone
Gets the focus widget for self.
New in version 1.5.
- get_follows_content_size()¶
- Returns:
whether to size content automatically
- Return type:
Gets whether to size content of self automatically.
New in version 1.5.
- get_presentation_mode()¶
- Returns:
the presentation mode
- Return type:
Gets presentation mode for self.
New in version 1.5.
- present(parent)¶
- Parameters:
parent (
Gtk.Widget
orNone
) – 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
orNone
) – 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
orNone
) – 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
orNone
) – 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
orADW_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:
- 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:
- 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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
The child widget of the
AdwDialog
.New in version 1.5.
- Adw.Dialog.props.content_height¶
- Name:
content-height
- Type:
- Default Value:
-1
- Flags:
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:
- Default Value:
-1
- Flags:
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:
- Default Value:
- Flags:
The current breakpoint.
New in version 1.5.
- Adw.Dialog.props.default_widget¶
- Name:
default-widget
- Type:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
The focus widget.
New in version 1.5.
- Adw.Dialog.props.follows_content_size¶
- Name:
follows-content-size
- Type:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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
orADW_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:
- Default Value:
''
- Flags:
The title of the dialog.
New in version 1.5.