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§
source§impl Observer
impl Observer
sourcepub fn new() -> Observer
pub fn new() -> Observer
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();
sourcepub fn wait(&self)
pub fn wait(&self)
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§
Auto Trait Implementations§
impl !RefUnwindSafe for Observer
impl !Send for Observer
impl !Sync for Observer
impl Unpin for Observer
impl !UnwindSafe for Observer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more