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