[][src]Macro vgtk::on_signal

macro_rules! on_signal {
    ($object:expr, $connect:ident) => { ... };

Connect a GLib signal to a Future.

This macro takes a GLib object and the name of a method to connect it to a signal (generally of the form connect_signal_name), and generates an async block that will resolve with the emitted value the first time the signal is emitted.

The output type of the async block is Result<T, Canceled>, where T is the type of the emitted value (the second argument to the callback connect_signal_name takes). It will produce Err(Canceled) if the object is destroyed before the signal is emitted.


let dialog = AboutDialog::new();
if on_signal!(dialog, connect_response).await == Ok(ResponseType::Accept) {
    println!("Dialog accepted");
} else {
    println!("Dialog not accepted");