Set up configuration via gsettings #115

Merged
savanni merged 2 commits from fitnesstrax/gsettings into main 2023-12-07 15:34:32 +00:00
5 changed files with 29 additions and 4 deletions

1
Cargo.lock generated
View File

@ -976,6 +976,7 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6"
name = "fitnesstrax"
version = "0.1.0"
dependencies = [
"ft-core",
"gio",
"glib",
"glib-build-tools 0.18.0",

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] }
ft-core = { path = "../core" }
gio = { version = "0.18" }
glib = { version = "0.18" }
gtk = { version = "0.7", package = "gtk4", features = [ "v4_8" ] }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<schemalist>
<schema id="com.luminescent-dreams.fitnesstrax.dev" path="/com/luminescent-dreams/fitnesstrax/dev/">
<key name="series-path" type="s">
<default>""</default>
<summary>Path to the series</summary>
</key>
</schema>
</schemalist>

View File

@ -1,7 +1,12 @@
use fitnesstrax;
use gtk::prelude::*;
use std::env;
const APP_ID_DEV: &str = "com.luminescent-dreams.fitnesstrax.dev";
const APP_ID_PROD: &str = "com.luminescent-dreams.fitnesstrax";
const RESOURCE_BASE_PATH_DEV: &str = "/com/luminescent-dreams/fitnesstrax/dev/";
const RESOURCE_BASE_PATH_PROD: &str = "/com/luminescent-dreams/fitnesstrax/";
struct AppState {}
struct AppWindow {
@ -9,11 +14,19 @@ struct AppWindow {
}
fn main() {
println!("Hello, world!");
let (app_id, base_path) = if std::env::var_os("ENV") == Some("dev".into()) {
(APP_ID_DEV, RESOURCE_BASE_PATH_DEV)
} else {
(APP_ID_PROD, RESOURCE_BASE_PATH_PROD)
};
let settings = gio::Settings::new(app_id);
println!("database path: {}", settings.string("series-path"));
let app = adw::Application::builder()
.application_id("com.luminescent-dreams.fitnesstrax")
.resource_base_path("/com/luminescent-dreams/fitnesstrax")
.application_id(app_id)
.resource_base_path(base_path)
.build();
/*

View File

@ -48,6 +48,7 @@
typeshare.packages."x86_64-linux".default
];
LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
ENV = "dev";
};
};
}