summaryrefslogtreecommitdiff
path: root/src/settings_window.rs
blob: fbab489a1cfe391baad77d67cd4e66b41f215075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

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(())
    }
}