RR: hook partition UI to pikainstall linker
This commit is contained in:
parent
663bff897a
commit
948be55a18
40
Cargo.lock
generated
40
Cargo.lock
generated
@ -373,6 +373,12 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.18.0"
|
||||
@ -540,6 +546,12 @@ dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
|
||||
|
||||
[[package]]
|
||||
name = "libadwaita"
|
||||
version = "0.5.3"
|
||||
@ -648,9 +660,12 @@ dependencies = [
|
||||
"duct",
|
||||
"fragile",
|
||||
"glib",
|
||||
"glob",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
"pretty-bytes",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"time",
|
||||
"zoha-vte4",
|
||||
]
|
||||
@ -760,6 +775,12 @@ dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.21"
|
||||
@ -768,24 +789,35 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.195"
|
||||
version = "1.0.196"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02"
|
||||
checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.195"
|
||||
version = "1.0.196"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
|
||||
checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.5"
|
||||
|
@ -15,3 +15,6 @@ gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
|
||||
pretty-bytes = "0.2.2"
|
||||
time = "0.3.31"
|
||||
vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] }
|
||||
glob = "0.3.1"
|
||||
serde_json = "1.0.113"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
@ -1,3 +1,4 @@
|
||||
use std::cell::RefCell;
|
||||
// Use libraries
|
||||
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
|
||||
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
|
||||
@ -18,8 +19,13 @@ use pretty_bytes::converter::convert;
|
||||
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) {
|
||||
use serde::*;
|
||||
use serde_json::*;
|
||||
use crate::manual_partitioning::DriveMount;
|
||||
|
||||
pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow, manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>) {
|
||||
|
||||
// create the bottom box for next and back buttons
|
||||
let bottom_box = gtk::Box::builder()
|
||||
@ -117,18 +123,23 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte
|
||||
.build();
|
||||
install_confirm_detail_keyboard.add_css_class("property");
|
||||
|
||||
let install_confirm_detail_target = adw::ActionRow::builder()
|
||||
.title("Install Target:")
|
||||
.build();
|
||||
|
||||
if Path::new("/tmp/pika-installer-gtk4-target-manual.txt").exists() {
|
||||
install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-manual.txt").expect("Unable to read file"));
|
||||
//install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-manual.txt").expect("Unable to read file"));
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_language);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_timezone);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard);
|
||||
for partitions in manual_drive_mount_array.borrow_mut().iter() {
|
||||
let confirm_row = adw::ActionRow::builder()
|
||||
.title("/dev/".to_owned() + &partitions.partition + " mounted on " + &partitions.mountpoint)
|
||||
.build();
|
||||
install_confirm_details_boxed_list.append(&confirm_row);
|
||||
}
|
||||
} else {
|
||||
let install_confirm_detail_target = adw::ActionRow::builder()
|
||||
.title("Install Target:")
|
||||
.build();
|
||||
install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file"));
|
||||
}
|
||||
install_confirm_detail_target.add_css_class("property");
|
||||
|
||||
if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() {
|
||||
install_confirm_detail_target.add_css_class("property");
|
||||
let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file");
|
||||
let target_size_cli = Command::new("sudo")
|
||||
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
|
||||
@ -188,13 +199,6 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte
|
||||
install_confirm_details_boxed_list.append(&install_confirm_p2);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_p3);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_p4);
|
||||
} else {
|
||||
// / install_confirm_selection_box appends
|
||||
//// add live and install media button to install page selections
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_language);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_timezone);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard);
|
||||
install_confirm_details_boxed_list.append(&install_confirm_detail_target);
|
||||
}
|
||||
|
||||
let install_confirm_button = gtk::Button::builder()
|
||||
|
@ -46,16 +46,18 @@ use gtk::Orientation::Vertical;
|
||||
|
||||
use pretty_bytes::converter::convert;
|
||||
use crate::drive_mount_row::DriveMountRow;
|
||||
use serde::*;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Eq)]
|
||||
#[derive(Hash)]
|
||||
#[derive(Clone)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct DriveMount {
|
||||
partition: String,
|
||||
mountpoint: String,
|
||||
mountopt: String,
|
||||
pub partition: String,
|
||||
pub mountpoint: String,
|
||||
pub mountopt: String,
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -129,7 +131,7 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc<RefCel
|
||||
}
|
||||
|
||||
//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();
|
||||
|
||||
@ -309,7 +311,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
||||
});
|
||||
|
||||
let anti_dup_partition_loop_context = MainContext::default();
|
||||
anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move {
|
||||
anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @weak partitioning_stack, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move {
|
||||
while let Ok(_state) = anti_dup_partition_receiver.recv().await {
|
||||
let mut counter = drive_mounts_adw_listbox.first_child();
|
||||
|
||||
@ -357,13 +359,15 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack:
|
||||
}
|
||||
let manual_drive_mount_array_ref_clone = manual_drive_mount_array_ref.clone();
|
||||
partition_err_check(&partition_method_manual_warn_label, &partition_method_manual_error_label, manual_drive_mount_array_ref, &check_part_unique);
|
||||
if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() {
|
||||
if !bottom_next_button.is_sensitive() {
|
||||
bottom_next_button.set_sensitive(true);
|
||||
}
|
||||
} else {
|
||||
if bottom_next_button.is_sensitive() {
|
||||
bottom_next_button.set_sensitive(false);
|
||||
if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_manual_page".into())) {
|
||||
if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() {
|
||||
if !bottom_next_button.is_sensitive() {
|
||||
bottom_next_button.set_sensitive(true);
|
||||
}
|
||||
} else {
|
||||
if bottom_next_button.is_sensitive() {
|
||||
bottom_next_button.set_sensitive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ use adw::*;
|
||||
use glib::*;
|
||||
use gdk::Display;
|
||||
use gtk::subclass::layout_child;
|
||||
use glob::glob;
|
||||
|
||||
use crate::automatic_partitioning::automatic_partitioning;
|
||||
use crate::manual_partitioning::manual_partitioning;
|
||||
@ -219,7 +220,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
||||
/// add all pages to partitioning stack
|
||||
partitioning_stack.add_titled(&partitioning_method_main_box, Some("partition_method_select_page"), "partition_method_select_page");
|
||||
let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button);
|
||||
let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, manual_drive_mount_array);
|
||||
let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, &manual_drive_mount_array);
|
||||
|
||||
// add everything to the main box
|
||||
partitioning_main_box.append(&partitioning_stack);
|
||||
@ -236,10 +237,6 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
||||
|
||||
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_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone();
|
||||
|
||||
bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| {
|
||||
content_stack.set_visible_child_name("install_page")
|
||||
}));
|
||||
@ -249,7 +246,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
||||
bottom_next_button.set_sensitive(false);
|
||||
}));
|
||||
|
||||
bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| {
|
||||
bottom_next_button.connect_clicked(clone!(@strong manual_drive_mount_array, @weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| {
|
||||
if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() {
|
||||
fs::remove_file("/tmp/pika-installer-gtk4-target-auto.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-auto.txt");
|
||||
}
|
||||
@ -262,6 +259,10 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
||||
if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() {
|
||||
fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt");
|
||||
}
|
||||
for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") {
|
||||
let partition_file = partition_file.unwrap();
|
||||
fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap());
|
||||
}
|
||||
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");
|
||||
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();
|
||||
@ -270,18 +271,17 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,
|
||||
} else {
|
||||
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, &manual_drive_mount_array);
|
||||
content_stack.set_visible_child_name("install_page");
|
||||
} else {
|
||||
//fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file");
|
||||
//partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string());
|
||||
//let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string();
|
||||
//if manual_luks_result.is_empty() {
|
||||
// //
|
||||
//} else {
|
||||
// fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result);
|
||||
//}
|
||||
install_page(&done_main_box, &install_main_box, &content_stack, &window);
|
||||
fs::write("/tmp/pika-installer-gtk4-target-manual.txt", "").expect("Unable to write file");
|
||||
let mut iter_count = 0;
|
||||
iter_count = 0;
|
||||
for partitions in manual_drive_mount_array.borrow_mut().iter() {
|
||||
fs::write("/tmp/pika-installer-gtk4-target-manual-p".to_owned() + &iter_count.to_string() + ".json", serde_json::to_string(partitions).unwrap()).expect("Unable to write file");
|
||||
iter_count += 1;
|
||||
}
|
||||
install_page(&done_main_box, &install_main_box, &content_stack, &window, &manual_drive_mount_array);
|
||||
content_stack.set_visible_child_name("install_page");
|
||||
}
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user