Trait gtk4::prelude::DialogExt [−][src]
pub trait DialogExt: 'static {
fn add_action_widget<P: IsA<Widget>>(
&self,
child: &P,
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
Trait containing all Dialog
methods.
Implementors
AppChooserDialog
, ColorChooserDialog
, Dialog
, FileChooserDialog
, FontChooserDialog
, MessageDialog
, PageSetupUnixDialog
, PrintUnixDialog
Required methods
fn add_action_widget<P: IsA<Widget>>(
&self,
child: &P,
response_id: ResponseType
)
fn add_action_widget<P: IsA<Widget>>(
&self,
child: &P,
response_id: ResponseType
)
Adds an activatable widget to the action area of a Dialog
.
GTK connects a signal handler that will emit the
signal::Dialog::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.
child
an activatable widget
response_id
response ID for child
Adds a button with the given text.
GTK arranges things so that clicking the button will emit the
signal::Dialog::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.
button_text
text of button
response_id
response ID for the button
Returns
the Button
widget that was added
fn content_area(&self) -> Box
fn content_area(&self) -> Box
fn header_bar(&self) -> HeaderBar
fn header_bar(&self) -> HeaderBar
fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget>
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.
response_id
the response ID used by the self
widget
Returns
the widget
button that uses the given
response_id
fn response(&self, response_id: ResponseType)
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.
response_id
response ID
fn set_default_response(&self, response_id: ResponseType)
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.
response_id
a response ID
fn set_response_sensitive(&self, response_id: ResponseType, setting: bool)
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
.
response_id
a response ID
setting
true
for sensitive
fn use_header_bar(&self) -> i32
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
property::Settings::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);
fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
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.
fn emit_close(&self)
fn connect_response<F: Fn(&Self, ResponseType) + 'static>(
&self,
f: F
) -> SignalHandlerId
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.
response_id
the response ID