Some progress

This commit is contained in:
Ward from fusion-voyager-3 2024-01-18 17:16:26 +03:00
parent d4caeee694
commit 94be21c822
6 changed files with 138 additions and 28 deletions

46
Cargo.lock generated
View File

@ -21,6 +21,17 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@ -256,6 +267,15 @@ dependencies = [
"system-deps",
]
[[package]]
name = "getopts"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]
[[package]]
name = "gio"
version = "0.18.4"
@ -466,6 +486,15 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "indexmap"
version = "2.1.0"
@ -575,6 +604,7 @@ dependencies = [
"glib",
"gtk4",
"libadwaita",
"pretty-bytes",
"time",
]
@ -602,6 +632,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "pretty-bytes"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "009d6edd2c1dbf2e1c0cd48a2f7766e03498d49ada7109a01c6911815c685316"
dependencies = [
"atty",
"getopts",
]
[[package]]
name = "proc-macro-crate"
version = "1.3.1"
@ -853,6 +893,12 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "version-compare"
version = "0.1.1"

View File

@ -11,4 +11,5 @@ async-channel = "2.1.1"
fragile = "2.0.0"
glib = "0.18.5"
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
pretty-bytes = "0.2.2"
time = "0.3.31"

View File

@ -146,20 +146,9 @@ pub fn keyboard_page(content_stack: &gtk::Stack) {
keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport);
keyboard_selection_expander_row_viewport_box.append(&null_checkbutton);
let null_checkbutton_clone = null_checkbutton.clone();
let keyboard_selection_expander_row_clone2 = keyboard_selection_expander_row.clone();
let bottom_next_button_clone = bottom_next_button.clone();
null_checkbutton.connect_toggled(move |_| {
if null_checkbutton_clone.is_active() == true {
keyboard_selection_expander_row_clone2.set_title("No Keyboard Layout selected");
bottom_next_button_clone.set_sensitive(false);
}
});
let mut current_keyboard_cli = Command::new("localectl")
.arg("status")
.stdin(Stdio::piped())

View File

@ -147,20 +147,9 @@ pub fn language_page(content_stack: &gtk::Stack) {
language_selection_expander_row.add_row(&language_selection_expander_row_viewport);
language_selection_expander_row_viewport_box.append(&null_checkbutton);
let null_checkbutton_clone = null_checkbutton.clone();
let language_selection_expander_row_clone2 = language_selection_expander_row.clone();
let bottom_next_button_clone = bottom_next_button.clone();
null_checkbutton.connect_toggled(move |_| {
if null_checkbutton_clone.is_active() == true {
language_selection_expander_row_clone2.set_title("No locale selected");
bottom_next_button_clone.set_sensitive(false);
}
});
let current_locale = match env::var_os("LANG") {
Some(v) => v.into_string().unwrap(),
None => panic!("$LANG is not set")

View File

@ -9,6 +9,14 @@ use glib::*;
use gdk::Display;
use gtk::subclass::layout_child;
use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::time::Instant;
use std::env;
use pretty_bytes::converter::convert;
pub fn partitioning_page(content_stack: &gtk::Stack) {
// create the bottom box for next and back buttons
@ -239,7 +247,66 @@ pub fn partitioning_page(content_stack: &gtk::Stack) {
.margin_start(15)
.margin_end(15)
.build();
partition_method_automatic_selection_text.add_css_class("medium_sixed_text");
partition_method_automatic_selection_text.add_css_class("medium_sized_text");
let devices_selection_expander_row = adw::ExpanderRow::builder()
.title("No disk selected for selection")
.build();
let null_checkbutton = gtk::CheckButton::builder()
.build();
let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder()
.height_request(200)
.build();
let devices_selection_expander_row_viewport_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
devices_selection_expander_row_viewport.set_child(Some(&devices_selection_expander_row_viewport_box));
let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(SelectionMode::None)
.margin_top(15)
.margin_bottom(15)
.margin_start(15)
.margin_end(15)
.build();
devices_selection_expander_row_viewport_listbox.add_css_class("boxed-list");
devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row);
devices_selection_expander_row.add_row(&devices_selection_expander_row_viewport);
let mut partition_method_automatic_get_devices_cli = Command::new("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_block_devices")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.unwrap_or_else(|e| panic!("failed {}", e));
let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.as_mut().expect("could not get stdout"));
for device in partition_method_automatic_get_devices_reader.lines() {
let device = device.unwrap();
let device_size_cli = Command::new("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.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)
.subtitle(pretty_bytes::converter::convert(device_size))
.build();
device_row.add_prefix(&device_button);
devices_selection_expander_row_viewport_box.append(&device_row);
}
let partition_method_automatic_luks_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
@ -266,6 +333,14 @@ pub fn partitioning_page(content_stack: &gtk::Stack) {
.hexpand(true)
.build();
let partition_method_automatic_status_label = gtk::Label::builder()
.label("No Disk specified")
.halign(Align::Start)
.valign(Align::End)
.vexpand(true)
.build();
partition_method_automatic_status_label.add_css_class("small_error_text");
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_listbox);
@ -274,8 +349,9 @@ pub fn partitioning_page(content_stack: &gtk::Stack) {
partition_method_automatic_selection_box.append(&partition_method_automatic_selection_text);
partition_method_automatic_main_box.append(&partition_method_automatic_header_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(&partition_method_automatic_luks_box);
partition_method_automatic_main_box.append(&partition_method_automatic_status_label);
// Manual Partitioning Yard
let partition_method_manual_main_box = gtk::Box::builder()
@ -327,7 +403,7 @@ pub fn partitioning_page(content_stack: &gtk::Stack) {
.margin_start(15)
.margin_end(15)
.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_method_manual_luks_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
@ -354,6 +430,14 @@ pub fn partitioning_page(content_stack: &gtk::Stack) {
.hexpand(true)
.build();
let partition_method_manual_status_label = gtk::Label::builder()
.label("No mountpoint specified")
.halign(Align::Start)
.valign(Align::End)
.vexpand(true)
.build();
partition_method_manual_status_label.add_css_class("small_error_text");
partition_method_manual_luks_listbox.append(&partition_method_manual_luks_password_entry);
partition_method_manual_luks_box.append(&partition_method_manual_luks_checkbutton);
partition_method_manual_luks_box.append(&partition_method_manual_luks_listbox);
@ -364,6 +448,7 @@ pub fn partitioning_page(content_stack: &gtk::Stack) {
partition_method_manual_main_box.append(&partition_method_manual_selection_box);
partition_method_manual_main_box.append(&partition_method_manual_luks_box);
partition_method_manual_main_box.append(&partition_method_manual_status_label);
/// add all pages to partitioning stack
partitioning_stack.add_titled(&partitioning_method_main_box, Some("partition_method_select_page"), "partition_method_select_page");

View File

@ -1,5 +1,5 @@
.bigREDTEXT {
font-size: 14px;
.small_error_text {
font-size: 11px;
color: red;
}