musicus/src/main.rs

50 lines
1.2 KiB
Rust
Raw Normal View History

// Required for database/schema.rs
#[macro_use]
extern crate diesel;
// Required for embed_migrations macro in database/database.rs
#[macro_use]
extern crate diesel_migrations;
2020-09-27 21:58:42 +02:00
use gio::prelude::*;
use glib::clone;
use std::cell::RefCell;
2020-09-28 15:02:19 +02:00
use std::rc::Rc;
2020-09-27 21:58:42 +02:00
mod backend;
mod database;
2020-09-28 15:02:19 +02:00
mod dialogs;
2020-10-16 21:24:55 +02:00
mod screens;
mod widgets;
2020-09-27 21:58:42 +02:00
mod window;
use window::Window;
fn main() {
gtk::init().expect("Failed to initialize GTK!");
libhandy::init();
2020-09-27 21:58:42 +02:00
let bytes = glib::Bytes::from(include_bytes!("../res/resources.gresource").as_ref());
let resource = gio::Resource::from_data(&bytes).expect("Failed to load resources!");
gio::resources_register(&resource);
let app = gtk::Application::new(
Some("de.johrpan.musicus"),
2020-09-27 21:58:42 +02:00
gio::ApplicationFlags::empty(),
)
.expect("Failed to initialize GTK application!");
2020-09-28 15:02:19 +02:00
let window: RefCell<Option<Rc<Window>>> = RefCell::new(None);
2020-09-27 21:58:42 +02:00
app.connect_activate(clone!(@strong app => move |_| {
let mut window = window.borrow_mut();
if window.is_none() {
window.replace(Window::new(&app));
}
window.as_ref().unwrap().present();
}));
let args = std::env::args().collect::<Vec<String>>();
app.run(&args);
}