pub struct Observer { /* private fields */ }
Expand description

Used to wait for a widget’s signal.

It’s recommended to use it with the observer_new macro.

Example:

extern crate gtk;
#[macro_use]
extern crate gtk_test;

use gtk::prelude::GtkWindowExt;

gtk::init().expect("initialization failed");
let window = gtk::Window::new(gtk::WindowType::Toplevel);

let observer = observer_new!(window, connect_activate_focus, |_|);
window.emit_activate_focus();
observer.wait();

Implementations

Returns a new observer.

It’s recommended to not use it directly as is but instead to use the observer_new macro.

But anyway, here’s an example using it as is:

extern crate gtk;
#[macro_use]
extern crate gtk_test;

use gtk::prelude::GtkWindowExt;

gtk::init().expect("GTK init failed");

let window = gtk::Window::new(gtk::WindowType::Toplevel);

let observer = gtk_test::Observer::new();
let inner = observer.get_inner().clone();
window.connect_activate_focus(move |_| {
    *inner.borrow_mut() = true;
});

window.emit_activate_focus();
observer.wait();

Returns the inner field. Just don’t use it.

Wait for the signal to be triggered.

extern crate gtk;
#[macro_use]
extern crate gtk_test;

use gtk::prelude::GtkWindowExt;

gtk::init().expect("initialization failed");
let window = gtk::Window::new(gtk::WindowType::Toplevel);

let observer = observer_new!(window, connect_activate_focus, |_|);
window.emit_activate_focus();
observer.wait();

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.