:right-sidebar: True Dialog =================================================================== .. currentmodule:: gi.repository.Adw .. versionadded:: 1.5 .. class:: Dialog(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Adw.AboutDialog`, :class:`~gi.repository.Adw.AlertDialog`, :class:`~gi.repository.Adw.PreferencesDialog` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` An adaptive dialog container. .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/dialog-bottom.png ``AdwDialog`` is similar to a window, but is shown within another window. It can be used with :obj:`~gi.repository.Adw.Window` and :obj:`~gi.repository.Adw.ApplicationWindow`\, use :obj:`~gi.repository.Dialog.present` to show it. ``AdwDialog`` is not resizable. Use the :obj:`~gi.repository.Adw.Dialog.props.content_width` and :obj:`~gi.repository.Adw.Dialog.props.content_height` properties to set its size, or set :obj:`~gi.repository.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. :obj:`~gi.repository.Adw.Dialog.props.presentation_mode` can be used to change that. ``AdwDialog`` can be closed via :obj:`~gi.repository.Dialog.close`\. When presented as a bottom sheet, ``AdwDialog`` can also be closed via swiping it down. The :obj:`~gi.repository.Adw.Dialog.props.can_close` can be used to prevent closing. In that case, :obj:`~gi.repository.Adw.Dialog.signals.close_attempt` gets emitted instead. Use :obj:`~gi.repository.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 :obj:`~gi.repository.Adw.BottomSheet` for persistent and more tightly integrated bottom sheets. Header Bar Integration -------------------------------------------------------------------------------- When placed inside an ``AdwDialog``\, :obj:`~gi.repository.Adw.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 :obj:`~gi.repository.Adw.HeaderBar.props.show_start_title_buttons` and :obj:`~gi.repository.Adw.HeaderBar.props.show_end_title_buttons` to ``FALSE`` to remove it if it's unwanted. Breakpoints -------------------------------------------------------------------------------- ``AdwDialog`` can be used with :obj:`~gi.repository.Adw.Breakpoint` the same way as :obj:`~gi.repository.Adw.BreakpointBin`\. Refer to that widget's documentation for details. Like ``AdwBreakpointBin``\, if breakpoints are used, ``AdwDialog`` doesn't have a minimum size, and :obj:`~gi.repository.Gtk.Widget.props.width_request` and :obj:`~gi.repository.Gtk.Widget.props.height_request` properties must be set manually. Constructors ------------ .. rst-class:: interim-class .. class:: Dialog :no-index: .. classmethod:: new() -> ~gi.repository.Adw.Dialog Creates a new ``AdwDialog``\. .. versionadded:: 1.5 Methods ------- .. rst-class:: interim-class .. class:: Dialog :no-index: .. method:: add_breakpoint(breakpoint: ~gi.repository.Adw.Breakpoint) -> None Adds ``breakpoint`` to ``self``\. .. versionadded:: 1.5 :param breakpoint: the breakpoint to add .. method:: close() -> bool Attempts to close ``self``\. If the :obj:`~gi.repository.Adw.Dialog.props.can_close` property is set to ``FALSE``\, the :obj:`~gi.repository.Adw.Dialog.signals.close_attempt` signal is emitted. See also: :obj:`~gi.repository.Dialog.force_close`\. .. versionadded:: 1.5 .. method:: do_close_attempt(self) -> None .. method:: do_closed(self) -> None .. method:: force_close() -> None Closes ``self``\. Unlike :obj:`~gi.repository.Dialog.close`\, it succeeds even if :obj:`~gi.repository.Adw.Dialog.props.can_close` is set to ``FALSE``\. .. versionadded:: 1.5 .. method:: get_can_close() -> bool Gets whether ``self`` can be closed. .. versionadded:: 1.5 .. method:: get_child() -> ~gi.repository.Gtk.Widget | None Gets the child widget of ``self``\. .. versionadded:: 1.5 .. method:: get_content_height() -> int Gets the height of the dialog's contents. .. versionadded:: 1.5 .. method:: get_content_width() -> int Gets the width of the dialog's contents. .. versionadded:: 1.5 .. method:: get_current_breakpoint() -> ~gi.repository.Adw.Breakpoint | None Gets the current breakpoint. .. versionadded:: 1.5 .. method:: get_default_widget() -> ~gi.repository.Gtk.Widget | None Gets the default widget for ``self``\. .. versionadded:: 1.5 .. method:: get_focus() -> ~gi.repository.Gtk.Widget | None Gets the focus widget for ``self``\. .. versionadded:: 1.5 .. method:: get_follows_content_size() -> bool Gets whether to size content of ``self`` automatically. .. versionadded:: 1.5 .. method:: get_presentation_mode() -> ~gi.repository.Adw.DialogPresentationMode Gets presentation mode for ``self``\. .. versionadded:: 1.5 .. method:: get_title() -> str Gets the title of ``self``\. .. versionadded:: 1.5 .. method:: present(parent: ~gi.repository.Gtk.Widget | None = None) -> None Presents ``self`` within ``parent``\'s window. If ``self`` is already shown, raises it to the top instead. If the window is an :obj:`~gi.repository.Adw.Window` or :obj:`~gi.repository.Adw.ApplicationWindow`\, the dialog will be shown within it. Otherwise, it will be a separate window. .. versionadded:: 1.5 :param parent: a widget within the toplevel .. method:: set_can_close(can_close: bool) -> None Sets whether ``self`` can be closed. If set to ``FALSE``\, the close button, shortcuts and :obj:`~gi.repository.Dialog.close` will result in :obj:`~gi.repository.Adw.Dialog.signals.close_attempt` being emitted instead, and bottom sheet close swipe will be disabled. :obj:`~gi.repository.Dialog.force_close` still works. .. versionadded:: 1.5 :param can_close: whether to allow closing .. method:: set_child(child: ~gi.repository.Gtk.Widget | None = None) -> None Sets the child widget of ``self``\. .. versionadded:: 1.5 :param child: the child widget .. method:: set_content_height(content_height: int) -> None Sets the height of the dialog's contents. Set it to -1 to reset it to the content's natural height. See also: :obj:`~gi.repository.Gtk.Window.props.default_height` .. versionadded:: 1.5 :param content_height: the content height .. method:: set_content_width(content_width: int) -> None Sets the width of the dialog's contents. Set it to -1 to reset it to the content's natural width. See also: :obj:`~gi.repository.Gtk.Window.props.default_width` .. versionadded:: 1.5 :param content_width: the content width .. method:: set_default_widget(default_widget: ~gi.repository.Gtk.Widget | None = None) -> None Sets the default widget for ``self``\. It's activated when the user presses Enter. .. versionadded:: 1.5 :param default_widget: the default widget .. method:: set_focus(focus: ~gi.repository.Gtk.Widget | None = None) -> None 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 :obj:`~gi.repository.Gtk.Widget.grab_focus` instead of this function. .. versionadded:: 1.5 :param focus: the focus widget .. method:: set_follows_content_size(follows_content_size: bool) -> None Sets whether to size content of ``self`` automatically. If set to ``TRUE``\, always use the content's natural size instead of :obj:`~gi.repository.Adw.Dialog.props.content_width` and :obj:`~gi.repository.Adw.Dialog.props.content_height`\. If the content resizes, the dialog will immediately resize as well. See also: :obj:`~gi.repository.Gtk.Window.props.resizable` .. versionadded:: 1.5 :param follows_content_size: whether to size content automatically .. method:: set_presentation_mode(presentation_mode: ~gi.repository.Adw.DialogPresentationMode) -> None 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. .. versionadded:: 1.5 :param presentation_mode: the new presentation mode .. method:: set_title(title: str) -> None Sets the title of ``self``\. .. versionadded:: 1.5 :param title: the new title Properties ---------- .. rst-class:: interim-class .. class:: Dialog :no-index: .. attribute:: props.can_close :type: bool The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.child :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.content_height :type: int The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.content_width :type: int The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.current_breakpoint :type: ~gi.repository.Adw.Breakpoint The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.default_widget :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.focus_widget :type: ~gi.repository.Gtk.Widget The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.follows_content_size :type: bool The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.presentation_mode :type: ~gi.repository.Adw.DialogPresentationMode The type of the None singleton. .. versionadded:: 1.5 .. attribute:: props.title :type: str The type of the None singleton. .. versionadded:: 1.5 Signals ------- .. rst-class:: interim-class .. class:: Dialog.signals :no-index: .. method:: close_attempt() -> None The type of the None singleton. .. versionadded:: 1.5 .. method:: closed() -> None The type of the None singleton. .. versionadded:: 1.5 Virtual Methods --------------- .. rst-class:: interim-class .. class:: Dialog :no-index: .. method:: do_close_attempt() -> None The type of the None singleton. .. method:: do_closed() -> None The type of the None singleton. Fields ------ .. rst-class:: interim-class .. class:: Dialog :no-index: .. attribute:: parent_instance