2024-08-19 01:12:35 +02:00
|
|
|
use crate::{
|
2024-08-23 00:02:58 +02:00
|
|
|
config::APP_ID, efi_error_page, eula_page, installation_progress_page,
|
|
|
|
installation_summary_page, keyboard_page, language_page, partitioning_page, timezone_page,
|
|
|
|
welcome_page,
|
2024-08-19 01:12:35 +02:00
|
|
|
};
|
|
|
|
use gtk::{gio, glib, prelude::*};
|
|
|
|
use std::{cell::RefCell, path::Path, rc::Rc};
|
2024-01-20 18:48:32 +01:00
|
|
|
|
2024-08-21 23:41:06 +02:00
|
|
|
// Custom Installer Data types
|
|
|
|
|
|
|
|
/// Locale Data types
|
|
|
|
|
2024-08-21 23:06:34 +02:00
|
|
|
#[derive(Default, Clone, Debug)]
|
|
|
|
pub struct PikaLocale {
|
|
|
|
pub name: String,
|
2024-08-23 00:02:58 +02:00
|
|
|
pub pretty_name: String,
|
2024-08-21 23:06:34 +02:00
|
|
|
}
|
|
|
|
|
2024-08-21 23:41:06 +02:00
|
|
|
/// Keyboard Data types
|
|
|
|
|
2024-08-21 23:06:34 +02:00
|
|
|
#[derive(Default, Clone, Debug)]
|
|
|
|
pub struct PikaKeymap {
|
|
|
|
pub name: String,
|
|
|
|
pub variant: Option<String>,
|
2024-08-23 00:02:58 +02:00
|
|
|
pub pretty_name: String,
|
2024-08-21 23:06:34 +02:00
|
|
|
}
|
|
|
|
|
2024-08-22 17:18:26 +02:00
|
|
|
#[derive(Default, Clone, Debug)]
|
2024-08-21 23:41:06 +02:00
|
|
|
pub struct BlockDevice {
|
|
|
|
pub block_name: String,
|
|
|
|
pub block_size: f64,
|
|
|
|
pub block_size_pretty: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Partitioning Data types
|
|
|
|
|
|
|
|
#[derive(Default, Clone, Debug)]
|
|
|
|
pub struct Partition {
|
|
|
|
pub part_name: String,
|
|
|
|
pub part_fs: String,
|
|
|
|
pub part_uuid: String,
|
|
|
|
pub has_encryption: bool,
|
|
|
|
pub need_mapper: bool,
|
|
|
|
pub part_size: f64,
|
|
|
|
pub part_size_pretty: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default, Clone, Debug)]
|
|
|
|
pub struct FstabEntry {
|
|
|
|
pub partition: Partition,
|
|
|
|
pub mountpoint: String,
|
|
|
|
pub mountopts: String,
|
|
|
|
pub used_by: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default, Clone, Debug)]
|
|
|
|
pub struct CrypttabEntry {
|
|
|
|
pub partition: String,
|
|
|
|
pub map: String,
|
|
|
|
pub uuid: String,
|
|
|
|
pub password: Option<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct SubvolDeclaration {
|
|
|
|
pub part_name: Rc<std::cell::RefCell<String>>,
|
|
|
|
pub made_by: Rc<std::cell::RefCell<i32>>,
|
|
|
|
}
|
|
|
|
|
2024-01-14 22:31:40 +01:00
|
|
|
pub fn build_ui(app: &adw::Application) {
|
2024-08-21 23:29:39 +02:00
|
|
|
glib::set_prgname(Some(t!("application_name").to_string()));
|
2024-08-19 01:50:56 +02:00
|
|
|
glib::set_application_name(&t!("application_name"));
|
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-08-19 01:50:56 +02:00
|
|
|
.title(t!("application_name"))
|
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-08-21 23:29:39 +02:00
|
|
|
.startup_id(APP_ID)
|
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
|
|
|
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-19 01:12:35 +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-21 23:06:34 +02:00
|
|
|
let language_selection_text_refcell: Rc<RefCell<PikaLocale>> = Rc::new(RefCell::default());
|
|
|
|
let keymap_selection_text_refcell: Rc<RefCell<PikaKeymap>> = Rc::new(RefCell::default());
|
2024-08-15 20:07:01 +02:00
|
|
|
let timezone_selection_text_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
|
|
|
|
let partition_method_type_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
|
2024-08-22 17:18:26 +02:00
|
|
|
let partition_method_automatic_target_refcell: Rc<RefCell<BlockDevice>> =
|
2024-08-19 01:12:35 +02:00
|
|
|
Rc::new(RefCell::default());
|
|
|
|
let partition_method_automatic_target_fs_refcell: Rc<RefCell<String>> =
|
|
|
|
Rc::new(RefCell::default());
|
|
|
|
let partition_method_automatic_luks_enabled_refcell: Rc<RefCell<bool>> =
|
|
|
|
Rc::new(RefCell::new(false));
|
2024-08-15 20:07:01 +02:00
|
|
|
let partition_method_automatic_luks_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
|
2024-08-16 06:18:37 +02:00
|
|
|
let partition_method_automatic_ratio_refcell: Rc<RefCell<f64>> = Rc::new(RefCell::new(0.0));
|
2024-08-19 01:12:35 +02:00
|
|
|
let partition_method_automatic_seperation_refcell: Rc<RefCell<String>> =
|
|
|
|
Rc::new(RefCell::default());
|
|
|
|
let partition_method_manual_fstab_entry_array_refcell: Rc<RefCell<Vec<FstabEntry>>> =
|
|
|
|
Rc::new(RefCell::new(Vec::new()));
|
|
|
|
let partition_method_manual_luks_enabled_refcell: Rc<RefCell<bool>> =
|
|
|
|
Rc::new(RefCell::new(false));
|
|
|
|
let partition_method_manual_crypttab_entry_array_refcell: Rc<RefCell<Vec<CrypttabEntry>>> =
|
|
|
|
Rc::new(RefCell::new(Vec::new()));
|
2024-08-13 23:13:09 +02:00
|
|
|
|
2024-08-06 17:03:11 +02:00
|
|
|
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
|
2024-08-22 09:06:22 +02:00
|
|
|
let page_done_action = gio::SimpleAction::new("lang-changed", Some(glib::VariantTy::STRING));
|
2024-08-06 17:03:11 +02:00
|
|
|
|
2024-08-19 01:12:35 +02:00
|
|
|
language_page::language_page(
|
|
|
|
&carousel,
|
|
|
|
&language_selection_text_refcell,
|
|
|
|
&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-19 01:12:35 +02:00
|
|
|
keyboard_page::keyboard_page(
|
|
|
|
&carousel,
|
2024-08-21 23:06:34 +02:00
|
|
|
&keymap_selection_text_refcell,
|
2024-08-19 01:12:35 +02:00
|
|
|
&language_changed_action,
|
|
|
|
);
|
2024-08-06 22:56:10 +02:00
|
|
|
|
2024-08-19 01:12:35 +02:00
|
|
|
timezone_page::timezone_page(
|
|
|
|
&carousel,
|
|
|
|
&timezone_selection_text_refcell,
|
|
|
|
&language_changed_action,
|
|
|
|
);
|
2024-08-07 01:02:56 +02:00
|
|
|
|
2024-08-15 01:03:18 +02:00
|
|
|
partitioning_page::partitioning_page(
|
2024-08-19 01:12:35 +02:00
|
|
|
&carousel,
|
2024-08-19 22:42:36 +02:00
|
|
|
window.clone(),
|
2024-08-19 01:12:35 +02:00
|
|
|
&partition_method_type_refcell,
|
|
|
|
&partition_method_automatic_target_refcell,
|
|
|
|
&partition_method_automatic_target_fs_refcell,
|
|
|
|
&partition_method_automatic_luks_enabled_refcell,
|
|
|
|
&partition_method_automatic_luks_refcell,
|
|
|
|
&partition_method_automatic_ratio_refcell,
|
|
|
|
&partition_method_automatic_seperation_refcell,
|
|
|
|
&partition_method_manual_fstab_entry_array_refcell,
|
|
|
|
&partition_method_manual_luks_enabled_refcell,
|
|
|
|
&partition_method_manual_crypttab_entry_array_refcell,
|
|
|
|
&language_changed_action,
|
2024-08-22 09:06:22 +02:00
|
|
|
&page_done_action,
|
2024-08-19 01:12:35 +02:00
|
|
|
);
|
2024-08-07 01:27:24 +02:00
|
|
|
|
2024-08-23 00:02:58 +02:00
|
|
|
installation_summary_page::installation_summary_page(
|
|
|
|
&carousel,
|
|
|
|
&language_changed_action,
|
|
|
|
&page_done_action,
|
|
|
|
&language_selection_text_refcell,
|
|
|
|
&keymap_selection_text_refcell,
|
|
|
|
&timezone_selection_text_refcell,
|
|
|
|
&partition_method_type_refcell,
|
|
|
|
&partition_method_automatic_target_refcell,
|
|
|
|
&partition_method_automatic_target_fs_refcell,
|
|
|
|
&partition_method_automatic_luks_enabled_refcell,
|
|
|
|
&partition_method_automatic_luks_refcell,
|
|
|
|
&partition_method_automatic_ratio_refcell,
|
|
|
|
&partition_method_automatic_seperation_refcell,
|
|
|
|
&partition_method_manual_fstab_entry_array_refcell,
|
|
|
|
&partition_method_manual_luks_enabled_refcell,
|
|
|
|
&partition_method_manual_crypttab_entry_array_refcell,
|
|
|
|
);
|
|
|
|
|
2024-08-04 22:56:30 +02:00
|
|
|
window.present()
|
2024-08-19 01:12:35 +02:00
|
|
|
}
|