pub trait DialogExtManual: 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
fn response_for_widget<P: IsA<Widget>>(&self, widget: &P) -> ResponseType
πDeprecated: Since 4.10
Sourcefn run_future<'a>(&'a self) -> Pin<Box<dyn Future<Output = ResponseType> + 'a>>
πDeprecated: Since 4.10
fn run_future<'a>(&'a self) -> Pin<Box<dyn Future<Output = ResponseType> + 'a>>
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)
πDeprecated: Since 4.10
fn run_async<F: FnOnce(&Self, ResponseType) + 'static>(&self, f: F)
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);
});Dyn CompatibilityΒ§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.