add EFI Check

This commit is contained in:
Ward from fusion-voyager-3 2024-01-20 20:48:32 +03:00
parent f23f9c25e2
commit 25565f7542
4 changed files with 126 additions and 2 deletions

View File

@ -10,12 +10,15 @@ use gdk::Display;
use gtk::subclass::layout_child; use gtk::subclass::layout_child;
use crate::save_window_size; use crate::save_window_size;
use crate::welcome_page; use crate::welcome_page;
use crate::efi_error_page;
use crate::language_page; use crate::language_page;
use crate::eula_page; use crate::eula_page;
use crate::timezone_page; use crate::timezone_page;
use crate::keyboard_page; use crate::keyboard_page;
use crate::partitioning_page; use crate::partitioning_page;
use std::path::Path;
// build ui function linked to app startup above // build ui function linked to app startup above
pub fn build_ui(app: &adw::Application) { pub fn build_ui(app: &adw::Application) {
@ -89,7 +92,11 @@ pub fn build_ui(app: &adw::Application) {
.build(); .build();
// Add welcome_page.rs as a page for content_stack // Add welcome_page.rs as a page for content_stack
if Path::new("/sys/firmware/efi/efivars").exists() {
welcome_page(&window, &content_stack); welcome_page(&window, &content_stack);
} else {
efi_error_page(&window, &content_stack);
}
// bottom_box moved per page // bottom_box moved per page
// if content_stack visible child becomes NOT content_stack, show the buttom box // if content_stack visible child becomes NOT content_stack, show the buttom box

110
src/efi_error_page.rs Normal file
View File

@ -0,0 +1,110 @@
// Use libraries
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::*;
use adw::prelude::*;
use adw::*;
use glib::*;
use gdk::Display;
use gtk::subclass::layout_child;
pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {
// the header box for the efi_error page
let efi_error_main_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
// the header box for the efi_error page
let efi_error_header_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
.build();
// the header text for the efi_error page
let efi_error_header_text = gtk::Label::builder()
.label("Unsupported boot platform")
.halign(gtk::Align::End)
.hexpand(true)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(5)
.build();
efi_error_header_text.add_css_class("header_sized_text");
// the header icon for the efi_error icon
let efi_error_header_icon = gtk::Image::builder()
.icon_name("emblem-error")
.halign(gtk::Align::Start)
.hexpand(true)
.pixel_size(78)
.margin_top(15)
.margin_bottom(15)
.margin_start(0)
.margin_end(15)
.build();
// make efi_error selection box for choosing installation or live media
let efi_error_selection_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.margin_bottom(15)
.margin_top(15)
.margin_start(15)
.margin_end(15)
.build();
let efi_error_text = gtk::Label::builder()
.vexpand(true)
.hexpand(true)
.label("PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode.")
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build();
efi_error_text.add_css_class("big_error_text");
let kill_me_button = gtk::Button::builder()
.label("Exit")
.vexpand(true)
.hexpand(true)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build();
// / efi_error_selection_box appends
// / efi_error_header_box appends
//// Add the efi_error page header text and icon
efi_error_header_box.append(&efi_error_header_text);
efi_error_header_box.append(&efi_error_header_icon);
// / efi_error_main_box appends
//// Add the efi_error header to efi_error main box
efi_error_main_box.append(&efi_error_header_box);
//// Add the efi_error selection/page content box to efi_error main box
efi_error_main_box.append(&efi_error_selection_box);
// Start Appending widgets to boxes
// / efi_error_selection_box appends
//// add live and install media button to efi_error page selections
efi_error_selection_box.append(&efi_error_text);
efi_error_selection_box.append(&kill_me_button);
// / efi_error_header_box appends
//// Add the efi_error page header text and icon
efi_error_header_box.append(&efi_error_header_text);
efi_error_header_box.append(&efi_error_header_icon);
// / efi_error_main_box appends
//// Add the efi_error header to efi_error main box
efi_error_main_box.append(&efi_error_header_box);
//// Add the efi_error selection/page content box to efi_error main box
efi_error_main_box.append(&efi_error_selection_box);
// / Content stack appends
//// Add the efi_error_main_box as page: efi_error_page, Give it nice title
content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome");
kill_me_button.connect_clicked(clone!(@weak window => move |_| window.close()));
}

View File

@ -13,6 +13,7 @@ mod build_ui;
use crate::build_ui::build_ui; use crate::build_ui::build_ui;
mod save_window_size; mod save_window_size;
mod welcome_page; mod welcome_page;
mod efi_error_page;
mod language_page; mod language_page;
mod eula_page; mod eula_page;
mod timezone_page; mod timezone_page;
@ -20,6 +21,7 @@ mod keyboard_page;
mod partitioning_page; mod partitioning_page;
use crate::save_window_size::save_window_size; use crate::save_window_size::save_window_size;
use crate::welcome_page::welcome_page; use crate::welcome_page::welcome_page;
use crate::efi_error_page::efi_error_page;
use crate::language_page::language_page; use crate::language_page::language_page;
use crate::eula_page::eula_page; use crate::eula_page::eula_page;
use crate::timezone_page::timezone_page; use crate::timezone_page::timezone_page;

View File

@ -3,6 +3,11 @@
color: red; color: red;
} }
.big_error_text {
font-size: 32px;
color: red;
}
.header_sized_text { .header_sized_text {
font-size: 32px; font-size: 32px;
} }