musicus/src/main.rs
2020-10-16 21:24:55 +02:00

49 lines
1.2 KiB
Rust

// 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;
use gio::prelude::*;
use glib::clone;
use std::cell::RefCell;
use std::rc::Rc;
mod backend;
mod database;
mod dialogs;
mod screens;
mod widgets;
mod window;
use window::Window;
fn main() {
gtk::init().expect("Failed to initialize GTK!");
libhandy::init();
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_desktop"),
gio::ApplicationFlags::empty(),
)
.expect("Failed to initialize GTK application!");
let window: RefCell<Option<Rc<Window>>> = RefCell::new(None);
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);
}