2024-01-20 18:48:32 +01:00
|
|
|
use std::path::Path;
|
2024-08-06 17:03:11 +02:00
|
|
|
use gtk::{prelude::*, glib as glib, gio as gio};
|
2024-08-07 01:02:56 +02:00
|
|
|
use crate::{efi_error_page, welcome_page, language_page, eula_page, keyboard_page, timezone_page};
|
2024-01-20 18:48:32 +01:00
|
|
|
|
2024-01-14 22:31:40 +01:00
|
|
|
pub fn build_ui(app: &adw::Application) {
|
2024-08-04 22:56:30 +02:00
|
|
|
glib::set_prgname(Some("pikaos_installer"));
|
2024-02-20 16:11:38 +01:00
|
|
|
glib::set_application_name(&t!("pikaos_installer"));
|
2024-01-14 22:31:40 +01:00
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
let carousel = adw::Carousel::builder()
|
|
|
|
.allow_long_swipes(false)
|
|
|
|
.allow_mouse_drag(false)
|
|
|
|
.allow_scroll_wheel(false)
|
|
|
|
.interactive(false)
|
|
|
|
.vexpand(true)
|
|
|
|
.hexpand(true)
|
2024-01-14 22:31:40 +01:00
|
|
|
.build();
|
2024-02-16 22:21:09 +01:00
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
let carousel_indicator = adw::CarouselIndicatorDots::builder()
|
|
|
|
.carousel(&carousel)
|
|
|
|
.build();
|
2024-01-14 22:31:40 +01:00
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
let window_headerbar = adw::HeaderBar::builder()
|
|
|
|
.show_start_title_buttons(true)
|
|
|
|
.title_widget(&carousel_indicator)
|
2024-01-14 22:31:40 +01:00
|
|
|
.build();
|
2024-02-16 22:21:09 +01:00
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
let toolbarview = adw::ToolbarView::builder()
|
|
|
|
.top_bar_style(adw::ToolbarStyle::Flat)
|
|
|
|
.content(&carousel)
|
2024-01-14 22:31:40 +01:00
|
|
|
.build();
|
2024-02-16 22:21:09 +01:00
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
toolbarview.add_top_bar(&window_headerbar);
|
2024-02-17 14:52:07 +01:00
|
|
|
|
2024-01-14 22:31:40 +01:00
|
|
|
let window = adw::ApplicationWindow::builder()
|
2024-02-20 16:11:38 +01:00
|
|
|
.title(t!("pikaos_installer"))
|
2024-01-14 22:31:40 +01:00
|
|
|
.application(app)
|
2024-01-24 20:17:19 +01:00
|
|
|
.icon_name("calamares")
|
2024-01-14 22:31:40 +01:00
|
|
|
.width_request(700)
|
|
|
|
.height_request(500)
|
2024-08-04 22:56:30 +02:00
|
|
|
.default_width(700)
|
|
|
|
.default_height(500)
|
2024-01-30 15:01:47 +01:00
|
|
|
.deletable(false)
|
2024-08-04 22:56:30 +02:00
|
|
|
.content(&toolbarview)
|
2024-01-14 22:31:40 +01:00
|
|
|
.startup_id("pika-installer-gtk4")
|
|
|
|
.build();
|
2024-02-16 22:21:09 +01:00
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
match Path::new("/sys/firmware/efi/efivars").exists() {
|
2024-08-05 02:25:05 +02:00
|
|
|
true => welcome_page::welcome_page(&window, &carousel),
|
2024-08-04 22:56:30 +02:00
|
|
|
_ => efi_error_page::efi_error_page(&window, &carousel)
|
2024-01-14 22:31:40 +01:00
|
|
|
}
|
2024-08-05 02:25:05 +02:00
|
|
|
|
2024-08-06 17:03:11 +02:00
|
|
|
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
|
|
|
|
|
2024-08-06 18:53:57 +02:00
|
|
|
language_page::language_page(&carousel, &language_changed_action);
|
2024-08-06 18:08:03 +02:00
|
|
|
|
|
|
|
eula_page::eula_page(&carousel, &language_changed_action);
|
2024-02-16 22:21:09 +01:00
|
|
|
|
2024-08-06 22:56:10 +02:00
|
|
|
keyboard_page::keyboard_page(&carousel, &language_changed_action);
|
|
|
|
|
2024-08-07 01:02:56 +02:00
|
|
|
timezone_page::timezone_page(&carousel, &language_changed_action);
|
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
window.present()
|
|
|
|
}
|