get some checks in place
This commit is contained in:
parent
803ab34294
commit
469c0b720c
@ -287,49 +287,22 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::S
|
|||||||
.unwrap_or_else(|e| panic!("failed {}", e));
|
.unwrap_or_else(|e| panic!("failed {}", e));
|
||||||
let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout"));
|
let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout"));
|
||||||
|
|
||||||
let partition_method_automatic_status_label = gtk::Label::builder()
|
let partition_method_automatic_disk_error_label = gtk::Label::builder()
|
||||||
.label("No Disk specified")
|
.label("No Disk specified.")
|
||||||
.halign(Align::Start)
|
.halign(Align::Start)
|
||||||
.valign(Align::End)
|
.valign(Align::End)
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.build();
|
.build();
|
||||||
partition_method_automatic_status_label.add_css_class("small_error_text");
|
partition_method_automatic_disk_error_label.add_css_class("small_error_text");
|
||||||
|
|
||||||
for device in partition_method_automatic_get_devices_reader.lines() {
|
let partition_method_automatic_luks_error_label = gtk::Label::builder()
|
||||||
let device = device.unwrap();
|
.label("LUKS Encryption Enabled but no password provided.")
|
||||||
let device_size_cli = Command::new("pkexec")
|
.halign(Align::Start)
|
||||||
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
|
.valign(Align::End)
|
||||||
.arg("get_block_size")
|
.vexpand(true)
|
||||||
.arg(device.clone())
|
.visible(false)
|
||||||
.output()
|
.build();
|
||||||
.expect("failed to execute process");
|
partition_method_automatic_luks_error_label.add_css_class("small_error_text");
|
||||||
let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::<f64>().unwrap();
|
|
||||||
let device_button = gtk::CheckButton::builder()
|
|
||||||
.valign(Align::Center)
|
|
||||||
.can_focus(false)
|
|
||||||
.build();
|
|
||||||
device_button.set_group(Some(&null_checkbutton));
|
|
||||||
let device_row = adw::ActionRow::builder()
|
|
||||||
.activatable_widget(&device_button)
|
|
||||||
.title(device.clone())
|
|
||||||
.subtitle(pretty_bytes::converter::convert(device_size))
|
|
||||||
.build();
|
|
||||||
device_row.add_prefix(&device_button);
|
|
||||||
devices_selection_expander_row_viewport_box.append(&device_row);
|
|
||||||
device_button.connect_toggled(clone!(@weak device_button, @weak devices_selection_expander_row, @weak bottom_next_button, @weak partition_method_automatic_status_label => move |_| {
|
|
||||||
if device_button.is_active() == true {
|
|
||||||
devices_selection_expander_row.set_title(&device);
|
|
||||||
if device_size > 39000000000.0 {
|
|
||||||
partition_method_automatic_status_label.set_visible(false);
|
|
||||||
bottom_next_button.set_sensitive(true);
|
|
||||||
} else {
|
|
||||||
partition_method_automatic_status_label.set_visible(true);
|
|
||||||
partition_method_automatic_status_label.set_label("Disk Size too small, PikaOS needs 40GB Disk");
|
|
||||||
bottom_next_button.set_sensitive(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
let partition_method_automatic_luks_box = gtk::Box::builder()
|
let partition_method_automatic_luks_box = gtk::Box::builder()
|
||||||
.orientation(Orientation::Horizontal)
|
.orientation(Orientation::Horizontal)
|
||||||
@ -357,13 +330,74 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::S
|
|||||||
.sensitive(false)
|
.sensitive(false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
partition_method_automatic_luks_checkbutton.connect_toggled(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry => move |_| {
|
for device in partition_method_automatic_get_devices_reader.lines() {
|
||||||
if partition_method_automatic_luks_checkbutton.is_active() == true {
|
let device = device.unwrap();
|
||||||
partition_method_automatic_luks_password_entry.set_sensitive(true);
|
let device_size_cli = Command::new("pkexec")
|
||||||
} else {
|
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
|
||||||
partition_method_automatic_luks_password_entry.set_sensitive(false);
|
.arg("get_block_size")
|
||||||
}
|
.arg(device.clone())
|
||||||
}));
|
.output()
|
||||||
|
.expect("failed to execute process");
|
||||||
|
let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::<f64>().unwrap();
|
||||||
|
let device_button = gtk::CheckButton::builder()
|
||||||
|
.valign(Align::Center)
|
||||||
|
.can_focus(false)
|
||||||
|
.build();
|
||||||
|
device_button.set_group(Some(&null_checkbutton));
|
||||||
|
let device_row = adw::ActionRow::builder()
|
||||||
|
.activatable_widget(&device_button)
|
||||||
|
.title(device.clone())
|
||||||
|
.subtitle(pretty_bytes::converter::convert(device_size))
|
||||||
|
.build();
|
||||||
|
device_row.add_prefix(&device_button);
|
||||||
|
devices_selection_expander_row_viewport_box.append(&device_row);
|
||||||
|
device_button.connect_toggled(clone!(@weak device_button, @weak devices_selection_expander_row, @weak bottom_next_button, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak partition_method_automatic_luks_checkbutton => move |_| {
|
||||||
|
if device_button.is_active() == true {
|
||||||
|
devices_selection_expander_row.set_title(&device);
|
||||||
|
if device_size > 39000000000.0 {
|
||||||
|
partition_method_automatic_disk_error_label.set_visible(false);
|
||||||
|
if partition_method_automatic_luks_checkbutton.is_active() == true {
|
||||||
|
if partition_method_automatic_luks_error_label.get_visible() {
|
||||||
|
//
|
||||||
|
} else {
|
||||||
|
bottom_next_button.set_sensitive(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bottom_next_button.set_sensitive(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
partition_method_automatic_disk_error_label.set_visible(true);
|
||||||
|
partition_method_automatic_disk_error_label.set_label("Disk Size too small, PikaOS needs 40GB Disk");
|
||||||
|
bottom_next_button.set_sensitive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
partition_method_automatic_luks_checkbutton.connect_toggled(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button => move |_| {
|
||||||
|
if partition_method_automatic_luks_checkbutton.is_active() == true {
|
||||||
|
partition_method_automatic_luks_password_entry.set_sensitive(true);
|
||||||
|
if partition_method_automatic_luks_password_entry.text().to_string().is_empty() {
|
||||||
|
partition_method_automatic_luks_error_label.set_visible(true);
|
||||||
|
bottom_next_button.set_sensitive(false);
|
||||||
|
} else {
|
||||||
|
partition_method_automatic_luks_error_label.set_visible(false);
|
||||||
|
if partition_method_automatic_disk_error_label.get_visible() {
|
||||||
|
//
|
||||||
|
} else {
|
||||||
|
bottom_next_button.set_sensitive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
partition_method_automatic_luks_password_entry.set_sensitive(false);
|
||||||
|
partition_method_automatic_luks_error_label.set_visible(false);
|
||||||
|
if partition_method_automatic_disk_error_label.get_visible() {
|
||||||
|
//
|
||||||
|
} else {
|
||||||
|
bottom_next_button.set_sensitive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry);
|
partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry);
|
||||||
partition_method_automatic_luks_box.append(&partition_method_automatic_luks_checkbutton);
|
partition_method_automatic_luks_box.append(&partition_method_automatic_luks_checkbutton);
|
||||||
@ -375,7 +409,8 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::S
|
|||||||
partition_method_automatic_main_box.append(&partition_method_automatic_selection_box);
|
partition_method_automatic_main_box.append(&partition_method_automatic_selection_box);
|
||||||
partition_method_automatic_main_box.append(&devices_selection_expander_row_viewport_listbox);
|
partition_method_automatic_main_box.append(&devices_selection_expander_row_viewport_listbox);
|
||||||
partition_method_automatic_main_box.append(&partition_method_automatic_luks_box);
|
partition_method_automatic_main_box.append(&partition_method_automatic_luks_box);
|
||||||
partition_method_automatic_main_box.append(&partition_method_automatic_status_label);
|
partition_method_automatic_main_box.append(&partition_method_automatic_luks_error_label);
|
||||||
|
partition_method_automatic_main_box.append(&partition_method_automatic_disk_error_label);
|
||||||
|
|
||||||
// Manual Partitioning Yard
|
// Manual Partitioning Yard
|
||||||
let partition_method_manual_main_box = gtk::Box::builder()
|
let partition_method_manual_main_box = gtk::Box::builder()
|
||||||
|
Loading…
Reference in New Issue
Block a user