pika-installer-gtk4/src/main.rs

62 lines
1.4 KiB
Rust
Raw Normal View History

2024-08-19 01:12:35 +02:00
use gdk::Display;
use gtk::{gdk, glib, prelude::*, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION};
use std::env;
2024-08-04 22:56:30 +02:00
mod build_ui;
2024-08-19 01:12:35 +02:00
mod config;
2024-08-06 18:08:03 +02:00
//
2024-08-21 23:41:06 +02:00
mod installer_stack_page;
2024-08-19 01:12:35 +02:00
mod drive_mount_row;
2024-08-21 23:41:06 +02:00
//
mod welcome_page;
mod efi_error_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-19 01:12:35 +02:00
mod language_page;
mod timezone_page;
2024-08-21 23:41:06 +02:00
//
mod partitioning_page;
mod automatic_partitioning_page;
mod manual_partitioning_page;
//
mod installation_summary_page;
#[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-19 01:12:35 +02:00
Some(v) => v
.into_string()
.unwrap()
.chars()
2024-08-04 22:56:30 +02:00
.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);
2024-08-19 01:12:35 +02:00
let app = adw::Application::builder()
.application_id(config::APP_ID)
.build();
2024-08-04 22:56:30 +02:00
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,
);
2024-08-19 01:12:35 +02:00
}