From 0ac9bb74a694a2687493728b288a9a5c2375f138 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 19 Nov 2023 22:47:36 -0500 Subject: [PATCH] Set up the bare minimum of a GUI app, opening only a single window --- Cargo.lock | 7 +++++++ fitnesstrax/Cargo.toml | 21 ++++++++++++++++++++- fitnesstrax/src/main.rs | 35 +++++++++++++++++++++++++++++++++++ fitnesstrax/src/types.rs | 4 ++++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1be57a2..b71ef7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -976,8 +976,15 @@ name = "fitnesstrax" version = "0.1.0" dependencies = [ "chrono", + "chrono-tz", "dimensioned 0.8.0", "emseries", + "gio", + "glib", + "glib-build-tools 0.18.0", + "gtk4", + "libadwaita", + "tokio", ] [[package]] diff --git a/fitnesstrax/Cargo.toml b/fitnesstrax/Cargo.toml index da0b1bc..85ba517 100644 --- a/fitnesstrax/Cargo.toml +++ b/fitnesstrax/Cargo.toml @@ -5,7 +5,26 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "fitnesstrax" +path = "src/lib.rs" + +[[bin]] +name = "fitnesstrax" +path = "src/main.rs" + [dependencies] +adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] } chrono = { version = "0.4" } -dimensioned = {version = "0.8" } +chrono-tz = { version = "0.8" } +dimensioned = { version = "0.8" } emseries = { path = "../emseries" } +gio = { version = "0.18" } +glib = { version = "0.18" } +gtk = { version = "0.7", package = "gtk4", features = [ "v4_8" ] } +tokio = { version = "1.34", features = [ "full" ] } + +[build-dependencies] +glib-build-tools = "0.18" + + diff --git a/fitnesstrax/src/main.rs b/fitnesstrax/src/main.rs index e7a11a9..3204d89 100644 --- a/fitnesstrax/src/main.rs +++ b/fitnesstrax/src/main.rs @@ -1,3 +1,38 @@ +use fitnesstrax; +use gtk::prelude::*; +use std::env; + +struct AppState {} + +struct AppWindow { + window: adw::ApplicationWindow, +} + fn main() { println!("Hello, world!"); + + let app = adw::Application::builder() + .application_id("com.luminescent-dreams.fitnesstrax") + .resource_base_path("/com/luminescent-dreams/fitnesstrax") + .build(); + + /* + let runtime = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap(); + */ + + let app = adw::Application::builder() + .application_id("com.luminescent-dreams.fitnesstrax") + .resource_base_path("/com/luminescent-dreams/fitnesstrax") + .build(); + + app.connect_activate(move |app| { + let window = adw::ApplicationWindow::new(app); + window.present(); + }); + + let args: Vec = env::args().collect(); + ApplicationExtManual::run_with_args(&app, &args); } diff --git a/fitnesstrax/src/types.rs b/fitnesstrax/src/types.rs index 0dfc3e5..f09eab5 100644 --- a/fitnesstrax/src/types.rs +++ b/fitnesstrax/src/types.rs @@ -1,3 +1,7 @@ +use chrono::NaiveDate; +use dimensioned::si; +use emseries::DateTimeTz; + /// SetRep represents workouts like pushups or situps, which involve doing a "set" of a number of /// actions, resting, and then doing another set. pub struct SetRep {