Trait gtk4::prelude::DialogExtManual
source · pub trait DialogExtManual: Sealed + IsA<Dialog> + 'static {
// Provided methods
fn add_buttons(&self, buttons: &[(&str, ResponseType)]) { ... }
fn response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType { ... }
fn run_future<'a>(
&'a self
) -> Pin<Box<dyn Future<Output = ResponseType> + 'a>> { ... }
fn run_async<F: FnOnce(&Self, ResponseType) + 'static>(&self, f: F) { ... }
}
👎Deprecated: Since 4.10
Expand description
Trait containing manually implemented methods of Dialog
.
Provided Methods§
👎Deprecated: Since 4.10
Adds multiple buttons.
This is the same as calling DialogExt::add_button()
repeatedly. The variable argument list should be None
-terminated
as with Dialog::with_buttons()
. Each button must have both
text and response ID.
Deprecated since 4.10
Use Window
instead
first_button_text
button text
sourcefn response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType
fn response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType
👎Deprecated: Since 4.10
Gets the response id of a widget in the action area of a dialog.
Deprecated since 4.10
Use Window
instead
widget
a widget in the action area of @self
Returns
the response id of @widget, or ResponseType::None
if @widget doesn’t have a response id set.
sourcefn run_future<'a>(&'a self) -> Pin<Box<dyn Future<Output = ResponseType> + 'a>>
fn run_future<'a>(&'a self) -> Pin<Box<dyn Future<Output = ResponseType> + 'a>>
👎Deprecated: Since 4.10
Shows the dialog and returns a Future
that resolves to the
ResponseType
on response.
use gtk4::prelude::*;
let dialog = gtk4::MessageDialog::builder()
.buttons(gtk4::ButtonsType::OkCancel)
.text("What is your answer?")
.build();
let answer = dialog.run_future().await;
dialog.close();
println!("Answer: {:?}", answer);
sourcefn run_async<F: FnOnce(&Self, ResponseType) + 'static>(&self, f: F)
fn run_async<F: FnOnce(&Self, ResponseType) + 'static>(&self, f: F)
👎Deprecated: Since 4.10
Shows the dialog and calls the callback when a response has been received.
Important: this function isn’t blocking.
use gtk4::prelude::*;
let dialog = gtk4::MessageDialog::builder()
.buttons(gtk4::ButtonsType::OkCancel)
.text("What is your answer?")
.build();
dialog.run_async(|obj, answer| {
obj.close();
println!("Answer: {:?}", answer);
});