This commit is contained in:
Ward from fusion-voyager-3 2024-08-22 02:39:16 +03:00
parent 2918d5269f
commit c256d2e456
6 changed files with 74 additions and 224 deletions

View File

@ -21,19 +21,12 @@
"no_locale_selected": "No Locale Selected",
"language": "Language",
"keyboard_page_subtitle": "Select a keyboard",
"please_select_keyboard": "Please select a Keyboard layout for the system to use",
"no_keyboard_selected": "No Keyboard Layout selected",
"keyboard_test_entry_title": "Test Your Keyboard here!",
"please_select_keyboard": "Please Select a Keyboard layout for The System to Yse",
"no_keyboard_selected": "No Keyboard Layout Selected",
"keyboard_test_entry_title": "Test Your Keyboard Here!",
"keyboard_page_title": "Keyboard",
"crypttab_dialog_response_crypttab_dialog_boot": "Unlock on Boot Manually",
"crypttab_dialog_response_crypttab_dialog_auto": "Unlock Automatically with Root Unlock",
"sit_back_relax": "Sit back, Relax, and watch the show.",
"language_detail": "Language:",
"timezone_detail": "Timezone:",
"keyboard_detail": "Keyboard layout:",
"mounted_on_detail": " mounted on ",
"install_target_detail": "Install Target:",
"confirm_install_pika": "Confirm & Install PikaOS",
"view_logs": "View Logs",
"parting_status_text": "Partitioning The Target Drives.",
"image_status_text": "Writing Image to target.",
@ -100,6 +93,13 @@
"partition_method_manual_mountpoint_empty_error_label_label": "Filesystem Table Error: One or More Partitions Don't Have a Mountpoint configured!",
"partition_method_manual_partition_empty_error_label_label": "Filesystem Table Error: One or More Entries Don't Have a Partition configured!",
"partition_method_manual_mountpoint_invalid_error_label_label": "Filesystem Table Error: One or More Entries Are Configured to an Invalid Mountpoint!",
"partition_method_manual_valid_label_label": "Filesystem Table is Valid!"
"partition_method_manual_valid_label_label": "Filesystem Table is Valid!",
"installation_summary_page_title": "Installation Summary",
"installation_summary_page_subtitle": "Please Double Check and Confirm That This Configuration is Satisfactory",
"language_detail": "Language:",
"timezone_detail": "Timezone:",
"keyboard_detail": "Keyboard layout:",
"mounted_on_detail": " mounted on ",
"install_target_detail": "Install Target:",
"install_confirm_button_label": "Confirm & Install PikaOS"
}

View File

@ -10,6 +10,7 @@ const BOOT_AND_EFI_BYTE_SIZE: f64 = 1611661312.0;
const MINIMUM_ROOT_BYTE_SIZE: f64 = 39000000000.0;
pub fn automatic_partitioning_page(
main_carousel: &adw::Carousel,
partition_carousel: &adw::Carousel,
partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<String>>,
@ -596,7 +597,7 @@ pub fn automatic_partitioning_page(
false,
closure_local!(
#[weak]
partition_carousel,
main_carousel,
#[strong]
partition_method_type_refcell,
#[strong]
@ -613,14 +614,7 @@ pub fn automatic_partitioning_page(
partition_method_automatic_seperation_refcell,
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage| {
*partition_method_type_refcell.borrow_mut() = String::from("automatic");
//partition_carousel.scroll_to(&partition_carousel.nth_page(5), true)
dbg!(partition_method_type_refcell.borrow());
dbg!(partition_method_automatic_target_fs_refcell.borrow());
dbg!(partition_method_automatic_target_refcell.borrow());
dbg!(partition_method_automatic_luks_enabled_refcell.borrow());
dbg!(partition_method_automatic_luks_refcell.borrow());
dbg!(partition_method_automatic_ratio_refcell.borrow());
dbg!(partition_method_automatic_seperation_refcell.borrow());
main_carousel.scroll_to(&main_carousel.nth_page(6), true)
}
),
);

View File

@ -1,5 +1,5 @@
use crate::{
config::APP_ID, efi_error_page, eula_page, keyboard_page, language_page, timezone_page, welcome_page, partitioning_page
config::APP_ID, efi_error_page, eula_page, keyboard_page, language_page, timezone_page, welcome_page, partitioning_page, installation_summary_page
};
use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, path::Path, rc::Rc};
@ -169,5 +169,7 @@ pub fn build_ui(app: &adw::Application) {
&language_changed_action,
);
installation_summary_page::installation_summary_page(&carousel, &language_changed_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);
window.present()
}

