Trait gtk4::prelude::DialogExt

source ·
pub trait DialogExt: 'static {
    fn add_action_widget(
        &self,
        child: &impl IsA<Widget>,
        response_id: ResponseType
    ); fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget; fn content_area(&self) -> Box; fn header_bar(&self) -> HeaderBar; fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget>; fn response(&self, response_id: ResponseType); fn set_default_response(&self, response_id: ResponseType); fn set_response_sensitive(&self, response_id: ResponseType, setting: bool); fn use_header_bar(&self) -> i32; fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn emit_close(&self); fn connect_response<F: Fn(&Self, ResponseType) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }
Expand description

Required Methods§

source

fn add_action_widget(&self, child: &impl IsA<Widget>, response_id: ResponseType)

Adds an activatable widget to the action area of a Dialog.

GTK connects a signal handler that will emit the response signal on the dialog when the widget is activated. The widget is appended to the end of the dialog’s action area.

If you want to add a non-activatable widget, simply pack it into the @action_area field of the Dialog struct.

Deprecated since 4.10

Use Window instead

child

an activatable widget

response_id

response ID for @child

source

fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget

Adds a button with the given text.

GTK arranges things so that clicking the button will emit the response signal with the given @response_id. The button is appended to the end of the dialog’s action area. The button widget is returned, but usually you don’t need it.

Deprecated since 4.10

Use Window instead

button_text

text of button

response_id

response ID for the button

Returns

the Button widget that was added

source

fn content_area(&self) -> Box

Returns the content area of @self.

Deprecated since 4.10

Use Window instead

Returns

the content area Box.

source

fn header_bar(&self) -> HeaderBar

Returns the header bar of @self.

Note that the headerbar is only used by the dialog if the use-header-bar property is true.

Deprecated since 4.10

Use Window instead

Returns

the header bar

source

fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget>

Gets the widget button that uses the given response ID in the action area of a dialog.

Deprecated since 4.10

Use Window instead

response_id

the response ID used by the @self widget

Returns

the @widget button that uses the given @response_id

source

fn response(&self, response_id: ResponseType)

Emits the ::response signal with the given response ID.

Used to indicate that the user has responded to the dialog in some way.

Deprecated since 4.10

Use Window instead

response_id

response ID

source

fn set_default_response(&self, response_id: ResponseType)

Sets the default widget for the dialog based on the response ID.

Pressing “Enter” normally activates the default widget.

Deprecated since 4.10

Use Window instead

response_id

a response ID

source

fn set_response_sensitive(&self, response_id: ResponseType, setting: bool)

A convenient way to sensitize/desensitize dialog buttons.

Calls gtk_widget_set_sensitive (widget, @setting) for each widget in the dialog’s action area with the given @response_id.

Deprecated since 4.10

Use Window instead

response_id

a response ID

setting

true for sensitive

source

fn use_header_bar(&self) -> i32

true if the dialog uses a headerbar for action buttons instead of the action-area.

For technical reasons, this property is declared as an integer property, but you should only set it to true or false.

Creating a dialog with headerbar

Builtin Dialog subclasses such as ColorChooserDialog set this property according to platform conventions (using the gtk-dialogs-use-header setting).

Here is how you can achieve the same:

⚠️ The following code is in c ⚠️

g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
Deprecated since 4.10

Use Window instead

source

fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Emitted when the user uses a keybinding to close the dialog.

This is a keybinding signal.

The default binding for this signal is the Escape key.

Deprecated since 4.10

Use Window instead

source

fn emit_close(&self)

source

fn connect_response<F: Fn(&Self, ResponseType) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

Emitted when an action widget is clicked.

The signal is also emitted when the dialog receives a delete event, and when response() is called. On a delete event, the response ID is ResponseType::DeleteEvent. Otherwise, it depends on which action widget was clicked.

Deprecated since 4.10

Use Window instead

response_id

the response ID

Implementors§

source§

impl<O: IsA<Dialog>> DialogExt for O