musicus/src/window.rs

62 lines
1.5 KiB
Rust
Raw Normal View History

2020-09-28 15:02:19 +02:00
use super::database::*;
use super::dialogs::*;
2020-09-27 21:58:42 +02:00
use gio::prelude::*;
2020-09-28 15:02:19 +02:00
use glib::clone;
2020-09-27 21:58:42 +02:00
use gtk::prelude::*;
use gtk_macros::{action, get_widget};
2020-09-28 15:02:19 +02:00
use std::cell::RefCell;
use std::rc::Rc;
2020-09-27 21:58:42 +02:00
pub struct Window {
window: gtk::ApplicationWindow,
2020-09-28 15:02:19 +02:00
db: Rc<Database>,
2020-09-27 21:58:42 +02:00
}
impl Window {
2020-09-28 15:02:19 +02:00
pub fn new(app: &gtk::Application) -> Rc<Self> {
2020-09-27 21:58:42 +02:00
let builder = gtk::Builder::from_resource("/de/johrpan/musicus_editor/ui/window.ui");
get_widget!(builder, gtk::ApplicationWindow, window);
2020-09-28 15:02:19 +02:00
let db = Rc::new(Database::new("test.sqlite"));
let result = Rc::new(Window {
window: window,
db: db,
2020-09-27 21:58:42 +02:00
});
2020-09-28 15:02:19 +02:00
action!(
result.window,
"add-person",
clone!(@strong result => move |_, _| {
PersonEditor::new(result.db.clone(), &result.window, None, |person| {
println!("{:?}", person);
}).show();
})
);
action!(result.window, "add-instrument", |_, _| {
2020-09-27 21:58:42 +02:00
println!("TODO: Add instrument.");
});
2020-09-28 15:02:19 +02:00
action!(result.window, "add-work", |_, _| {
2020-09-27 21:58:42 +02:00
println!("TODO: Add work.");
});
2020-09-28 15:02:19 +02:00
action!(result.window, "add-ensemble", |_, _| {
2020-09-27 21:58:42 +02:00
println!("TODO: Add ensemble.");
});
2020-09-28 15:02:19 +02:00
action!(result.window, "add-recording", |_, _| {
2020-09-27 21:58:42 +02:00
println!("TODO: Add recording.");
});
2020-09-28 15:02:19 +02:00
result.window.set_application(Some(app));
2020-09-27 21:58:42 +02:00
2020-09-28 15:02:19 +02:00
result
2020-09-27 21:58:42 +02:00
}
pub fn present(&self) {
self.window.present();
}
}