diff --git a/src/build_ui.rs b/src/build_ui.rs index 1365da7..63bf34f 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -16,7 +16,6 @@ use crate::eula_page; use crate::timezone_page; use crate::keyboard_page; use crate::partitioning_page; -use crate::install_page; use std::path::Path; @@ -121,9 +120,6 @@ pub fn build_ui(app: &adw::Application) { // Add partitioning_page.rs as a page for content_stack partitioning_page(&window, &content_stack); - // Add install_page.rs as a page for content_stack - install_page(&content_stack); - // glib maximization if glib_settings.boolean("is-maximized") == true { window.maximize() diff --git a/src/install_page.rs b/src/install_page.rs index 179a61c..98fa254 100644 --- a/src/install_page.rs +++ b/src/install_page.rs @@ -11,6 +11,9 @@ use gtk::subclass::layout_child; use vte::prelude::*; use vte::*; +use std::fs; +use std::path::Path; + pub fn install_page(content_stack: >k::Stack) { // create the bottom box for next and back buttons @@ -97,26 +100,31 @@ pub fn install_page(content_stack: >k::Stack) { let install_confirm_detail_language = adw::ActionRow::builder() .title("Language:") - .subtitle("en_us") + .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-lang.txt").expect("Unable to read file")) .build(); install_confirm_detail_language.add_css_class("property"); let install_confirm_detail_timezone = adw::ActionRow::builder() .title("Time zone:") - .subtitle("Europe/Moscow") + .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-timezone.txt").expect("Unable to read file")) .build(); install_confirm_detail_timezone.add_css_class("property"); let install_confirm_detail_keyboard = adw::ActionRow::builder() .title("Keyboard layout:") - .subtitle("us") + .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-keyboard.txt").expect("Unable to read file")) .build(); install_confirm_detail_keyboard.add_css_class("property"); let install_confirm_detail_target = adw::ActionRow::builder() .title("Install Target:") - .subtitle("/dev/sda1") .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")); + } else { + 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"); let install_confirm_button = gtk::Button::builder() @@ -206,11 +214,12 @@ pub fn install_page(content_stack: >k::Stack) { // / Content stack appends //// Add the install_main_box as page: install_page, Give it nice title - content_stack.add_titled(&install_main_box, Some("install_page"), "Welcome"); + content_stack.add_titled(&install_main_box, Some("install_page"), "Installation"); install_confirm_button.connect_clicked(clone!(@weak install_nested_stack => move |_| install_nested_stack.set_visible_child_name("progress_page"))); - bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { + bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak install_main_box => move |_| { + content_stack.remove(&install_main_box); content_stack.set_visible_child_name("partitioning_page"); })); } \ No newline at end of file diff --git a/src/keyboard_page.rs b/src/keyboard_page.rs index bb041af..2ca0cc2 100644 --- a/src/keyboard_page.rs +++ b/src/keyboard_page.rs @@ -230,11 +230,11 @@ pub fn keyboard_page(content_stack: >k::Stack) { let keyboard_data_buffer_clone = keyboard_data_buffer.clone(); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("partitioning_page"); if Path::new("/tmp/pika-installer-gtk4-keyboard.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-keyboard.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-keyboard.txt"); } fs::write("/tmp/pika-installer-gtk4-keyboard.txt", keyboard_data_buffer_clone.text(&keyboard_data_buffer_clone.bounds().0, &keyboard_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + content_stack.set_visible_child_name("partitioning_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { diff --git a/src/language_page.rs b/src/language_page.rs index 69a1f09..2b5c584 100644 --- a/src/language_page.rs +++ b/src/language_page.rs @@ -225,11 +225,11 @@ pub fn language_page(content_stack: >k::Stack) { let lang_data_buffer_clone = lang_data_buffer.clone(); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("eula_page"); if Path::new("/tmp/pika-installer-gtk4-lang.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-lang.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-lang.txt"); } fs::write("/tmp/pika-installer-gtk4-lang.txt", lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + content_stack.set_visible_child_name("eula_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("welcome_page") diff --git a/src/partitioning_page.rs b/src/partitioning_page.rs index f75e3d9..2a18655 100644 --- a/src/partitioning_page.rs +++ b/src/partitioning_page.rs @@ -23,6 +23,8 @@ use std::time::*; use std::fs; use std::path::Path; +use crate::install_page; + pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // create the bottom box for next and back buttons @@ -971,13 +973,12 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::S bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("install_page") })); - bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack => move |_| { + bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak partitioning_main_box => move |_| { content_stack.set_visible_child_name("keyboard_page"); partitioning_stack.set_visible_child_name("partition_method_select_page"); })); bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack => move |_| { - content_stack.set_visible_child_name("install_page"); 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"); } @@ -998,6 +999,8 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::S } else { fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); } + install_page(&content_stack); + 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(&partition_method_manual_luks_password_entry.text().to_string()); @@ -1007,6 +1010,8 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: >k::S } else { fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result); } + install_page(&content_stack); + content_stack.set_visible_child_name("install_page"); } })); diff --git a/src/timezone_page.rs b/src/timezone_page.rs index 21efa1f..492835b 100644 --- a/src/timezone_page.rs +++ b/src/timezone_page.rs @@ -220,11 +220,11 @@ pub fn timezone_page(content_stack: >k::Stack) { let timezone_data_buffer_clone = timezone_data_buffer.clone(); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("keyboard_page"); if Path::new("/tmp/pika-installer-gtk4-timezone.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-timezone.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-timezone.txt"); } fs::write("/tmp/pika-installer-gtk4-timezone.txt", timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + content_stack.set_visible_child_name("keyboard_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("eula_page")