fix weird shit

This commit is contained in:
Ward from fusion-voyager-3 2024-01-21 21:43:58 +03:00
parent 26c6a2bd38
commit f040d7461d
3 changed files with 80 additions and 20 deletions

View File

@ -117,8 +117,17 @@ pub fn build_ui(app: &adw::Application) {
// Add keyboard_page.rs as a page for content_stack
keyboard_page(&content_stack);
// Add install_page.rs as a page for content_stack
let install_main_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
// Add partitioning_page.rs as a page for content_stack
partitioning_page(&window, &content_stack);
partitioning_page(&install_main_box , &window, &content_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"), "Installation");
// glib maximization
if glib_settings.boolean("is-maximized") == true {

View File

@ -14,7 +14,7 @@ use vte::*;
use std::fs;
use std::path::Path;
pub fn install_page(content_stack: &gtk::Stack) {
pub fn install_page(install_main_box: &gtk::Box ,content_stack: &gtk::Stack) {
// create the bottom box for next and back buttons
let bottom_box = gtk::Box::builder()
@ -38,10 +38,6 @@ pub fn install_page(content_stack: &gtk::Stack) {
//// Add the next and back buttons
bottom_box.append(&bottom_back_button);
let install_main_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
let install_nested_stack = gtk::Stack::builder()
.transition_type(StackTransitionType::SlideLeftRight)
.build();
@ -178,7 +174,11 @@ pub fn install_page(content_stack: &gtk::Stack) {
.orientation(Orientation::Vertical)
.build();
let the_terminal = vte::Terminal::builder()
let install_progress_log_stack = gtk::Stack::builder()
.transition_type(StackTransitionType::SlideUpDown)
.build();
let install_progress_log_terminal = vte::Terminal::builder()
.vexpand(true)
.hexpand(true)
.margin_top(15)
@ -188,7 +188,7 @@ pub fn install_page(content_stack: &gtk::Stack) {
.sensitive(false)
.build();
the_terminal.spawn_async(
install_progress_log_terminal.spawn_async(
PtyFlags::DEFAULT,
Some(""),
&["bash"],
@ -207,19 +207,70 @@ pub fn install_page(content_stack: &gtk::Stack) {
},
);
install_progress_box.append(&the_terminal);
let placeholder_icon = gtk::Image::builder()
.icon_name("debian-swirl")
.halign(gtk::Align::Center)
.valign(gtk::Align::Center)
.hexpand(true)
.vexpand(true)
.pixel_size(512)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.build();
let progress_bar_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
.margin_start(15)
.margin_end(15)
.build();
let install_progress_bar = gtk::ProgressBar::builder()
.hexpand(true)
.margin_start(15)
.margin_end(15)
.margin_top(15)
.margin_bottom(15)
.build();
let progress_log_button_content = adw::ButtonContent::builder()
.label("View Logs")
.icon_name("terminal")
.build();
let progress_log_button = gtk::Button::builder()
.child(&progress_log_button_content)
.margin_start(15)
.margin_end(15)
.margin_top(15)
.margin_bottom(15)
.build();
progress_bar_box.append(&install_progress_bar);
progress_bar_box.append(&progress_log_button);
install_progress_log_stack.add_titled(&placeholder_icon, Some("slideshow_page"), "slideshow_page");
install_progress_log_stack.add_titled(&install_progress_log_terminal, Some("terminal_log_page"), "terminal_log_page");
install_progress_box.append(&install_progress_log_stack);
install_progress_box.append(&progress_bar_box);
install_nested_stack.add_titled(&install_confirm_box, Some("confirm_page"), "confirm_page");
install_nested_stack.add_titled(&install_progress_box, Some("progress_page"), "progress_page");
// / 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"), "Installation");
install_confirm_button.connect_clicked(clone!(@weak install_nested_stack => move |_| install_nested_stack.set_visible_child_name("progress_page")));
progress_log_button.connect_clicked(clone!(@weak install_progress_log_stack => move |_| {
if install_progress_log_stack.visible_child_name() == Some(GString::from_string_unchecked("slideshow_page".into())) {
install_progress_log_stack.set_visible_child_name("terminal_log_page");
} else {
install_progress_log_stack.set_visible_child_name("slideshow_page");
}
}));
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");
content_stack.remove(&install_main_box);
}));
}

View File

@ -25,15 +25,15 @@ use std::path::Path;
use crate::install_page;
pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {
pub fn partitioning_page(install_main_box: &gtk::Box, window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {
// create the bottom box for next and back buttons
let bottom_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
.valign(gtk::Align::End)
.vexpand(true)
.build();
// Next and back button
let bottom_back_button = gtk::Button::builder()
.label("Back")
@ -978,7 +978,7 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: &gtk::S
partitioning_stack.set_visible_child_name("partition_method_select_page");
}));
bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack => move |_| {
bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak install_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");
}
@ -999,7 +999,7 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: &gtk::S
} else {
fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result);
}
install_page(&content_stack);
install_page(&install_main_box, &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");
@ -1010,7 +1010,7 @@ pub fn partitioning_page(window: &adw::ApplicationWindow, content_stack: &gtk::S
} else {
fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result);
}
install_page(&content_stack);
install_page(&install_main_box, &content_stack);
content_stack.set_visible_child_name("install_page");
}
}));