RR: Some minor manual partition gui touch ups
This commit is contained in:
parent
c9c2e1f854
commit
663bff897a
@ -58,7 +58,7 @@ pub struct DriveMount {
|
|||||||
mountopt: String,
|
mountopt: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>, check_part_unique: &Rc<RefCell<bool>>) -> DriveMountRow {
|
fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>, part_table_array: &Rc<RefCell<Vec<String>>>, check_part_unique: &Rc<RefCell<bool>>) -> DriveMountRow {
|
||||||
let partition_scroll_child = gtk::ListBox::builder()
|
let partition_scroll_child = gtk::ListBox::builder()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -76,12 +76,8 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc<RefCel
|
|||||||
|
|
||||||
let partition_method_manual_emitter = gtk::SignalAction::new("partchg");
|
let partition_method_manual_emitter = gtk::SignalAction::new("partchg");
|
||||||
|
|
||||||
let partition_method_manual_get_partitions_cmd = cmd!("bash", "-c", "sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions");
|
let mut part_table_array_ref = part_table_array.borrow_mut();
|
||||||
let partition_method_manual_get_partitions_reader = partition_method_manual_get_partitions_cmd.stderr_to_stdout().reader();
|
for partition in part_table_array_ref.iter() {
|
||||||
let mut partition_method_manual_get_partitions_lines = BufReader::new(partition_method_manual_get_partitions_reader.unwrap()).lines();
|
|
||||||
|
|
||||||
for partition in partition_method_manual_get_partitions_lines {
|
|
||||||
let partition = partition.unwrap();
|
|
||||||
let partition_size_cli = Command::new("sudo")
|
let partition_size_cli = Command::new("sudo")
|
||||||
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
|
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
|
||||||
.arg("get_part_size")
|
.arg("get_part_size")
|
||||||
@ -112,7 +108,7 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc<RefCel
|
|||||||
if partition_button.is_active() == true {
|
if partition_button.is_active() == true {
|
||||||
row.set_partition(partition.clone());
|
row.set_partition(partition.clone());
|
||||||
} else {
|
} else {
|
||||||
let manual_drive_mount_array_ref_index = manual_drive_mount_array_ref.iter().position(|x| *x.partition == partition.clone()).unwrap();
|
let manual_drive_mount_array_ref_index = manual_drive_mount_array_ref.iter().position(|x| x.partition == partition.clone()).unwrap();
|
||||||
manual_drive_mount_array_ref.remove(manual_drive_mount_array_ref_index);
|
manual_drive_mount_array_ref.remove(manual_drive_mount_array_ref_index);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -132,18 +128,11 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc<RefCel
|
|||||||
row
|
row
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_unique_elements<T>(iter: T) -> bool
|
|
||||||
where
|
|
||||||
T: IntoIterator,
|
|
||||||
T::Item: Eq + Hash,
|
|
||||||
{
|
|
||||||
let mut uniq = HashSet::new();
|
|
||||||
iter.into_iter().all(move |x| uniq.insert(x))
|
|
||||||
}
|
|
||||||
|
|
||||||
//pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) {
|
//pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) {
|
||||||
pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: Rc<RefCell<Vec<DriveMount>>>) {
|
pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: Rc<RefCell<Vec<DriveMount>>>) {
|
||||||
|
|
||||||
|
let part_table_array: Rc<RefCell<Vec<String>>> = Default::default();
|
||||||
|
|
||||||
let check_part_unique = Rc::new(RefCell::new(true));
|
let check_part_unique = Rc::new(RefCell::new(true));
|
||||||
|
|
||||||
let partition_method_manual_main_box = gtk::Box::builder()
|
let partition_method_manual_main_box = gtk::Box::builder()
|
||||||
@ -228,7 +217,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
let partition_method_manual_selection_text = gtk::Label::builder()
|
let partition_method_manual_selection_text = gtk::Label::builder()
|
||||||
.label("\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n ")
|
.label("\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n ")
|
||||||
.halign(gtk::Align::Center)
|
.halign(gtk::Align::Center)
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.margin_top(15)
|
.margin_top(15)
|
||||||
@ -238,6 +227,12 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
|||||||
.build();
|
.build();
|
||||||
partition_method_manual_selection_text.add_css_class("medium_sized_text");
|
partition_method_manual_selection_text.add_css_class("medium_sized_text");
|
||||||
|
|
||||||
|
let partition_refresh_button = gtk::Button::builder()
|
||||||
|
.label("Refresh Partition Table")
|
||||||
|
.halign(gtk::Align::End)
|
||||||
|
.build();
|
||||||
|
partition_refresh_button.add_css_class("destructive-action");
|
||||||
|
|
||||||
let drive_mount_add_button = gtk::Button::builder()
|
let drive_mount_add_button = gtk::Button::builder()
|
||||||
.icon_name("list-add")
|
.icon_name("list-add")
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
@ -263,6 +258,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
|||||||
partition_method_manual_header_box.append(&partition_method_manual_header_text);
|
partition_method_manual_header_box.append(&partition_method_manual_header_text);
|
||||||
partition_method_manual_header_box.append(&partition_method_manual_header_icon);
|
partition_method_manual_header_box.append(&partition_method_manual_header_icon);
|
||||||
partition_method_manual_selection_box.append(&partition_method_manual_selection_text);
|
partition_method_manual_selection_box.append(&partition_method_manual_selection_text);
|
||||||
|
partition_method_manual_selection_box.append(&partition_refresh_button);
|
||||||
partition_method_manual_main_box.append(&partition_method_manual_header_box);
|
partition_method_manual_main_box.append(&partition_method_manual_header_box);
|
||||||
partition_method_manual_main_box.append(&partition_method_manual_selection_box);
|
partition_method_manual_main_box.append(&partition_method_manual_selection_box);
|
||||||
partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content);
|
partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content);
|
||||||
@ -273,14 +269,31 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
|||||||
partition_method_manual_main_box.append(&partition_method_manual_error_label);
|
partition_method_manual_main_box.append(&partition_method_manual_error_label);
|
||||||
partition_method_manual_main_box.append(&partition_method_manual_warn_label);
|
partition_method_manual_main_box.append(&partition_method_manual_warn_label);
|
||||||
|
|
||||||
|
partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array => move |_| {
|
||||||
|
let mut counter = drive_mounts_adw_listbox.first_child();
|
||||||
|
while let Some(ref row) = counter {
|
||||||
|
if row.widget_name() == "DriveMountRow" {
|
||||||
|
drive_mounts_adw_listbox.remove(row);
|
||||||
|
}
|
||||||
|
counter = row.next_sibling();
|
||||||
|
}
|
||||||
|
let mut partition_method_manual_get_partitions_lines = BufReader::new(cmd!("bash", "-c", "sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions").reader().unwrap()).lines();
|
||||||
|
let mut part_table_array_ref = part_table_array.borrow_mut();
|
||||||
|
part_table_array_ref.clear();
|
||||||
|
for partition in partition_method_manual_get_partitions_lines {
|
||||||
|
part_table_array_ref.push(partition.unwrap());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
partition_refresh_button.emit_clicked();
|
||||||
|
|
||||||
partition_method_manual_gparted_button.connect_clicked(move |_| {
|
partition_method_manual_gparted_button.connect_clicked(move |_| {
|
||||||
Command::new("gparted")
|
Command::new("gparted")
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("gparted failed to start");
|
.expect("gparted failed to start");
|
||||||
});
|
});
|
||||||
|
|
||||||
drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong check_part_unique => move |_| {
|
drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong part_table_array, @strong check_part_unique => move |_| {
|
||||||
drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &manual_drive_mount_array, &check_part_unique))
|
drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &manual_drive_mount_array, &part_table_array,&check_part_unique))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let (anti_dup_partition_sender, anti_dup_partition_receiver) = async_channel::unbounded();
|
let (anti_dup_partition_sender, anti_dup_partition_receiver) = async_channel::unbounded();
|
||||||
|
@ -232,9 +232,9 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
|||||||
automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page")));
|
automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page")));
|
||||||
manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page")));
|
manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page")));
|
||||||
|
|
||||||
//let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone();
|
let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone();
|
||||||
|
|
||||||
//let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone();
|
let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone();
|
||||||
|
|
||||||
//let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone();
|
//let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone();
|
||||||
|
|
||||||
@ -263,13 +263,13 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
|||||||
fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
|
fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
|
||||||
}
|
}
|
||||||
if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) {
|
if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) {
|
||||||
//fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file");
|
fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file");
|
||||||
//let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string();
|
let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string();
|
||||||
//if automatic_luks_result.is_empty() {
|
if automatic_luks_result.is_empty() {
|
||||||
// //
|
//
|
||||||
//} else {
|
} else {
|
||||||
// fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result);
|
fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result);
|
||||||
//}
|
}
|
||||||
install_page(&done_main_box, &install_main_box, &content_stack, &window);
|
install_page(&done_main_box, &install_main_box, &content_stack, &window);
|
||||||
content_stack.set_visible_child_name("install_page");
|
content_stack.set_visible_child_name("install_page");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user