I am passing the sender of on async channel to a modal window so that the modal window can send messages to the parent window:
...
let (tx, rx): (Sender<ApplicationMessage>, Receiver<ApplicationMessage>) = async_channel::bounded(1);
let window = MainWindow::new(&*self.obj());
window.connect_close_request(move |window| {
debug!("connect_close_request");
let dialog = ConfirmCloseDialog::new(window, &tx);
dialog.set_transient_for(Some(window));
dialog.present();
// glib::Propagation::Proceed
glib::Propagation::Stop
});
and I added pub fn new<P: IsA<gtk::Window>>(window: &P, tx: &Sender<ApplicationMessage>) -> Self to the impl of the dialog. How do I store the tx in the imp struct of the dialog?