Add more rows

This commit is contained in:
Ward from fusion-voyager-3 2024-08-22 18:18:26 +03:00
parent d2bc7e6c6b
commit 12ec5055ba
7 changed files with 67 additions and 18 deletions

View File

@ -107,8 +107,9 @@
"install_confirm_detail_partition_method_type_subtitle_manual_luks": "Manual w/ LUKS", "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_type_subtitle_manual": "Manual",
"install_confirm_detail_partition_method_automatic_target_title": "Automatic Partitioning Target Disk", "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_target_fs_title": "Automatic Partitioning Target Disk Filesystem",
"install_confirm_detail_partition_method_automatic_seperation_title": "Seperate /home ?",
"mounted_on_detail": " mounted on ", "mounted_on_detail": " mounted on ",
"install_target_detail": "Install Target:", "install_target_detail": "Install Target:",
"install_confirm_button_label": "Confirm & Install PikaOS" "install_confirm_button_label": "Confirm & Install PikaOS"

View File

@ -1,19 +1,18 @@
use crate::installer_stack_page; use crate::installer_stack_page;
use crate::partitioning_page::get_block_devices; 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::gio;
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local, ffi::gboolean}; use glib::{clone, closure_local, ffi::gboolean};
use gtk::{glib, prelude::*}; use gtk::{glib, prelude::*};
use std::{cell::RefCell, rc::Rc}; 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( pub fn automatic_partitioning_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,
partition_carousel: &adw::Carousel, partition_carousel: &adw::Carousel,
partition_method_type_refcell: &Rc<RefCell<String>>, partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<String>>, partition_method_automatic_target_refcell: &Rc<RefCell<BlockDevice>>,
partition_method_automatic_target_fs_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_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>, partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,
@ -398,6 +397,8 @@ pub fn automatic_partitioning_page(
#[strong] #[strong]
partition_method_automatic_target_refcell, partition_method_automatic_target_refcell,
#[strong] #[strong]
device,
#[strong]
error_labels, error_labels,
#[weak] #[weak]
automatic_partitioning_page, automatic_partitioning_page,
@ -410,7 +411,7 @@ pub fn automatic_partitioning_page(
device.block_size, device.block_size,
); );
partition_method_automatic_disk_nodisk_error_label.set_visible(false); 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 { let default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 {
100000000000.0 100000000000.0
} else if (usable_disk_space * 40.0) / 100.0 < MINIMUM_ROOT_BYTE_SIZE { } 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 (usable_disk_space * 40.0) / 100.0
}; };
advanced_home_part_ratio_selection_slider 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.set_value(default_root_size);
advanced_home_part_ratio_selection_slider.emit_by_name_with_values( advanced_home_part_ratio_selection_slider.emit_by_name_with_values(
"change_value", "change_value",
&[gtk::ScrollType::None.into(), default_root_size.into()], &[gtk::ScrollType::None.into(), default_root_size.into()],
); );
*partition_method_automatic_target_refcell.borrow_mut() = *partition_method_automatic_target_refcell.borrow_mut() =
String::from(&device.block_name); device.clone();
if check_for_errors(&error_labels) { if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true) automatic_partitioning_page.set_next_sensitive(true)
} else { } else {

View File

@ -23,6 +23,7 @@ pub struct PikaKeymap {
pub pretty_name: String pub pretty_name: String
} }
#[derive(Default, Clone, Debug)]
pub struct BlockDevice { pub struct BlockDevice {
pub block_name: String, pub block_name: String,
pub block_size: f64, pub block_size: f64,
@ -114,7 +115,7 @@ pub fn build_ui(app: &adw::Application) {
let keymap_selection_text_refcell: Rc<RefCell<PikaKeymap>> = Rc::new(RefCell::default()); let keymap_selection_text_refcell: Rc<RefCell<PikaKeymap>> = Rc::new(RefCell::default());
let timezone_selection_text_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default()); let timezone_selection_text_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_type_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default()); let partition_method_type_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_automatic_target_refcell: Rc<RefCell<String>> = let partition_method_automatic_target_refcell: Rc<RefCell<BlockDevice>> =
Rc::new(RefCell::default()); Rc::new(RefCell::default());
let partition_method_automatic_target_fs_refcell: Rc<RefCell<String>> = let partition_method_automatic_target_fs_refcell: Rc<RefCell<String>> =
Rc::new(RefCell::default()); Rc::new(RefCell::default());

View File

@ -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 RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource");
//pub const VERSION: &str = env!("CARGO_PKG_VERSION"); //pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const DISTRO_ICON: &str = "pika-logo"; 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;

View File

@ -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 adw::prelude::*;
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{gio, glib}; use gtk::{gio, glib};
@ -12,7 +12,7 @@ pub fn installation_summary_page(
keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>, keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>,
timezone_selection_text_refcell: &Rc<RefCell<String>>, timezone_selection_text_refcell: &Rc<RefCell<String>>,
partition_method_type_refcell: &Rc<RefCell<String>>, partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<String>>, partition_method_automatic_target_refcell: &Rc<RefCell<BlockDevice>>,
partition_method_automatic_target_fs_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_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>, partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,
@ -87,6 +87,10 @@ pub fn installation_summary_page(
partition_method_automatic_target_refcell, partition_method_automatic_target_refcell,
#[strong] #[strong]
partition_method_manual_luks_enabled_refcell, partition_method_manual_luks_enabled_refcell,
#[strong]
partition_method_automatic_seperation_refcell,
#[strong]
partition_method_automatic_ratio_refcell,
move|_, action_arg| move|_, action_arg|
{ {
let action_arg = String::from_utf8_lossy(action_arg.unwrap().data()); 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" { if &*partition_method_type_refcell.borrow().as_str() == "automatic" {
let install_confirm_detail_partition_method_automatic_target = adw::ActionRow::builder() let install_confirm_detail_partition_method_automatic_target = adw::ActionRow::builder()
.title(t!("install_confirm_detail_partition_method_automatic_target_title")) .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(); .build();
install_confirm_detail_partition_method_automatic_target.add_css_class("property"); install_confirm_detail_partition_method_automatic_target.add_css_class("property");
installation_summary_row_viewport_listbox.append(&install_confirm_detail_partition_method_automatic_target); 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"); 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); 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());
} }
} }
} }

View File

@ -1,15 +1,26 @@
use crate::drive_mount_row::DriveMountRow; 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::gio;
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::glib; use gtk::glib;
use std::{cell::RefCell, rc::Rc}; 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)] #[derive(Clone, Debug)]
struct PartitionRow { struct PartitionRow {
widget: adw::ActionRow, widget: adw::ActionRow,

View File

@ -8,7 +8,7 @@ pub fn partitioning_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,
window: adw::ApplicationWindow, window: adw::ApplicationWindow,
partition_method_type_refcell: &Rc<RefCell<String>>, partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_automatic_target_refcell: &Rc<RefCell<String>>, partition_method_automatic_target_refcell: &Rc<RefCell<BlockDevice>>,
partition_method_automatic_target_fs_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_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>, partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,