pub trait MessageDialogExtManual: 'static {
    // Required methods
    fn response_label(&self, response: &str) -> GString;
    fn add_responses(&self, ids_and_labels: &[(&str, &str)]);
    fn run_future<'a>(&'a self) -> Pin<Box<dyn Future<Output = String> + 'a>>;
    fn run_async<F: FnOnce(&Self, &str) + 'static>(
        &self,
        detail: Option<&str>,
        f: F
    );
}
Available on crate feature v1_2 only.

Required Methods§

source

fn response_label(&self, response: &str) -> GString

source

fn add_responses(&self, ids_and_labels: &[(&str, &str)])

source

fn run_future<'a>(&'a self) -> Pin<Box<dyn Future<Output = String> + 'a>>

Shows the dialog and returns a Future that resolves to the ResponseType on response.

use libadwaita::prelude::*;

let dialog = libadwaita::MessageDialog::builder()
   .body("What is your answer?")
   .build();

dialog.add_responses(&[("ok", "Ok"), ("cancel", "Cancel")]);

let answer = dialog.run_future(None).await;
dialog.close();
println!("Answer: {answer}");
source

fn run_async<F: FnOnce(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F )

Shows the dialog and calls the callback when a response has been received.

Important: this function isn’t blocking.

use libadwaita::prelude::*;

let dialog = libadwaita::MessageDialog::builder()
   .body("What is your answer?")
   .build();

dialog.add_responses(&[("ok", "Ok"), ("cancel", "Cancel")]);

dialog.run_async(None, |obj, answer| {
    obj.close();
    println!("Answer: {:?}", answer);
});

Implementors§