Yoda/src/main.rs

35 lines
978 B
Rust
Raw Normal View History

2024-10-02 02:14:00 +03:00
mod app;
2024-09-18 20:33:29 +03:00
2024-10-02 02:14:00 +03:00
use app::App;
use gtk::glib::{user_config_dir, ExitCode};
use sqlite::Connection;
use std::{fs::create_dir_all, sync::Arc};
2024-09-21 20:48:12 +03:00
2024-09-30 02:00:14 +03:00
fn main() -> ExitCode {
// Init profile path
let mut profile_path = user_config_dir();
profile_path.push(env!("CARGO_PKG_NAME"));
if let Err(error) = create_dir_all(&profile_path) {
panic!("Failed to create profile directory: {error}")
}
// Init profile database path
let mut profile_database_path = profile_path.clone();
profile_database_path.push("database.sqlite3");
// Init database connection
let profile_database_connection = match Connection::open(profile_database_path) {
Ok(connection) => Arc::new(connection),
Err(error) => panic!("Failed to connect profile database: {error}"),
};
// Init GTK, start application
match gtk::init() {
Ok(_) => App::new(profile_database_connection).activate().run(),
Err(_) => ExitCode::FAILURE,
}
2024-09-20 18:02:10 +03:00
}