pika-installer-gtk4/src/main.rs

53 lines
1.3 KiB
Rust
Raw Normal View History

use std::env;
2024-08-18 17:00:56 +02:00
use gtk::{CssProvider, gdk, STYLE_PROVIDER_PRIORITY_APPLICATION, prelude::*, glib as glib};
2024-08-04 22:56:30 +02:00
use gdk::{Display};
mod config;
2024-08-04 22:56:30 +02:00
mod build_ui;
mod efi_error_page;
mod installer_stack_page;
2024-08-06 18:08:03 +02:00
//
2024-08-05 02:25:05 +02:00
mod welcome_page;
mod language_page;
2024-08-06 18:08:03 +02:00
mod eula_page;
2024-08-06 22:56:10 +02:00
mod keyboard_page;
2024-08-07 01:02:56 +02:00
mod timezone_page;
2024-08-07 01:27:24 +02:00
mod partitioning_page;
2024-08-08 17:56:02 +02:00
mod automatic_partitioning_page;
2024-08-17 00:15:03 +02:00
mod manual_partitioning_page;
2024-08-18 00:17:57 +02:00
mod drive_mount_row;
#[macro_use]
extern crate rust_i18n;
i18n!("locales", fallback = "en_US");
2024-08-04 22:56:30 +02:00
fn main() -> glib::ExitCode {
let current_locale = match env::var_os("LANG") {
2024-08-04 22:56:30 +02:00
Some(v) => v.into_string().unwrap().chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
2024-08-04 22:56:30 +02:00
rust_i18n::set_locale(&current_locale);
let app = adw::Application::builder().application_id(config::APP_ID).build();
app.connect_startup(|app| {
load_css();
app.connect_activate(build_ui::build_ui);
2024-01-14 22:31:40 +01:00
});
2024-08-04 22:56:30 +02:00
// Run the application
app.run()
2024-02-19 18:44:10 +01:00
}
2024-08-04 22:56:30 +02:00
fn load_css() {
let provider = CssProvider::new();
provider.load_from_string(include_str!("style.css"));
gtk::style_context_add_provider_for_display(
&Display::default().expect("Could not connect to a display."),
&provider,
STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}