2024-01-14 22:31:40 +01:00
|
|
|
// Use libraries
|
2024-02-18 16:39:04 +01:00
|
|
|
use crate::build_ui::build_ui;
|
2024-01-14 22:31:40 +01:00
|
|
|
use adw::prelude::*;
|
|
|
|
use adw::*;
|
|
|
|
use gdk::Display;
|
2024-02-16 22:21:09 +01:00
|
|
|
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
|
|
|
|
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
|
|
|
|
use gtk::*;
|
2024-02-17 14:52:07 +01:00
|
|
|
|
2024-02-18 16:39:04 +01:00
|
|
|
mod config;
|
2024-02-19 18:44:10 +01:00
|
|
|
use config::{APP_ID, GETTEXT_PACKAGE, LOCALEDIR};
|
2024-02-18 16:39:04 +01:00
|
|
|
use gettextrs::{gettext, LocaleCategory};
|
|
|
|
|
2024-02-16 22:21:09 +01:00
|
|
|
mod automatic_partitioning;
|
2024-01-14 22:31:40 +01:00
|
|
|
mod build_ui;
|
2024-02-16 22:21:09 +01:00
|
|
|
mod done_page;
|
|
|
|
mod drive_mount_row;
|
2024-01-20 18:48:32 +01:00
|
|
|
mod efi_error_page;
|
2024-01-17 14:50:32 +01:00
|
|
|
mod eula_page;
|
2024-01-20 20:01:20 +01:00
|
|
|
mod install_page;
|
2024-02-16 22:21:09 +01:00
|
|
|
mod keyboard_page;
|
|
|
|
mod language_page;
|
2024-02-10 19:03:19 +01:00
|
|
|
mod manual_partitioning;
|
2024-02-16 22:21:09 +01:00
|
|
|
mod partitioning_page;
|
|
|
|
mod save_window_size;
|
|
|
|
mod timezone_page;
|
|
|
|
mod welcome_page;
|
2024-01-14 22:31:40 +01:00
|
|
|
|
|
|
|
/// main function
|
|
|
|
fn main() {
|
2024-02-19 18:44:10 +01:00
|
|
|
let application = adw::Application::new(Some(APP_ID), Default::default());
|
2024-01-14 22:31:40 +01:00
|
|
|
application.connect_startup(|app| {
|
|
|
|
// The CSS "magic" happens here.
|
|
|
|
let provider = CssProvider::new();
|
2024-01-19 12:37:40 +01:00
|
|
|
provider.load_from_string(include_str!("style.css"));
|
2024-01-14 22:31:40 +01:00
|
|
|
// 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,
|
|
|
|
);
|
2024-02-18 16:39:04 +01:00
|
|
|
// Prepare i18n
|
|
|
|
gettextrs::setlocale(LocaleCategory::LcAll, "");
|
2024-02-19 18:44:10 +01:00
|
|
|
gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR)
|
|
|
|
.expect("Unable to bind the text domain");
|
2024-02-18 16:39:04 +01:00
|
|
|
gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");
|
|
|
|
// Fallback if no translation present
|
2024-02-18 18:28:14 +01:00
|
|
|
if gettext("pikaos_installer") == "pikaos_installer" {
|
2024-02-18 16:39:04 +01:00
|
|
|
println!("Warning: Current LANG is not supported, using fallback Locale.");
|
|
|
|
gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8");
|
|
|
|
}
|
2024-01-14 22:31:40 +01:00
|
|
|
|
2024-02-18 16:39:04 +01:00
|
|
|
app.connect_activate(build_ui);
|
2024-01-14 22:31:40 +01:00
|
|
|
});
|
2024-02-18 16:39:04 +01:00
|
|
|
|
2024-01-14 22:31:40 +01:00
|
|
|
application.run();
|
2024-02-19 18:44:10 +01:00
|
|
|
}
|