Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/data/gschemas.compiled
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions data/io.github.AghastyGD.Wiretray.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<schemalist>
<schema
id="io.github.AghastyGD.Wiretray"
path="/io/github/AghastyGD/Wiretray/">

<key name="ssid" type="s">
<default>''</default>
<summary>Hotspot SSID</summary>
</key>

<key name="password" type="s">
<default>''</default>
<summary>Hotspot password</summary>
</key>
</schema>
</schemalist>
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod dbus;
pub mod models;
pub mod services;
pub mod settings;
pub mod tray;
7 changes: 2 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
mod dbus;
mod models;
mod services;
mod tray;

use anyhow::Result;

use wiretray::tray;

fn main() -> Result<()> {
setup_logging();

Expand Down
5 changes: 5 additions & 0 deletions src/settings/hotspot_settings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HotspotSettings {
pub ssid: String,
pub password: String,
}
2 changes: 2 additions & 0 deletions src/settings/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod hotspot_settings;
pub mod service;
42 changes: 42 additions & 0 deletions src/settings/service.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use anyhow::Result;
use gtk::gio::Settings;
use gtk::prelude::SettingsExt;

use super::hotspot_settings::HotspotSettings;

const SCHEMA_ID: &str = "io.github.AghastyGD.Wiretray";

const KEY_SSID: &str = "ssid";
const KEY_PASSWORD: &str = "password";

pub struct SettingsService {
settings: Settings,
}

impl Default for SettingsService {
fn default() -> Self {
Self::new()
}
}

impl SettingsService {
pub fn new() -> Self {
Self {
settings: Settings::new(SCHEMA_ID),
}
}

pub fn load(&self) -> Result<HotspotSettings> {
Ok(HotspotSettings {
ssid: self.settings.string(KEY_SSID).to_string(),
password: self.settings.string(KEY_PASSWORD).to_string(),
})
}
pub fn save(&self, settings: &HotspotSettings) -> Result<()> {
self.settings.set_string(KEY_SSID, &settings.ssid)?;

self.settings.set_string(KEY_PASSWORD, &settings.password)?;

Ok(())
}
}
Loading