View File

@ -1,32 +1,32 @@
use crate::{build_ui::{PikaLocale, PikaKeymap, FstabEntry, CrypttabEntry} installer_stack_page};
use crate::{build_ui::{PikaLocale, PikaKeymap, FstabEntry, CrypttabEntry}, installer_stack_page};
use adw::prelude::*;
use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, fs, path::Path, process::Command, rc::Rc};
pub fn keyboard_page(
pub fn installation_summary_page(
main_carousel: &adw::Carousel,
language_changed_action: &gio::SimpleAction,
language_selection_text_refcell: Rc<RefCell<PikaLocale>>,
keymap_selection_text_refcell: Rc<RefCell<PikaKeymap>>,
timezone_selection_text_refcell: Rc<RefCell<String>>,
partition_method_type_refcell: Rc<RefCell<String>>,
partition_method_automatic_target_refcell: Rc<RefCell<String>>,
partition_method_automatic_target_fs_refcell: Rc<RefCell<String>>,
partition_method_automatic_luks_enabled_refcell: Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: Rc<RefCell<String>>,
partition_method_automatic_ratio_refcell: Rc<RefCell<f64>>,
partition_method_automatic_seperation_refcell: Rc<RefCell<String>>,
partition_method_manual_fstab_entry_array_refcell: Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: Rc<RefCell<Vec<CrypttabEntry>>>
installation_summary_text_refcell: &Rc<RefCell<PikaLocale>>,
keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>,
timezone_selection_text_refcell: &Rc<RefCell<String>>,
partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_fs_refcell: &Rc<RefCell<String>>,
partition_method_automatic_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,
partition_method_automatic_ratio_refcell: &Rc<RefCell<f64>>,
partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>,
partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>
) {
let keyboard_page = installer_stack_page::InstallerStackPage::new();
keyboard_page.set_page_icon("keyboard-symbolic");
keyboard_page.set_back_visible(true);
keyboard_page.set_next_visible(true);
keyboard_page.set_back_sensitive(true);
keyboard_page.set_next_sensitive(false);
let installation_summary_page = installer_stack_page::InstallerStackPage::new();
installation_summary_page.set_page_icon("dialog-warning-symbolic");
installation_summary_page.set_back_sensitive(true);
installation_summary_page.set_next_sensitive(false);
installation_summary_page.set_back_visible(true);
installation_summary_page.set_next_visible(true);
let content_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
@ -34,211 +34,65 @@ pub fn keyboard_page(
.vexpand(true)
.build();
let null_checkbutton = gtk::CheckButton::builder().build();
let keyboard_selection_row_viewport_listbox = gtk::ListBox::builder()
let installation_summary_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
.build();
keyboard_selection_row_viewport_listbox.add_css_class("boxed-list");
keyboard_selection_row_viewport_listbox.add_css_class("round-border-only");
installation_summary_row_viewport_listbox.add_css_class("boxed-list");
installation_summary_row_viewport_listbox.add_css_class("round-all-scroll");
let keyboard_selection_row_viewport = gtk::ScrolledWindow::builder()
let installation_summary_row_viewport = gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.has_frame(true)
.child(&keyboard_selection_row_viewport_listbox)
.child(&installation_summary_row_viewport_listbox)
.build();
keyboard_selection_row_viewport.add_css_class("round-border-only-top-with-padding");
installation_summary_row_viewport.add_css_class("round-all-scroll");
let keyboard_search_bar = gtk::SearchEntry::builder()
.hexpand(true)
.margin_top(15)
.margin_bottom(15)
.search_delay(500)
let install_confirm_button = gtk::Button::builder()
.margin_top(15)
.margin_bottom(15)
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.build();
keyboard_search_bar.add_css_class("rounded-all-25");
let keyboard_test_entry_boxed_list = gtk::ListBox::builder()
.margin_top(5)
.margin_bottom(5)
.build();
keyboard_test_entry_boxed_list.add_css_class("boxed-list");
let keyboard_test_entry = adw::EntryRow::builder().build();
keyboard_test_entry_boxed_list.append(&keyboard_test_entry);
keyboard_test_entry_boxed_list.add_css_class("round-border-only-bottom");
let current_keymap = "us";
let xkbinfo = gnome_desktop::XkbInfo::new();
let keymap_list = gnome_desktop::XkbInfo::all_layouts(&xkbinfo);
let mut sorted_keymap_vec = Vec::new();
for keymap in keymap_list.iter() {
sorted_keymap_vec.push(PikaKeymap{
name: keymap.to_string(),
pretty_name: xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string()
})
}
sorted_keymap_vec.sort_by_key(|k| k.pretty_name.clone());
for pika_keymap in sorted_keymap_vec {
let keymap = pika_keymap.name;
let keymap_name = pika_keymap.pretty_name;
let keymap_split: Vec<String> = keymap.split("+").map(|s| s.into()).collect();
let keymap_base = keymap_split.get(0).unwrap().clone();
let mut keymap_variant = String::new();
let mut split_index = 0;
for split in keymap_split {
split_index += 1;
if split_index == 1 {
continue;
}
keymap_variant.push_str(&split)
}
let keymap_clone = keymap.clone();
let keymap_checkbutton = gtk::CheckButton::builder()
.valign(gtk::Align::Center)
.can_focus(false)
.build();
let keymap_row = adw::ActionRow::builder()
.activatable_widget(&keymap_checkbutton)
.title(keymap_name)
.subtitle(keymap.clone())
.build();
keymap_row.add_prefix(&keymap_checkbutton);
keymap_checkbutton.set_group(Some(&null_checkbutton));
keyboard_selection_row_viewport_listbox.append(&keymap_row);
keymap_checkbutton.connect_toggled(clone!(
#[weak]
keymap_checkbutton,
#[strong]
keymap_base_data_refcell,
#[strong]
keymap_variant_data_refcell,
#[weak]
keyboard_page,
move |_| {
if keymap_checkbutton.is_active() == true {
keyboard_page.set_next_sensitive(true);
if keymap_variant.is_empty() {
*keymap_base_data_refcell.borrow_mut() = String::from(&keymap_base);
Command::new("setxkbmap")
.arg("-layout")
.arg(keymap_base.clone())
.spawn()
.expect("keyboard failed to start");
} else {
*keymap_base_data_refcell.borrow_mut() = String::from(&keymap_base);
*keymap_variant_data_refcell.borrow_mut() = String::from(&keymap_variant);
Command::new("setxkbmap")
.arg("-layout")
.arg(keymap_base.clone())
.arg("-variant")
.arg(keymap_variant.clone())
.spawn()
.expect("keyboard failed to start");
}
}
}
));
if current_keymap == keymap_clone {
keymap_checkbutton.set_active(true);
}
}
install_confirm_button.add_css_class("destructive-action");
install_confirm_button.add_css_class("circular");
// / content_box appends
//// add text and and entry to keyboard page selections
content_box.append(&keyboard_search_bar);
content_box.append(&keyboard_selection_row_viewport);
content_box.append(&keyboard_test_entry_boxed_list);
//// add text and and entry to installation_summary page selections
content_box.append(&installation_summary_row_viewport_listbox);
content_box.append(&install_confirm_button);
keyboard_search_bar.connect_search_changed(clone!(
#[weak]
keyboard_search_bar,
#[weak]
keyboard_selection_row_viewport_listbox,
move |_| {
let mut counter = keyboard_selection_row_viewport_listbox.first_child();
while let Some(row) = counter {
if row.widget_name() == "AdwActionRow" {
if !keyboard_search_bar.text().is_empty() {
if row
.property::<String>("subtitle")
.to_lowercase()
.contains(&keyboard_search_bar.text().to_string().to_lowercase())
|| row
.property::<String>("title")
.to_lowercase()
.contains(&keyboard_search_bar.text().to_string().to_lowercase())
{
row.set_property("visible", true);
keyboard_search_bar.grab_focus();
} else {
row.set_property("visible", false);
}
} else {
row.set_property("visible", true);
}
}
counter = row.next_sibling();
}
}
));
keyboard_page.set_child_widget(&content_box);
installation_summary_page.set_child_widget(&content_box);
//
language_changed_action.connect_activate(clone!(
#[weak]
keyboard_page,
installation_summary_page,
#[weak]
keyboard_search_bar,
#[weak]
keyboard_test_entry,
install_confirm_button,
move |_, _| {
keyboard_page.set_page_title(t!("keyboard_page_title"));
keyboard_page.set_page_subtitle(t!("keyboard_page_subtitle"));
keyboard_page.set_back_tooltip_label(t!("back"));
keyboard_page.set_next_tooltip_label(t!("next"));
installation_summary_page.set_page_title(t!("installation_summary_page_title"));
installation_summary_page.set_page_subtitle(t!("installation_summary_page_subtitle"));
installation_summary_page.set_back_tooltip_label(t!("back"));
installation_summary_page.set_next_tooltip_label(t!("next"));
//
keyboard_search_bar
.set_placeholder_text(Some(&t!("keyboard_search_bar_placeholder_text")));
//
keyboard_test_entry.set_title(&t!("keyboard_test_entry_title"))
install_confirm_button.set_label(&t!("install_confirm_button_label"));
}
));
//
keyboard_page.connect_closure(
installation_summary_page.connect_closure(
"back-button-pressed",
false,
closure_local!(
#[weak]
main_carousel,
move |_keyboard_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(2), true)
move |_installation_summary_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(5), true)
}
),
);
keyboard_page.connect_closure(
"next-button-pressed",
false,
closure_local!(
#[weak]
main_carousel,
move |_keyboard_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(4), true)
}
),
);
main_carousel.append(&keyboard_page);
main_carousel.append(&installation_summary_page);
}

