80 lines
2.6 KiB
Rust
80 lines
2.6 KiB
Rust
#![allow(unused)]
|
|
#![allow(dead_code)]
|
|
#[macro_use]
|
|
mod utils;
|
|
#[macro_use]
|
|
extern crate lazy_static;
|
|
use config::Config;
|
|
use gtk::{
|
|
gio::{self, Settings},
|
|
prelude::SettingsExt,
|
|
};
|
|
use plugin_system::{init_plugin, PluginManager};
|
|
use std::{ptr, sync::Mutex};
|
|
use tokio::runtime::Runtime;
|
|
mod chart;
|
|
mod components;
|
|
mod config;
|
|
mod coords;
|
|
mod data;
|
|
mod errors;
|
|
mod pipeline;
|
|
mod plugin_system;
|
|
use components::app::AppModel;
|
|
use once_cell::{sync::Lazy as SafeLazy, unsync::Lazy as UnsafeLazy};
|
|
use tracing::info;
|
|
use tracing_subscriber;
|
|
mod widgets;
|
|
mod data_utils;
|
|
|
|
const APP_ID: &str = "org.tsuki.radar_g";
|
|
static RUNTIME: SafeLazy<Runtime> =
|
|
SafeLazy::new(|| Runtime::new().expect("Setting up tokio runtime needs to succeed."));
|
|
static CONFIG: SafeLazy<Mutex<Config>> = SafeLazy::new(|| Mutex::new(Config::from_env().unwrap()));
|
|
static PLUGIN_MANAGER: SafeLazy<PluginManager> = SafeLazy::new(|| PluginManager::new().unwrap());
|
|
|
|
fn main() {
|
|
// Load GL pointers from epoxy (GL context management library used by GTK).
|
|
tracing_subscriber::fmt::init();
|
|
{
|
|
#[cfg(target_os = "macos")]
|
|
let library =
|
|
unsafe { libloading::os::unix::Library::new("/opt/homebrew/lib/libepoxy.0.dylib") }
|
|
.or(unsafe { libloading::os::unix::Library::new("libepoxy.0.dylib") })
|
|
.unwrap();
|
|
|
|
#[cfg(all(unix, not(target_os = "macos")))]
|
|
let library = unsafe { libloading::os::unix::Library::new("libepoxy.so.0") }.unwrap();
|
|
#[cfg(windows)]
|
|
let library = libloading::os::windows::Library::open_already_loaded("libepoxy-0.dll")
|
|
.or_else(|_| libloading::os::windows::Library::open_already_loaded("epoxy-0.dll"))
|
|
.unwrap();
|
|
|
|
epoxy::load_with(|name| {
|
|
unsafe { library.get(name.as_bytes()) }
|
|
.map(|symbol| *symbol)
|
|
.unwrap_or(ptr::null())
|
|
});
|
|
}
|
|
let relm = relm4::RelmApp::new(APP_ID);
|
|
initialize_custom_css();
|
|
info!("Init plugin system");
|
|
let pluginmanager = PluginManager::new();
|
|
relm.run::<AppModel>(());
|
|
}
|
|
|
|
fn initialize_custom_css() {
|
|
gio::resources_register_include!("css.gresource").unwrap();
|
|
// Load the CSS file and add it to the provider
|
|
let provider = gtk::CssProvider::new();
|
|
// provider.load_from_string();
|
|
provider.load_from_resource("/org/tsuki/radar_g/css/main.css");
|
|
use gtk::gdk::Display;
|
|
// Add the provider to the default screen
|
|
gtk::style_context_add_provider_for_display(
|
|
&Display::default().expect("Could not connect to a display."),
|
|
&provider,
|
|
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
|
);
|
|
}
|