mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
reorder dependencies
This commit is contained in:
parent
043661282c
commit
b3faf9a1cb
49
src/main.rs
49
src/main.rs
@ -6,29 +6,9 @@ use gtk::prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkW
|
||||
|
||||
use gtk::{glib, Application};
|
||||
|
||||
const APP_ID: &str = "io.github.yggverse.Yoda";
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
// Init meta
|
||||
const APP_ID: &str = "io.github.yggverse.Yoda";
|
||||
|
||||
// Init profile directory
|
||||
let mut fs = gtk::glib::user_config_dir();
|
||||
|
||||
fs.push(APP_ID);
|
||||
|
||||
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();
|
||||
|
||||
@ -39,8 +19,29 @@ fn main() -> glib::ExitCode {
|
||||
app.set_accels_for_action("win.quit", &["<Ctrl>Escape"]);
|
||||
|
||||
// Create new window
|
||||
app.connect_activate(move |app| {
|
||||
browser::new(&app, &db, 640, 480).present();
|
||||
app.connect_activate({
|
||||
// Init profile directory
|
||||
let mut fs = gtk::glib::user_config_dir();
|
||||
|
||||
fs.push(APP_ID);
|
||||
|
||||
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}"),
|
||||
};
|
||||
|
||||
move |this| {
|
||||
browser::new(&this, &db, 640, 480).present();
|
||||
}
|
||||
});
|
||||
|
||||
// Start
|
||||
|
Loading…
x
Reference in New Issue
Block a user