Begin working in root and home ratio selector

This commit is contained in:
Ward from fusion-voyager-3 2024-08-16 01:33:40 +03:00
parent ede15c0d54
commit 44334bb034

View File

@ -6,6 +6,9 @@ use adw::{prelude::*};
use glib::{clone, closure_local};
use std::{rc::Rc, cell::RefCell};
const BOOT_AND_EFI_BYTE_SIZE: f64 = 1611661312.0;
const MINIMUM_ROOT_BYTE_SIZE: f64 = 40000000000.0;
pub fn automatic_partitioning_page(
main_carousel: &adw::Carousel,
partition_method_type_refcell: &Rc<RefCell<String>>,
@ -45,6 +48,158 @@ pub fn automatic_partitioning_page(
//
// Advanced
let advanced_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
let advanced_box_viewport =
gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.child(&advanced_box)
.build();
//
let advanced_home_part_ratio_selection_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.homogeneous(true)
.build();
let advanced_home_part_ratio_selection_frame = gtk::Frame::builder()
.label("/ to /home ratio")
.child(&advanced_home_part_ratio_selection_box)
.margin_top(5)
.margin_bottom(5)
.build();
let advanced_home_part_ratio_selection_slider= gtk::Scale::builder()
.draw_value(false)
.build();
//
let advanced_home_seperation_selection_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.homogeneous(true)
.build();
let advanced_home_seperation_selection_frame = gtk::Frame::builder()
.label("/home seperation")
.child(&advanced_home_seperation_selection_box)
.margin_top(5)
.margin_bottom(5)
.build();
let advanced_home_seperation_selection_checkbutton_subvol = gtk::CheckButton::builder()
.label("subvol")
.active(true)
.build();
let advanced_home_seperation_selection_checkbutton_partition = gtk::CheckButton::builder()
.label("partition")
.build();
let advanced_home_seperation_selection_checkbutton_none = gtk::CheckButton::builder()
.label("none")
.build();
advanced_home_seperation_selection_checkbutton_partition.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_none.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_partition
.bind_property(
"active",
&advanced_home_part_ratio_selection_frame,
"sensitive",
)
.sync_create()
.build();
//
let advanced_filesystem_selection_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.homogeneous(true)
.build();
let advanced_filesystem_selection_frame = gtk::Frame::builder()
.label("Filesystem")
.child(&advanced_filesystem_selection_box)
.margin_top(5)
.margin_bottom(5)
.build();
let advanced_filesystem_selection_checkbutton_btrfs = gtk::CheckButton::builder()
.label("BTRFS")
.active(true)
.build();
let advanced_filesystem_selection_checkbutton_ext4 = gtk::CheckButton::builder()
.label("EXT4")
.build();
let advanced_filesystem_selection_checkbutton_xfs = gtk::CheckButton::builder()
.label("XFS")
.build();
advanced_filesystem_selection_checkbutton_btrfs
.bind_property(
"active",
&advanced_home_seperation_selection_checkbutton_subvol,
"sensitive",
)
.sync_create()
.build();
advanced_filesystem_selection_checkbutton_ext4.connect_toggled(clone!(
#[weak]
advanced_filesystem_selection_checkbutton_ext4,
#[weak]
advanced_home_seperation_selection_checkbutton_subvol,
#[weak]
advanced_home_seperation_selection_checkbutton_partition,
move |_|
{
if advanced_filesystem_selection_checkbutton_ext4.is_active() && advanced_home_seperation_selection_checkbutton_subvol.is_active() {
advanced_home_seperation_selection_checkbutton_partition.set_active(true)
}
}
)
);
advanced_filesystem_selection_checkbutton_xfs.connect_toggled(clone!(
#[weak]
advanced_filesystem_selection_checkbutton_xfs,
#[weak]
advanced_home_seperation_selection_checkbutton_subvol,
#[weak]
advanced_home_seperation_selection_checkbutton_partition,
move |_|
{
if advanced_filesystem_selection_checkbutton_xfs.is_active() && advanced_home_seperation_selection_checkbutton_subvol.is_active() {
advanced_home_seperation_selection_checkbutton_partition.set_active(true)
}
}
)
);
advanced_filesystem_selection_checkbutton_ext4.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
advanced_filesystem_selection_checkbutton_xfs.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
//
let advanced_expander = gtk::Expander::builder()
.child(&advanced_box_viewport)
.build();
//
//
let devices_selection_expander_row = adw::ExpanderRow::builder()
.name("status:disk=none,")
.build();
@ -185,6 +340,8 @@ pub fn automatic_partitioning_page(
partition_method_automatic_disk_nodisk_error_label,
#[weak]
partition_method_automatic_disk_small_error_label,
#[weak]
advanced_home_part_ratio_selection_slider,
#[strong]
partition_method_automatic_target_refcell,
#[strong]
@ -194,6 +351,14 @@ pub fn automatic_partitioning_page(
move |_| {
disk_check(&device_button, &devices_selection_expander_row, &partition_method_automatic_disk_small_error_label, &device.block_name, 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 default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 {
100000000000.0
} else {
MINIMUM_ROOT_BYTE_SIZE
};
advanced_home_part_ratio_selection_slider.set_range(MINIMUM_ROOT_BYTE_SIZE, device.block_size);
advanced_home_part_ratio_selection_slider.set_value(default_root_size);
*partition_method_automatic_target_refcell.borrow_mut() = String::from(&device.block_name);
if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true)
@ -298,153 +463,6 @@ pub fn automatic_partitioning_page(
)
);
// Advanced
let advanced_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
let advanced_box_viewport =
gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.child(&advanced_box)
.build();
//
let advanced_home_part_ratio_selection_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.homogeneous(true)
.build();
let advanced_home_part_ratio_selection_frame = gtk::Frame::builder()
.label("/ to /home ratio")
.child(&advanced_home_part_ratio_selection_box)
.margin_top(5)
.margin_bottom(5)
.build();
let advanced_home_part_ratio_selection_slider= gtk::Scale::builder()
.build();
//
let advanced_home_seperation_selection_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.homogeneous(true)
.build();
let advanced_home_seperation_selection_frame = gtk::Frame::builder()
.label("/home seperation")
.child(&advanced_home_seperation_selection_box)
.margin_top(5)
.margin_bottom(5)
.build();
let advanced_home_seperation_selection_checkbutton_subvol = gtk::CheckButton::builder()
.label("subvol")
.active(true)
.build();
let advanced_home_seperation_selection_checkbutton_partition = gtk::CheckButton::builder()
.label("partition")
.build();
let advanced_home_seperation_selection_checkbutton_none = gtk::CheckButton::builder()
.label("none")
.build();
advanced_home_seperation_selection_checkbutton_partition.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_none.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_partition
.bind_property(
"active",
&advanced_home_part_ratio_selection_frame,
"sensitive",
)
.sync_create()
.build();
//
let advanced_filesystem_selection_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal)
.homogeneous(true)
.build();
let advanced_filesystem_selection_frame = gtk::Frame::builder()
.label("Filesystem")
.child(&advanced_filesystem_selection_box)
.margin_top(5)
.margin_bottom(5)
.build();
let advanced_filesystem_selection_checkbutton_btrfs = gtk::CheckButton::builder()
.label("BTRFS")
.active(true)
.build();
let advanced_filesystem_selection_checkbutton_ext4 = gtk::CheckButton::builder()
.label("EXT4")
.build();
let advanced_filesystem_selection_checkbutton_xfs = gtk::CheckButton::builder()
.label("XFS")
.build();
advanced_filesystem_selection_checkbutton_btrfs
.bind_property(
"active",
&advanced_home_seperation_selection_checkbutton_subvol,
"sensitive",
)
.sync_create()
.build();
advanced_filesystem_selection_checkbutton_ext4.connect_toggled(clone!(
#[weak]
advanced_filesystem_selection_checkbutton_ext4,
#[weak]
advanced_home_seperation_selection_checkbutton_subvol,
#[weak]
advanced_home_seperation_selection_checkbutton_partition,
move |_|
{
if advanced_filesystem_selection_checkbutton_ext4.is_active() && advanced_home_seperation_selection_checkbutton_subvol.is_active() {
advanced_home_seperation_selection_checkbutton_partition.set_active(true)
}
}
)
);
advanced_filesystem_selection_checkbutton_xfs.connect_toggled(clone!(
#[weak]
advanced_filesystem_selection_checkbutton_xfs,
#[weak]
advanced_home_seperation_selection_checkbutton_subvol,
#[weak]
advanced_home_seperation_selection_checkbutton_partition,
move |_|
{
if advanced_filesystem_selection_checkbutton_xfs.is_active() && advanced_home_seperation_selection_checkbutton_subvol.is_active() {
advanced_home_seperation_selection_checkbutton_partition.set_active(true)
}
}
)
);
advanced_filesystem_selection_checkbutton_ext4.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
advanced_filesystem_selection_checkbutton_xfs.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
//
let advanced_expander = gtk::Expander::builder()
.child(&advanced_box_viewport)
.build();
//
devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row);