mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
init sqlite connection
This commit is contained in:
parent
49cb876749
commit
043661282c
3 changed files with 23 additions and 8 deletions
22
src/main.rs
22
src/main.rs
|
|
@ -10,15 +10,25 @@ fn main() -> glib::ExitCode {
|
|||
// Init meta
|
||||
const APP_ID: &str = "io.github.yggverse.Yoda";
|
||||
|
||||
// Init config location
|
||||
let mut config = gtk::glib::user_config_dir();
|
||||
// Init profile directory
|
||||
let mut fs = gtk::glib::user_config_dir();
|
||||
|
||||
config.push(APP_ID);
|
||||
fs.push(APP_ID);
|
||||
|
||||
if let Err(e) = fs::create_dir_all(config) {
|
||||
if let Err(e) = fs::create_dir_all(&fs) {
|
||||
panic!("Failed to create profile directory: {e}")
|
||||
}
|
||||
|
||||
// Init profile database
|
||||
let mut db = fs.clone();
|
||||
|
||||
db.push("database.sqlite3");
|
||||
|
||||
let db = match sqlite::open(db) {
|
||||
Ok(db) => db,
|
||||
Err(e) => panic!("Failed to connect profile database: {e}"),
|
||||
};
|
||||
|
||||
// Init app
|
||||
let app = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
|
|
@ -29,8 +39,8 @@ fn main() -> glib::ExitCode {
|
|||
app.set_accels_for_action("win.quit", &["<Ctrl>Escape"]);
|
||||
|
||||
// Create new window
|
||||
app.connect_activate(|app| {
|
||||
browser::new(app, 640, 480).present();
|
||||
app.connect_activate(move |app| {
|
||||
browser::new(&app, &db, 640, 480).present();
|
||||
});
|
||||
|
||||
// Start
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue