vte: silence warnings

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2024-07-24 20:06:46 +04:00
parent 912e945758
commit edc7c26a54

View File

@ -29,48 +29,44 @@ fn main() {
window.set_child(Some(&term)); window.set_child(Some(&term));
let id = chardev_id.clone(); let id = chardev_id.clone();
MainContext::default().spawn_local(clone!( MainContext::default().spawn_local(clone!(async move {
#[strong] let conn = Connection::session()
window, .await
async move { .expect("Failed to connect to session D-Bus");
let conn = Connection::session()
.await
.expect("Failed to connect to session D-Bus");
let c = Chardev::new(&conn, &id).await.unwrap(); let c = Chardev::new(&conn, &id).await.unwrap();
c.proxy.name().await.expect("Chardev not found"); c.proxy.name().await.expect("Chardev not found");
let (p0, p1) = UnixStream::pair().unwrap(); let (p0, p1) = UnixStream::pair().unwrap();
if c.proxy.register((&p1).into()).await.is_ok() { if c.proxy.register((&p1).into()).await.is_ok() {
let ostream = unsafe { gio::UnixOutputStream::with_fd(p0.as_raw_fd()) }; let ostream = unsafe { gio::UnixOutputStream::with_fd(p0.as_raw_fd()) };
let istream = unsafe { gio::UnixInputStream::take_fd(p0) } let istream = unsafe { gio::UnixInputStream::take_fd(p0) }
.dynamic_cast::<gio::PollableInputStream>() .dynamic_cast::<gio::PollableInputStream>()
.unwrap(); .unwrap();
let mut read = istream.into_async_read().unwrap(); let mut read = istream.into_async_read().unwrap();
term.connect_commit(move |_, text, _| { term.connect_commit(move |_, text, _| {
let _res = ostream.write(text.as_bytes(), gio::Cancellable::NONE); let _res = ostream.write(text.as_bytes(), gio::Cancellable::NONE);
// TODO cancellable and error // TODO cancellable and error
}); });
loop { loop {
let mut buffer = [0u8; 8192]; let mut buffer = [0u8; 8192];
match read.read(&mut buffer[..]).await { match read.read(&mut buffer[..]).await {
Ok(0) => break, Ok(0) => break,
Ok(len) => { Ok(len) => {
term.feed(&buffer[..len]); term.feed(&buffer[..len]);
} }
Err(e) => { Err(e) => {
log::warn!("{}", e); log::warn!("{}", e);
break; break;
}
} }
} }
} }
} }
)); }));
window.show(); window.set_visible(true);
}); });
app.run(); app.run();