I'm trying to create a similar widget like Granite.AsyncImage using Rust Gtk, but I can't figure how to make it work because Pixbuff is not safe thread.
I have a code like next:
let file = gio::File::for_uri("https://e00-elmundo.uecdn.es/assets/multimedia/imagenes/2020/12/14/16079475000780.jpg");
file.read_async(
glib::Priority::default(),
Some(&gio::Cancellable::new()),
|s| {
match s {
Ok(stream) => {
Pixbuf::from_stream_at_scale_async(
&stream,
200,
200,
true,
Some(&gio::Cancellable::new()),
|r| {
match r {
Ok(pix) => {
// How can I send this pixbuff to a Gtk Image on main thread?
}
Err(_) => {}
}
});
}
Err(_) => todo!(),
}
});