diff --git a/locales/en_US.json b/locales/en_US.json index b0acd44..5ca3a1d 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -107,8 +107,9 @@ "install_confirm_detail_partition_method_type_subtitle_manual_luks": "Manual w/ LUKS", "install_confirm_detail_partition_method_type_subtitle_manual": "Manual", "install_confirm_detail_partition_method_automatic_target_title": "Automatic Partitioning Target Disk", - "install_confirm_detail_partition_method_automatic_target_subtitle": "{DISK} (WILL BE WIPED CLEAN!)", + "install_confirm_detail_partition_method_automatic_target_subtitle": "{DISK_SIZE} {DISK_NAME} (WILL BE WIPED CLEAN!)", "install_confirm_detail_partition_method_automatic_target_fs_title": "Automatic Partitioning Target Disk Filesystem", + "install_confirm_detail_partition_method_automatic_seperation_title": "Seperate /home ?", "mounted_on_detail": " mounted on ", "install_target_detail": "Install Target:", "install_confirm_button_label": "Confirm & Install PikaOS" diff --git a/src/automatic_partitioning_page/mod.rs b/src/automatic_partitioning_page/mod.rs index cc5be24..7fb0bea 100644 --- a/src/automatic_partitioning_page/mod.rs +++ b/src/automatic_partitioning_page/mod.rs @@ -1,19 +1,18 @@ use crate::installer_stack_page; use crate::partitioning_page::get_block_devices; +use crate::config::{MINIMUM_EFI_BYTE_SIZE, MINIMUM_BOOT_BYTE_SIZE, MINIMUM_ROOT_BYTE_SIZE}; +use crate::build_ui::BlockDevice; use adw::gio; use adw::prelude::*; use glib::{clone, closure_local, ffi::gboolean}; use gtk::{glib, prelude::*}; use std::{cell::RefCell, rc::Rc}; -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>, - partition_method_automatic_target_refcell: &Rc>, + partition_method_automatic_target_refcell: &Rc>, partition_method_automatic_target_fs_refcell: &Rc>, partition_method_automatic_luks_enabled_refcell: &Rc>, partition_method_automatic_luks_refcell: &Rc>, @@ -398,6 +397,8 @@ pub fn automatic_partitioning_page( #[strong] partition_method_automatic_target_refcell, #[strong] + device, + #[strong] error_labels, #[weak] automatic_partitioning_page, @@ -410,7 +411,7 @@ pub fn automatic_partitioning_page( device.block_size, ); partition_method_automatic_disk_nodisk_error_label.set_visible(false); - let usable_disk_space = device.block_size - BOOT_AND_EFI_BYTE_SIZE; + let usable_disk_space = device.block_size - (MINIMUM_EFI_BYTE_SIZE + MINIMUM_BOOT_BYTE_SIZE); let default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 { 100000000000.0 } else if (usable_disk_space * 40.0) / 100.0 < MINIMUM_ROOT_BYTE_SIZE { @@ -419,14 +420,14 @@ pub fn automatic_partitioning_page( (usable_disk_space * 40.0) / 100.0 }; advanced_home_part_ratio_selection_slider - .set_range(MINIMUM_ROOT_BYTE_SIZE, device.block_size - 10000000000.0); + .set_range(MINIMUM_ROOT_BYTE_SIZE, usable_disk_space - 10000000000.0); advanced_home_part_ratio_selection_slider.set_value(default_root_size); advanced_home_part_ratio_selection_slider.emit_by_name_with_values( "change_value", &[gtk::ScrollType::None.into(), default_root_size.into()], ); *partition_method_automatic_target_refcell.borrow_mut() = - String::from(&device.block_name); + device.clone(); if check_for_errors(&error_labels) { automatic_partitioning_page.set_next_sensitive(true) } else { diff --git a/src/build_ui.rs b/src/build_ui.rs index 7fac5a6..5ec093a 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -23,6 +23,7 @@ pub struct PikaKeymap { pub pretty_name: String } +#[derive(Default, Clone, Debug)] pub struct BlockDevice { pub block_name: String, pub block_size: f64, @@ -114,7 +115,7 @@ pub fn build_ui(app: &adw::Application) { let keymap_selection_text_refcell: Rc> = Rc::new(RefCell::default()); let timezone_selection_text_refcell: Rc> = Rc::new(RefCell::default()); let partition_method_type_refcell: Rc> = Rc::new(RefCell::default()); - let partition_method_automatic_target_refcell: Rc> = + let partition_method_automatic_target_refcell: Rc> = Rc::new(RefCell::default()); let partition_method_automatic_target_fs_refcell: Rc> = Rc::new(RefCell::default()); diff --git a/src/config.rs b/src/config.rs index c9a4897..3108762 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,3 +5,6 @@ pub const APP_ID: &str = "com.github.pikaos-linux.pikainstallergtk4"; //pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); //pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const DISTRO_ICON: &str = "pika-logo"; +pub const MINIMUM_EFI_BYTE_SIZE: f64 = 500000000.0; +pub const MINIMUM_BOOT_BYTE_SIZE: f64 = 1000000000.0; +pub const MINIMUM_ROOT_BYTE_SIZE: f64 = 39000000000.0; \ No newline at end of file diff --git a/src/installation_summary_page/mod.rs b/src/installation_summary_page/mod.rs index 8c795be..cdf7759 100644 --- a/src/installation_summary_page/mod.rs +++ b/src/installation_summary_page/mod.rs @@ -1,4 +1,4 @@ -use crate::{build_ui::{PikaLocale, PikaKeymap, FstabEntry, CrypttabEntry}, installer_stack_page}; +use crate::{build_ui::{PikaLocale, PikaKeymap, FstabEntry, CrypttabEntry, BlockDevice}, installer_stack_page}; use adw::prelude::*; use glib::{clone, closure_local}; use gtk::{gio, glib}; @@ -12,7 +12,7 @@ pub fn installation_summary_page( keymap_selection_text_refcell: &Rc>, timezone_selection_text_refcell: &Rc>, partition_method_type_refcell: &Rc>, - partition_method_automatic_target_refcell: &Rc>, + partition_method_automatic_target_refcell: &Rc>, partition_method_automatic_target_fs_refcell: &Rc>, partition_method_automatic_luks_enabled_refcell: &Rc>, partition_method_automatic_luks_refcell: &Rc>, @@ -87,6 +87,10 @@ pub fn installation_summary_page( partition_method_automatic_target_refcell, #[strong] partition_method_manual_luks_enabled_refcell, + #[strong] + partition_method_automatic_seperation_refcell, + #[strong] + partition_method_automatic_ratio_refcell, move|_, action_arg| { let action_arg = String::from_utf8_lossy(action_arg.unwrap().data()); @@ -146,7 +150,7 @@ pub fn installation_summary_page( if &*partition_method_type_refcell.borrow().as_str() == "automatic" { let install_confirm_detail_partition_method_automatic_target = adw::ActionRow::builder() .title(t!("install_confirm_detail_partition_method_automatic_target_title")) - .subtitle(strfmt::strfmt(&t!("install_confirm_detail_partition_method_automatic_target_subtitle"), &std::collections::HashMap::from([("DISK".to_string(), partition_method_automatic_target_refcell.borrow().as_str())])).unwrap()) + .subtitle(strfmt::strfmt(&t!("install_confirm_detail_partition_method_automatic_target_subtitle"), &std::collections::HashMap::from([("DISK_SIZE".to_string(), partition_method_automatic_target_refcell.borrow().block_size_pretty.as_str()), ("DISK_NAME".to_string(), partition_method_automatic_target_refcell.borrow().block_name.as_str())])).unwrap()) .build(); install_confirm_detail_partition_method_automatic_target.add_css_class("property"); installation_summary_row_viewport_listbox.append(&install_confirm_detail_partition_method_automatic_target); @@ -158,6 +162,34 @@ pub fn installation_summary_page( install_confirm_detail_partition_method_automatic_target_fs.add_css_class("property"); installation_summary_row_viewport_listbox.append(&install_confirm_detail_partition_method_automatic_target_fs); // + match &*partition_method_automatic_seperation_refcell.borrow().as_str() { + "subvol" => { + let install_confirm_detail_partition_method_automatic_seperation = adw::ActionRow::builder() + .title(t!("install_confirm_detail_partition_method_automatic_seperation_title")) + .subtitle(t!("advanced_home_seperation_selection_checkbutton_partition_label")) + .build(); + install_confirm_detail_partition_method_automatic_seperation.add_css_class("property"); + installation_summary_row_viewport_listbox.append(&install_confirm_detail_partition_method_automatic_seperation); + } + "partition" => { + let install_confirm_detail_partition_method_automatic_seperation = adw::ActionRow::builder() + .title(t!("install_confirm_detail_partition_method_automatic_seperation_title")) + .subtitle(t!("advanced_home_seperation_selection_checkbutton_partition_label")) + .build(); + install_confirm_detail_partition_method_automatic_seperation.add_css_class("property"); + installation_summary_row_viewport_listbox.append(&install_confirm_detail_partition_method_automatic_seperation); + } + "none" => { + let install_confirm_detail_partition_method_automatic_seperation = adw::ActionRow::builder() + .title(t!("install_confirm_detail_partition_method_automatic_seperation_title")) + .subtitle(t!("advanced_home_seperation_selection_checkbutton_none_label")) + .build(); + install_confirm_detail_partition_method_automatic_seperation.add_css_class("property"); + installation_summary_row_viewport_listbox.append(&install_confirm_detail_partition_method_automatic_seperation); + } + _ => panic!() + } + println!("{}", partition_method_automatic_ratio_refcell.borrow()); } } } diff --git a/src/manual_partitioning_page/func.rs b/src/manual_partitioning_page/func.rs index 55083e0..e2bb004 100644 --- a/src/manual_partitioning_page/func.rs +++ b/src/manual_partitioning_page/func.rs @@ -1,15 +1,26 @@ use crate::drive_mount_row::DriveMountRow; -use crate::{build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}, partitioning_page::{get_partitions}}; +use crate::{ + build_ui::{ + CrypttabEntry, + FstabEntry, + Partition, + SubvolDeclaration + }, + partitioning_page::{ + get_partitions + }, + config::{ + MINIMUM_EFI_BYTE_SIZE, + MINIMUM_BOOT_BYTE_SIZE, + MINIMUM_ROOT_BYTE_SIZE, + } +}; use adw::gio; use adw::prelude::*; use glib::{clone, closure_local}; use gtk::glib; use std::{cell::RefCell, rc::Rc}; -const MINIMUM_EFI_BYTE_SIZE: f64 = 500000000.0; -const MINIMUM_BOOT_BYTE_SIZE: f64 = 1000000000.0; -const MINIMUM_ROOT_BYTE_SIZE: f64 = 39000000000.0; - #[derive(Clone, Debug)] struct PartitionRow { widget: adw::ActionRow, diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 509b91f..49dea86 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -8,7 +8,7 @@ pub fn partitioning_page( main_carousel: &adw::Carousel, window: adw::ApplicationWindow, partition_method_type_refcell: &Rc>, - partition_method_automatic_target_refcell: &Rc>, + partition_method_automatic_target_refcell: &Rc>, partition_method_automatic_target_fs_refcell: &Rc>, partition_method_automatic_luks_enabled_refcell: &Rc>, partition_method_automatic_luks_refcell: &Rc>,