mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
migrate to relm 0.8.1
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -1,30 +1,41 @@
|
||||
#[rustfmt::skip]
|
||||
mod config;
|
||||
mod app;
|
||||
mod config;
|
||||
mod factories;
|
||||
mod modals;
|
||||
mod setup;
|
||||
|
||||
use crate::config::{APP_ID, GETTEXT_PACKAGE, LOCALEDIR, RESOURCES_FILE};
|
||||
use gettextrs::{gettext, LocaleCategory};
|
||||
use gtk::prelude::ApplicationExt;
|
||||
use gtk::{gio, glib};
|
||||
use relm4::{
|
||||
actions::{AccelsPlus, RelmAction, RelmActionGroup},
|
||||
gtk, main_application, RelmApp,
|
||||
};
|
||||
|
||||
use app::App;
|
||||
use setup::setup;
|
||||
|
||||
relm4::new_action_group!(AppActionGroup, "app");
|
||||
relm4::new_stateless_action!(QuitAction, AppActionGroup, "quit");
|
||||
|
||||
fn main() {
|
||||
gtk::init().unwrap();
|
||||
// Enable logging
|
||||
tracing_subscriber::fmt()
|
||||
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
|
||||
.with_max_level(tracing::Level::INFO)
|
||||
.init();
|
||||
|
||||
setup();
|
||||
// setup gettext
|
||||
gettextrs::setlocale(LocaleCategory::LcAll, "");
|
||||
gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain");
|
||||
gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");
|
||||
|
||||
glib::set_application_name(&gettext("Toolbox Tuner"));
|
||||
|
||||
let res = gio::Resource::load(RESOURCES_FILE).expect("Could not load gresource file");
|
||||
gio::resources_register(&res);
|
||||
|
||||
gtk::Window::set_default_icon_name(APP_ID);
|
||||
|
||||
let app = main_application();
|
||||
app.set_resource_base_path(Some("/org/kuchelmeister/ToolboxTuner/"));
|
||||
@@ -45,5 +56,12 @@ fn main() {
|
||||
let app = RelmApp::from_app(app);
|
||||
relm4_icons::initialize_icons();
|
||||
|
||||
app.run::<App>(());
|
||||
let data = res
|
||||
.lookup_data(
|
||||
"/org/kuchelmeister/ToolboxTuner/style.css",
|
||||
gio::ResourceLookupFlags::NONE,
|
||||
)
|
||||
.unwrap();
|
||||
app.set_global_css(&glib::GString::from_utf8_checked(data.to_vec()).unwrap());
|
||||
app.visible_on_activate(false).run::<App>(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user