pika-welcome/src/main.rs

52 lines
1.7 KiB
Rust
Raw Normal View History

2024-01-30 23:33:07 +03:00
// GTK crates
mod config;
2024-02-09 00:49:42 +03:00
use adw::prelude::*;
use adw::*;
use gdk::Display;
2024-01-30 23:33:07 +03:00
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*;
use gettextrs::{gettext, LocaleCategory};
use config::{GETTEXT_PACKAGE, LOCALEDIR, APP_ID};
2024-01-30 23:33:07 +03:00
// application crates
mod build_ui;
use crate::build_ui::build_ui;
2024-01-31 21:48:55 +03:00
/// first setup crates
mod first_setup;
2024-01-30 23:33:07 +03:00
/// main function
fn main() {
2024-02-09 00:49:42 +03:00
let application = adw::Application::new(
Some(APP_ID),
2024-02-09 00:49:42 +03:00
Default::default(),
);
2024-01-30 23:33:07 +03:00
application.connect_startup(|app| {
// The CSS "magic" happens here.
let provider = CssProvider::new();
provider.load_from_string(include_str!("style.css"));
// We give the CssProvided to the default screen so the CSS rules we added
// can be applied to our window.
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
STYLE_PROVIDER_PRIORITY_APPLICATION,
);
// Prepare i18n
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");
2024-02-09 22:16:33 +03:00
// Fallback if no translation present
if gettext("first_setup_initial_box_text_title") == "first_setup_initial_box_text_title" {
println!("Warning: Current LANG is not supported, using fallback Locale.");
gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8");
}
2024-01-30 23:33:07 +03:00
app.connect_activate(build_ui);
});
2024-02-09 00:49:42 +03:00
2024-01-30 23:33:07 +03:00
application.run();
}