use gtk4::prelude::*; use gtk4::{ ApplicationWindow, Box, Entry, Label, Orientation, HeaderBar, CheckButton }; use toml; use serde::Serialize; #[allow(dead_code)] #[derive(Debug, Serialize)] struct Settings { js: bool, outproxy: bool, i2p_proxy: bool, web_rtc: bool, home_addr: str, } #[allow(dead_code, unused_variables)] pub fn window() -> ApplicationWindow { let app = ApplicationWindow::builder() .title("Settings") .default_width(400) .default_height(300) .build(); let header_bar = HeaderBar::new(); window().set_titlebar(Some(&header_bar)); let main_box = Box::new(Orientation::Vertical, 0); window().set_child(Some(&main_box)); Label::new(Some("Settings")).set_markup("Settings"); let javascript = CheckButton::new().set_label(Some("Enable JS")); let outproxy = CheckButton::new().set_label(Some("Enable outproxy")); let i2pproxy = CheckButton::new().set_label(Some("Enable i2p proxy")); let webrtc = CheckButton::new().set_label(Some("Enable WebRTC")); let homeaddr = Entry::new(); app } #[allow(dead_code)] impl Settings { pub fn serialize_write(path: &std::path::Path, setts: &Settings) -> Result<(), toml::ser::Error> { let toml: String = toml::to_string(setts)?; std::fs::write(path, toml).expect("Some error occured, is permission granted to ~/.config?"); Ok(()) } }