View File

@ -11,6 +11,7 @@ use std::sync::atomic::AtomicBool;
mod func;
pub fn manual_partitioning_page(
main_carousel: &adw::Carousel,
partition_carousel: &adw::Carousel,
window: adw::ApplicationWindow,
partition_method_type_refcell: &Rc<RefCell<String>>,
@ -358,7 +359,7 @@ pub fn manual_partitioning_page(
false,
closure_local!(
#[weak]
partition_carousel,
main_carousel,
#[strong]
partition_method_type_refcell,
#[strong]
@ -369,11 +370,7 @@ pub fn manual_partitioning_page(
partition_method_manual_crypttab_entry_array_refcell,
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage| {
*partition_method_type_refcell.borrow_mut() = String::from("manual");
//partition_carousel.scroll_to(&partition_carousel.nth_page(5), true)
dbg!(partition_method_type_refcell.borrow());
dbg!(partition_method_manual_fstab_entry_array_refcell.borrow());
dbg!(partition_method_manual_luks_enabled_refcell.borrow());
dbg!(partition_method_manual_crypttab_entry_array_refcell.borrow());
main_carousel.scroll_to(&main_carousel.nth_page(6), true)
}
),
);

View File

@ -22,8 +22,9 @@ pub fn partitioning_page(
let partitioning_page = installer_stack_page::InstallerStackPage::new();
partitioning_page.set_page_icon("media-floppy-symbolic");
partitioning_page.set_back_sensitive(true);
partitioning_page.set_next_sensitive(false);
partitioning_page.set_back_visible(true);
partitioning_page.set_next_visible(false);
partitioning_page.set_next_visible(true);
let partitioning_carousel = adw::Carousel::builder()
.allow_long_swipes(false)
@ -132,6 +133,7 @@ pub fn partitioning_page(
partitioning_carousel.append(&partitioning_page);
automatic_partitioning_page::automatic_partitioning_page(
&main_carousel,
&partitioning_carousel,
&partition_method_type_refcell,
&partition_method_automatic_target_refcell,
@ -143,6 +145,7 @@ pub fn partitioning_page(
&language_changed_action,
);
manual_partitioning_page::manual_partitioning_page(
&main_carousel,
&partitioning_carousel,
window,
&partition_method_type_refcell,