mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-11 07:10:54 +03:00
47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
mod imp;
|
|
|
|
use adw::subclass::prelude::*;
|
|
use gtk::glib::{self, Object};
|
|
|
|
use lan_mouse_ipc::{ClientConfig, ClientHandle, ClientState};
|
|
|
|
glib::wrapper! {
|
|
pub struct ClientObject(ObjectSubclass<imp::ClientObject>);
|
|
}
|
|
|
|
impl ClientObject {
|
|
pub fn new(handle: ClientHandle, client: ClientConfig, state: ClientState) -> Self {
|
|
Object::builder()
|
|
.property("handle", handle)
|
|
.property("hostname", client.hostname)
|
|
.property("port", client.port as u32)
|
|
.property("position", client.pos.to_string())
|
|
.property("active", state.active)
|
|
.property(
|
|
"ips",
|
|
state
|
|
.ips
|
|
.iter()
|
|
.map(|ip| ip.to_string())
|
|
.collect::<Vec<_>>(),
|
|
)
|
|
.property("resolving", state.resolving)
|
|
.build()
|
|
}
|
|
|
|
pub fn get_data(&self) -> ClientData {
|
|
self.imp().data.borrow().clone()
|
|
}
|
|
}
|
|
|
|
#[derive(Default, Clone)]
|
|
pub struct ClientData {
|
|
pub handle: ClientHandle,
|
|
pub hostname: Option<String>,
|
|
pub port: u32,
|
|
pub active: bool,
|
|
pub position: String,
|
|
pub resolving: bool,
|
|
pub ips: Vec<String>,
|
|
}
|