49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
|
use glib::{Continue, Sender};
|
||
|
use gtk::prelude::*;
|
||
|
use std::{
|
||
|
env,
|
||
|
sync::{Arc, RwLock},
|
||
|
};
|
||
|
|
||
|
mod app_window;
|
||
|
use app_window::ApplicationWindow;
|
||
|
|
||
|
#[derive(Clone, Debug)]
|
||
|
pub enum Message {}
|
||
|
|
||
|
#[derive(Clone)]
|
||
|
pub struct Core {
|
||
|
tx: Arc<RwLock<Option<Sender<Message>>>>,
|
||
|
}
|
||
|
|
||
|
pub fn main() {
|
||
|
let app = adw::Application::builder()
|
||
|
.application_id("com.luminescent-dreams.gm-control-panel")
|
||
|
.build();
|
||
|
|
||
|
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||
|
.enable_all()
|
||
|
.build()
|
||
|
.unwrap();
|
||
|
|
||
|
let core = Core {
|
||
|
tx: Arc::new(RwLock::new(None)),
|
||
|
};
|
||
|
|
||
|
app.connect_activate(move |app| {
|
||
|
let (gtk_tx, gtk_rx) =
|
||
|
gtk::glib::MainContext::channel::<Message>(gtk::glib::PRIORITY_DEFAULT);
|
||
|
|
||
|
*core.tx.write().unwrap() = Some(gtk_tx);
|
||
|
|
||
|
let window = ApplicationWindow::new(app);
|
||
|
window.window.present();
|
||
|
|
||
|
gtk_rx.attach(None, move |_msg| Continue(true));
|
||
|
});
|
||
|
|
||
|
let args: Vec<String> = env::args().collect();
|
||
|
ApplicationExtManual::run_with_args(&app, &args);
|
||
|
runtime.shutdown_background();
|
||
|
}
|