mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Initial commit
This commit is contained in:
commit
868e1168e5
8 changed files with 850 additions and 0 deletions
31
src/main.rs
Normal file
31
src/main.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use gio::prelude::*;
|
||||
use glib::clone;
|
||||
use std::cell::RefCell;
|
||||
|
||||
mod window;
|
||||
use window::Window;
|
||||
|
||||
fn main() {
|
||||
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::new(None::<Window>);
|
||||
|
||||
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);
|
||||
}
|
||||
43
src/window.rs
Normal file
43
src/window.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use gio::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
use gtk_macros::{action, get_widget};
|
||||
|
||||
pub struct Window {
|
||||
window: gtk::ApplicationWindow,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(app: >k::Application) -> Self {
|
||||
let builder = gtk::Builder::from_resource("/de/johrpan/musicus_editor/ui/window.ui");
|
||||
|
||||
get_widget!(builder, gtk::ApplicationWindow, window);
|
||||
|
||||
action!(window, "add-person", |_, _| {
|
||||
println!("TODO: Add person.");
|
||||
});
|
||||
|
||||
action!(window, "add-instrument", |_, _| {
|
||||
println!("TODO: Add instrument.");
|
||||
});
|
||||
|
||||
action!(window, "add-work", |_, _| {
|
||||
println!("TODO: Add work.");
|
||||
});
|
||||
|
||||
action!(window, "add-ensemble", |_, _| {
|
||||
println!("TODO: Add ensemble.");
|
||||
});
|
||||
|
||||
action!(window, "add-recording", |_, _| {
|
||||
println!("TODO: Add recording.");
|
||||
});
|
||||
|
||||
window.set_application(Some(app));
|
||||
|
||||
Window { window: window }
|
||||
}
|
||||
|
||||
pub fn present(&self) {
|
||||
self.window.present();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue