2024-09-20 18:02:10 +03:00
|
|
|
mod browser;
|
2024-09-18 20:33:29 +03:00
|
|
|
|
2024-09-21 14:21:39 +03:00
|
|
|
use std::fs;
|
|
|
|
|
2024-09-20 18:02:10 +03:00
|
|
|
use gtk::prelude::{ApplicationExt, ApplicationExtManual, GtkApplicationExt, GtkWindowExt};
|
2024-09-19 00:34:46 +03:00
|
|
|
|
2024-09-20 18:02:10 +03:00
|
|
|
use gtk::{glib, Application};
|
2024-09-18 16:24:25 +03:00
|
|
|
|
2024-09-20 18:02:10 +03:00
|
|
|
fn main() -> glib::ExitCode {
|
2024-09-21 14:21:39 +03:00
|
|
|
// Init meta
|
|
|
|
const APP_ID: &str = "io.github.yggverse.Yoda";
|
|
|
|
|
|
|
|
// Init config location
|
|
|
|
let mut config = gtk::glib::user_config_dir();
|
|
|
|
|
|
|
|
config.push(APP_ID);
|
|
|
|
|
|
|
|
if fs::create_dir_all(config).is_err() {
|
2024-09-21 14:22:19 +03:00
|
|
|
panic!("Failed to create profile directory")
|
2024-09-21 14:21:39 +03:00
|
|
|
}
|
|
|
|
|
2024-09-19 17:06:40 +03:00
|
|
|
// Init app
|
2024-09-21 14:21:39 +03:00
|
|
|
let app = Application::builder().application_id(APP_ID).build();
|
2024-09-18 16:24:25 +03:00
|
|
|
|
2024-09-19 17:06:40 +03:00
|
|
|
// Init accels
|
2024-09-20 18:02:10 +03:00
|
|
|
app.set_accels_for_action("win.tab_append", &["<Ctrl>t"]);
|
|
|
|
app.set_accels_for_action("win.tab_close", &["<Ctrl>q"]);
|
|
|
|
app.set_accels_for_action("win.debug", &["<Ctrl>i"]);
|
|
|
|
app.set_accels_for_action("win.quit", &["<Ctrl>Escape"]);
|
2024-09-19 17:06:40 +03:00
|
|
|
|
|
|
|
// Create new window
|
2024-09-20 18:02:10 +03:00
|
|
|
app.connect_activate(|app| {
|
|
|
|
browser::new(app, 640, 480).present();
|
|
|
|
});
|
2024-09-18 16:24:25 +03:00
|
|
|
|
2024-09-19 17:06:40 +03:00
|
|
|
// Start
|
2024-09-18 16:24:25 +03:00
|
|
|
app.run()
|
2024-09-20 18:02:10 +03:00
|
|
|
}
|