Compare commits
No commits in common. "38db3d6780b25de87802490f44ccade3c7c578a7" and "acdf9ec1508ecb02c337e9443ca92c315b8c632b" have entirely different histories.
38db3d6780
...
acdf9ec150
|
@ -11,7 +11,7 @@ emseries = { path = "../../emseries" }
|
||||||
ft-core = { path = "../core" }
|
ft-core = { path = "../core" }
|
||||||
gio = { version = "0.18" }
|
gio = { version = "0.18" }
|
||||||
glib = { version = "0.18" }
|
glib = { version = "0.18" }
|
||||||
gtk = { version = "0.7", package = "gtk4", features = [ "v4_10" ] }
|
gtk = { version = "0.7", package = "gtk4", features = [ "v4_8" ] }
|
||||||
tokio = { version = "1.34", features = [ "full" ] }
|
tokio = { version = "1.34", features = [ "full" ] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -13,9 +13,6 @@ General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod ui;
|
|
||||||
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use emseries::Series;
|
use emseries::Series;
|
||||||
use ft_core::TraxRecord;
|
use ft_core::TraxRecord;
|
||||||
|
@ -27,7 +24,6 @@ use std::{
|
||||||
env,
|
env,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
};
|
};
|
||||||
use ui::FileChooserRow;
|
|
||||||
|
|
||||||
const APP_ID_DEV: &str = "com.luminescent-dreams.fitnesstrax.dev";
|
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";
|
||||||
|
@ -50,12 +46,12 @@ impl App {
|
||||||
|
|
||||||
/// This is the view to show if the application has not yet been configured. It will walk the user
|
/// This is the view to show if the application has not yet been configured. It will walk the user
|
||||||
/// through the most critical setup steps so that we can move on to the other views in the app.
|
/// through the most critical setup steps so that we can move on to the other views in the app.
|
||||||
pub struct WelcomeViewPrivate {}
|
pub struct UnconfiguredViewPrivate {}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
impl ObjectSubclass for WelcomeViewPrivate {
|
impl ObjectSubclass for UnconfiguredViewPrivate {
|
||||||
const NAME: &'static str = "WelcomeView";
|
const NAME: &'static str = "UnconfiguredView";
|
||||||
type Type = WelcomeView;
|
type Type = UnconfiguredView;
|
||||||
type ParentType = gtk::Box;
|
type ParentType = gtk::Box;
|
||||||
|
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
|
@ -63,46 +59,24 @@ impl ObjectSubclass for WelcomeViewPrivate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectImpl for WelcomeViewPrivate {}
|
impl ObjectImpl for UnconfiguredViewPrivate {}
|
||||||
impl WidgetImpl for WelcomeViewPrivate {}
|
impl WidgetImpl for UnconfiguredViewPrivate {}
|
||||||
impl BoxImpl for WelcomeViewPrivate {}
|
impl BoxImpl for UnconfiguredViewPrivate {}
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
pub struct WelcomeView(ObjectSubclass<WelcomeViewPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
pub struct UnconfiguredView(ObjectSubclass<UnconfiguredViewPrivate>) @extends gtk::Box, gtk::Widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WelcomeView {
|
impl UnconfiguredView {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let s: Self = Object::builder().build();
|
let s: Self = Object::builder().build();
|
||||||
s.set_orientation(gtk::Orientation::Vertical);
|
|
||||||
s.set_css_classes(&["modal"]);
|
|
||||||
|
|
||||||
// Replace this with the welcome screen that we set up in the fitnesstrax/unconfigured-page
|
// Replace this with the welcome screen that we set up in the fitnesstrax/unconfigured-page
|
||||||
// branch.
|
// branch.
|
||||||
let title = gtk::Label::builder()
|
let label = gtk::Label::builder()
|
||||||
.label("Welcome to FitnessTrax")
|
.label("Database is not configured.")
|
||||||
.css_classes(["modal-title"])
|
|
||||||
.build();
|
.build();
|
||||||
s.append(&title);
|
s.append(&label);
|
||||||
|
|
||||||
let content = gtk::Box::builder()
|
|
||||||
.css_classes(["model-content"])
|
|
||||||
.orientation(gtk::Orientation::Vertical)
|
|
||||||
.vexpand(true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
content.append(>k::Label::new(Some("Welcome to FitnessTrax. The application has not yet been configured, so I will walk you through that. Let's start out by selecting your database.")));
|
|
||||||
|
|
||||||
// The database selection row should be a box that shows a default database path, along with a
|
|
||||||
// button that triggers a file chooser dialog. Once the dialog returns, the box should be
|
|
||||||
// updated to reflect the chosen path.
|
|
||||||
let db_row = FileChooserRow::new();
|
|
||||||
|
|
||||||
content.append(&db_row);
|
|
||||||
|
|
||||||
s.append(&content);
|
|
||||||
s.append(>k::Button::builder().label("Save Settings").build());
|
|
||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +141,7 @@ impl AppWindow {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let current_view = if app.database.read().unwrap().is_none() {
|
let current_view = if app.database.read().unwrap().is_none() {
|
||||||
WelcomeView::new().upcast()
|
UnconfiguredView::new().upcast()
|
||||||
} else {
|
} else {
|
||||||
HistoricalView::new().upcast()
|
HistoricalView::new().upcast()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
|
||||||
|
|
||||||
This file is part of FitnessTrax.
|
|
||||||
|
|
||||||
FitnessTrax is free software: you can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
General Public License as published by the Free Software Foundation, either version 3 of the
|
|
||||||
License, or (at your option) any later version.
|
|
||||||
|
|
||||||
FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
|
||||||
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use glib::Object;
|
|
||||||
use gtk::{prelude::*, subclass::prelude::*};
|
|
||||||
use std::{cell::RefCell, path::PathBuf};
|
|
||||||
|
|
||||||
pub struct FileChooserRowPrivate {
|
|
||||||
path: RefCell<Option<PathBuf>>,
|
|
||||||
label: gtk::Label,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[glib::object_subclass]
|
|
||||||
impl ObjectSubclass for FileChooserRowPrivate {
|
|
||||||
const NAME: &'static str = "FileChooser";
|
|
||||||
type Type = FileChooserRow;
|
|
||||||
type ParentType = gtk::Box;
|
|
||||||
|
|
||||||
fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
path: RefCell::new(None),
|
|
||||||
label: gtk::Label::builder().hexpand(true).build(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ObjectImpl for FileChooserRowPrivate {}
|
|
||||||
impl WidgetImpl for FileChooserRowPrivate {}
|
|
||||||
impl BoxImpl for FileChooserRowPrivate {}
|
|
||||||
|
|
||||||
glib::wrapper! {
|
|
||||||
pub struct FileChooserRow(ObjectSubclass<FileChooserRowPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FileChooserRow {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
let s: Self = Object::builder().build();
|
|
||||||
|
|
||||||
s.set_orientation(gtk::Orientation::Horizontal);
|
|
||||||
|
|
||||||
// The database selection row should be a box that shows a default database path, along with a
|
|
||||||
// button that triggers a file chooser dialog. Once the dialog returns, the box should be
|
|
||||||
// updated to reflect the chosen path.
|
|
||||||
s.imp().label.set_text("No database selected");
|
|
||||||
|
|
||||||
let db_file_chooser_button = gtk::Button::builder().label("Select Database").build();
|
|
||||||
db_file_chooser_button.connect_clicked({
|
|
||||||
let s = s.clone();
|
|
||||||
move |_| {
|
|
||||||
let no_window: Option<>k::Window> = None;
|
|
||||||
let not_cancellable: Option<&gio::Cancellable> = None;
|
|
||||||
let s = s.clone();
|
|
||||||
gtk::FileDialog::builder().build().open(
|
|
||||||
no_window,
|
|
||||||
not_cancellable,
|
|
||||||
move |file_id| match file_id {
|
|
||||||
Ok(file_id) => match file_id.path() {
|
|
||||||
Some(path) => {
|
|
||||||
s.imp().label.set_text(path.to_str().unwrap());
|
|
||||||
*s.imp().path.borrow_mut() = Some(path);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
*s.imp().path.borrow_mut() = None;
|
|
||||||
s.imp().label.set_text("No database selected");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(err) => println!("file opening failed: {}", err),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
s.append(&s.imp().label);
|
|
||||||
s.append(&db_file_chooser_button);
|
|
||||||
|
|
||||||
s
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue