From f3a453d15174034833484f1b4b0b934b360802fa Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 7 Dec 2023 09:45:56 -0500 Subject: [PATCH 1/2] Set up a development gsettings schema --- Cargo.lock | 1 + fitnesstrax/app/Cargo.toml | 1 + ...minescent-dreams.fitnesstrax.dev.gschema.xml | 9 +++++++++ fitnesstrax/app/src/main.rs | 17 ++++++++++++++--- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 fitnesstrax/app/resources/com.luminescent-dreams.fitnesstrax.dev.gschema.xml diff --git a/Cargo.lock b/Cargo.lock index 5128401..3c04fd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -976,6 +976,7 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" name = "fitnesstrax" version = "0.1.0" dependencies = [ + "ft-core", "gio", "glib", "glib-build-tools 0.18.0", diff --git a/fitnesstrax/app/Cargo.toml b/fitnesstrax/app/Cargo.toml index 4692329..005fc16 100644 --- a/fitnesstrax/app/Cargo.toml +++ b/fitnesstrax/app/Cargo.toml @@ -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" ] } diff --git a/fitnesstrax/app/resources/com.luminescent-dreams.fitnesstrax.dev.gschema.xml b/fitnesstrax/app/resources/com.luminescent-dreams.fitnesstrax.dev.gschema.xml new file mode 100644 index 0000000..53d1d41 --- /dev/null +++ b/fitnesstrax/app/resources/com.luminescent-dreams.fitnesstrax.dev.gschema.xml @@ -0,0 +1,9 @@ + + + + + "" + Path to the series + + + diff --git a/fitnesstrax/app/src/main.rs b/fitnesstrax/app/src/main.rs index 3204d89..5369d27 100644 --- a/fitnesstrax/app/src/main.rs +++ b/fitnesstrax/app/src/main.rs @@ -1,7 +1,11 @@ -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/"; + struct AppState {} struct AppWindow { @@ -11,9 +15,16 @@ struct AppWindow { fn main() { println!("Hello, world!"); + let app_id = APP_ID_DEV; + let base_path = RESOURCE_BASE_PATH_DEV; + + 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(); /* -- 2.44.1 From a7d6d82ec2e948b1c1830295031e971fc5094100 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 7 Dec 2023 09:56:10 -0500 Subject: [PATCH 2/2] Set up an environment variable to toggle between dev and production schemas --- fitnesstrax/app/src/main.rs | 12 +++++++----- flake.nix | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fitnesstrax/app/src/main.rs b/fitnesstrax/app/src/main.rs index 5369d27..fdfe8f2 100644 --- a/fitnesstrax/app/src/main.rs +++ b/fitnesstrax/app/src/main.rs @@ -2,9 +2,10 @@ 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 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 {} @@ -13,10 +14,11 @@ struct AppWindow { } fn main() { - println!("Hello, world!"); - - let app_id = APP_ID_DEV; - let base_path = RESOURCE_BASE_PATH_DEV; + 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); diff --git a/flake.nix b/flake.nix index bac9d63..387310c 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,7 @@ typeshare.packages."x86_64-linux".default ]; LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; + ENV = "dev"; }; }; } -- 2.44.1