cargo fmt

This commit is contained in:
Ward from fusion-voyager-3 2024-08-23 01:02:58 +03:00
parent c7a5735e2d
commit b70fc0a3fb
13 changed files with 1047 additions and 937 deletions

View File

@ -1,7 +1,7 @@
use crate::build_ui::BlockDevice;
use crate::config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE, MINIMUM_ROOT_BYTE_SIZE};
use crate::installer_stack_page; use crate::installer_stack_page;
use crate::partitioning_page::get_block_devices; use crate::partitioning_page::get_block_devices;
use crate::config::{MINIMUM_EFI_BYTE_SIZE, MINIMUM_BOOT_BYTE_SIZE, MINIMUM_ROOT_BYTE_SIZE};
use crate::build_ui::BlockDevice;
use adw::gio; use adw::gio;
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local, ffi::gboolean}; use glib::{clone, closure_local, ffi::gboolean};
@ -411,7 +411,8 @@ pub fn automatic_partitioning_page(
device.block_size, device.block_size,
); );
partition_method_automatic_disk_nodisk_error_label.set_visible(false); partition_method_automatic_disk_nodisk_error_label.set_visible(false);
let usable_disk_space = device.block_size - (MINIMUM_EFI_BYTE_SIZE + MINIMUM_BOOT_BYTE_SIZE); let usable_disk_space =
device.block_size - (MINIMUM_EFI_BYTE_SIZE + MINIMUM_BOOT_BYTE_SIZE);
let default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 { let default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 {
100000000000.0 100000000000.0
} else if (usable_disk_space * 40.0) / 100.0 < MINIMUM_ROOT_BYTE_SIZE { } else if (usable_disk_space * 40.0) / 100.0 < MINIMUM_ROOT_BYTE_SIZE {
@ -426,8 +427,7 @@ pub fn automatic_partitioning_page(
"change_value", "change_value",
&[gtk::ScrollType::None.into(), default_root_size.into()], &[gtk::ScrollType::None.into(), default_root_size.into()],
); );
*partition_method_automatic_target_refcell.borrow_mut() = *partition_method_automatic_target_refcell.borrow_mut() = device.clone();
device.clone();
if check_for_errors(&error_labels) { if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true) automatic_partitioning_page.set_next_sensitive(true)
} else { } else {

View File

@ -1,5 +1,7 @@
use crate::{ use crate::{
config::APP_ID, efi_error_page, eula_page, keyboard_page, language_page, timezone_page, welcome_page, partitioning_page, installation_summary_page config::APP_ID, efi_error_page, eula_page, installation_progress_page,
installation_summary_page, keyboard_page, language_page, partitioning_page, timezone_page,
welcome_page,
}; };
use gtk::{gio, glib, prelude::*}; use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, path::Path, rc::Rc}; use std::{cell::RefCell, path::Path, rc::Rc};
@ -11,7 +13,7 @@ use std::{cell::RefCell, path::Path, rc::Rc};
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]
pub struct PikaLocale { pub struct PikaLocale {
pub name: String, pub name: String,
pub pretty_name: String pub pretty_name: String,
} }
/// Keyboard Data types /// Keyboard Data types
@ -20,7 +22,7 @@ pub struct PikaLocale {
pub struct PikaKeymap { pub struct PikaKeymap {
pub name: String, pub name: String,
pub variant: Option<String>, pub variant: Option<String>,
pub pretty_name: String pub pretty_name: String,
} }
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]
@ -172,7 +174,40 @@ pub fn build_ui(app: &adw::Application) {
&page_done_action, &page_done_action,
); );
installation_summary_page::installation_summary_page(&carousel, &language_changed_action, &page_done_action,&language_selection_text_refcell, &keymap_selection_text_refcell, &timezone_selection_text_refcell, &partition_method_type_refcell, &partition_method_automatic_target_refcell, &partition_method_automatic_target_fs_refcell, &partition_method_automatic_luks_enabled_refcell, &partition_method_automatic_luks_refcell, &partition_method_automatic_ratio_refcell, &partition_method_automatic_seperation_refcell, &partition_method_manual_fstab_entry_array_refcell, &partition_method_manual_luks_enabled_refcell, &partition_method_manual_crypttab_entry_array_refcell); installation_summary_page::installation_summary_page(
&carousel,
&language_changed_action,
&page_done_action,
&language_selection_text_refcell,
&keymap_selection_text_refcell,
&timezone_selection_text_refcell,
&partition_method_type_refcell,
&partition_method_automatic_target_refcell,
&partition_method_automatic_target_fs_refcell,
&partition_method_automatic_luks_enabled_refcell,
&partition_method_automatic_luks_refcell,
&partition_method_automatic_ratio_refcell,
&partition_method_automatic_seperation_refcell,
&partition_method_manual_fstab_entry_array_refcell,
&partition_method_manual_luks_enabled_refcell,
&partition_method_manual_crypttab_entry_array_refcell,
);
installation_progress_page::create_installation_script(
&language_selection_text_refcell,
&keymap_selection_text_refcell,
&timezone_selection_text_refcell,
&partition_method_type_refcell,
&partition_method_automatic_target_refcell,
&partition_method_automatic_target_fs_refcell,
&partition_method_automatic_luks_enabled_refcell,
&partition_method_automatic_luks_refcell,
&partition_method_automatic_ratio_refcell,
&partition_method_automatic_seperation_refcell,
&partition_method_manual_fstab_entry_array_refcell,
&partition_method_manual_luks_enabled_refcell,
&partition_method_manual_crypttab_entry_array_refcell,
);
window.present() window.present()
} }

View File

@ -4,7 +4,7 @@ use adw::{prelude::*, subclass::prelude::*, *};
use glib::{clone, subclass::Signal, Properties}; use glib::{clone, subclass::Signal, Properties};
use gtk::{glib, Orientation::Horizontal}; use gtk::{glib, Orientation::Horizontal};
use crate::{build_ui::{FstabEntry}}; use crate::build_ui::FstabEntry;
// ANCHOR: custom_button // ANCHOR: custom_button
// Object holding the state // Object holding the state

View File

@ -3,7 +3,7 @@ mod imp;
use glib::Object; use glib::Object;
use gtk::glib; use gtk::glib;
use crate::{build_ui::{FstabEntry}, partitioning_page::create_parition_struct}; use crate::{build_ui::FstabEntry, partitioning_page::create_parition_struct};
glib::wrapper! { glib::wrapper! {
pub struct DriveMountRow(ObjectSubclass<imp::DriveMountRow>) pub struct DriveMountRow(ObjectSubclass<imp::DriveMountRow>)

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,8 @@
use crate::{build_ui::{BlockDevice, CrypttabEntry, FstabEntry, PikaKeymap, PikaLocale}, config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE}, installer_stack_page}; use crate::{
build_ui::{BlockDevice, CrypttabEntry, FstabEntry, PikaKeymap, PikaLocale},
config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE},
installer_stack_page,
};
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{gio, glib}; use gtk::{gio, glib};
@ -8,7 +12,7 @@ pub fn installation_summary_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,
language_changed_action: &gio::SimpleAction, language_changed_action: &gio::SimpleAction,
page_done_action: &gio::SimpleAction, page_done_action: &gio::SimpleAction,
language_summary_text_refcell: &Rc<RefCell<PikaLocale>>, language_selection_text_refcell: &Rc<RefCell<PikaLocale>>,
keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>, keymap_selection_text_refcell: &Rc<RefCell<PikaKeymap>>,
timezone_selection_text_refcell: &Rc<RefCell<String>>, timezone_selection_text_refcell: &Rc<RefCell<String>>,
partition_method_type_refcell: &Rc<RefCell<String>>, partition_method_type_refcell: &Rc<RefCell<String>>,
@ -20,7 +24,7 @@ pub fn installation_summary_page(
partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>, partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>,
partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>, partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>, partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>> partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
) { ) {
let installation_summary_page = installer_stack_page::InstallerStackPage::new(); let installation_summary_page = installer_stack_page::InstallerStackPage::new();
installation_summary_page.set_page_icon("dialog-warning-symbolic"); installation_summary_page.set_page_icon("dialog-warning-symbolic");
@ -72,7 +76,7 @@ pub fn installation_summary_page(
#[strong] #[strong]
installation_summary_row_viewport_listbox, installation_summary_row_viewport_listbox,
#[strong] #[strong]
language_summary_text_refcell, language_selection_text_refcell,
#[strong] #[strong]
keymap_selection_text_refcell, keymap_selection_text_refcell,
#[strong] #[strong]
@ -108,7 +112,7 @@ pub fn installation_summary_page(
// //
let install_confirm_detail_language = adw::ActionRow::builder() let install_confirm_detail_language = adw::ActionRow::builder()
.title(t!("install_confirm_detail_language_title")) .title(t!("install_confirm_detail_language_title"))
.subtitle(&language_summary_text_refcell.borrow().pretty_name) .subtitle(&language_selection_text_refcell.borrow().pretty_name)
.build(); .build();
install_confirm_detail_language.add_css_class("property"); install_confirm_detail_language.add_css_class("property");
installation_summary_row_viewport_listbox.append(&install_confirm_detail_language); installation_summary_row_viewport_listbox.append(&install_confirm_detail_language);

View File

@ -71,7 +71,7 @@ pub fn keyboard_page(
let mut sorted_keymap_vec = Vec::new(); let mut sorted_keymap_vec = Vec::new();
for keymap in keymap_list.iter() { for keymap in keymap_list.iter() {
sorted_keymap_vec.push(PikaKeymap{ sorted_keymap_vec.push(PikaKeymap {
name: keymap.to_string(), name: keymap.to_string(),
pretty_name: xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string(), pretty_name: xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string(),
variant: { variant: {
@ -91,7 +91,7 @@ pub fn keyboard_page(
} else { } else {
Some(keymap_variant) Some(keymap_variant)
} }
} },
}) })
} }
sorted_keymap_vec.sort_by_key(|k| k.pretty_name.clone()); sorted_keymap_vec.sort_by_key(|k| k.pretty_name.clone());

View File

@ -84,11 +84,11 @@ pub fn language_page(
let mut sorted_locale_vec = Vec::new(); let mut sorted_locale_vec = Vec::new();
for locale in locale_list.iter() { for locale in locale_list.iter() {
sorted_locale_vec.push(PikaLocale{ sorted_locale_vec.push(PikaLocale {
name: locale.to_string(), name: locale.to_string(),
pretty_name: gnome_desktop::language_from_locale(&locale, None) pretty_name: gnome_desktop::language_from_locale(&locale, None)
.unwrap_or(locale.clone().into()) .unwrap_or(locale.clone().into())
.to_string() .to_string(),
}) })
} }
sorted_locale_vec.sort_by_key(|k| k.pretty_name.clone()); sorted_locale_vec.sort_by_key(|k| k.pretty_name.clone());

View File

@ -4,23 +4,23 @@ use std::env;
mod build_ui; mod build_ui;
mod config; mod config;
// //
mod installer_stack_page;
mod drive_mount_row; mod drive_mount_row;
mod installer_stack_page;
// //
mod welcome_page;
mod efi_error_page; mod efi_error_page;
mod welcome_page;
// //
mod eula_page; mod eula_page;
mod keyboard_page; mod keyboard_page;
mod language_page; mod language_page;
mod timezone_page; mod timezone_page;
// //
mod partitioning_page;
mod automatic_partitioning_page; mod automatic_partitioning_page;
mod manual_partitioning_page; mod manual_partitioning_page;
mod partitioning_page;
// //
mod installation_summary_page;
mod installation_progress_page; mod installation_progress_page;
mod installation_summary_page;
#[macro_use] #[macro_use]
extern crate rust_i18n; extern crate rust_i18n;

View File

@ -1,19 +1,8 @@
use crate::drive_mount_row::DriveMountRow; use crate::drive_mount_row::DriveMountRow;
use crate::{ use crate::{
build_ui::{ build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration},
CrypttabEntry, config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE, MINIMUM_ROOT_BYTE_SIZE},
FstabEntry, partitioning_page::get_partitions,
Partition,
SubvolDeclaration
},
partitioning_page::{
get_partitions
},
config::{
MINIMUM_EFI_BYTE_SIZE,
MINIMUM_BOOT_BYTE_SIZE,
MINIMUM_ROOT_BYTE_SIZE,
}
}; };
use adw::gio; use adw::gio;
use adw::prelude::*; use adw::prelude::*;
@ -222,13 +211,13 @@ pub fn create_efi_row(
row, row,
move |_| { move |_| {
if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") { if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") {
(*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration{ (*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration {
part_name: Rc::new(RefCell::new(row.partition())), part_name: Rc::new(RefCell::new(row.partition())),
made_by: Rc::new(RefCell::new(row.id())) made_by: Rc::new(RefCell::new(row.id())),
} });
);
} else { } else {
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| *x.made_by.borrow() != row.id()); (*subvol_partition_array_refcell.borrow_mut())
.retain(|x| *x.made_by.borrow() != row.id());
} }
partition_changed_action.activate(None); partition_changed_action.activate(None);
} }
@ -449,13 +438,13 @@ pub fn create_boot_row(
row, row,
move |_| { move |_| {
if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") { if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") {
(*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration{ (*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration {
part_name: Rc::new(RefCell::new(row.partition())), part_name: Rc::new(RefCell::new(row.partition())),
made_by: Rc::new(RefCell::new(row.id())) made_by: Rc::new(RefCell::new(row.id())),
} });
);
} else { } else {
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| *x.made_by.borrow() != row.id()); (*subvol_partition_array_refcell.borrow_mut())
.retain(|x| *x.made_by.borrow() != row.id());
} }
partition_changed_action.activate(None); partition_changed_action.activate(None);
} }
@ -681,13 +670,13 @@ pub fn create_root_row(
row, row,
move |_| { move |_| {
if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") { if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") {
(*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration{ (*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration {
part_name: Rc::new(RefCell::new(row.partition())), part_name: Rc::new(RefCell::new(row.partition())),
made_by: Rc::new(RefCell::new(row.id())) made_by: Rc::new(RefCell::new(row.id())),
} });
);
} else { } else {
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| *x.made_by.borrow() != row.id()); (*subvol_partition_array_refcell.borrow_mut())
.retain(|x| *x.made_by.borrow() != row.id());
} }
partition_changed_action.activate(None); partition_changed_action.activate(None);
} }
@ -877,13 +866,13 @@ pub fn create_mount_row(
row, row,
move |_| { move |_| {
if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") { if row.mountopts().contains("subvol=") || row.mountopts().contains("subvolid") {
(*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration{ (*subvol_partition_array_refcell.borrow_mut()).push(SubvolDeclaration {
part_name: Rc::new(RefCell::new(row.partition())), part_name: Rc::new(RefCell::new(row.partition())),
made_by: Rc::new(RefCell::new(row.id())) made_by: Rc::new(RefCell::new(row.id())),
} });
);
} else { } else {
(*subvol_partition_array_refcell.borrow_mut()).retain(|x| *x.made_by.borrow() != row.id()); (*subvol_partition_array_refcell.borrow_mut())
.retain(|x| *x.made_by.borrow() != row.id());
} }
partition_changed_action.activate(None); partition_changed_action.activate(None);
} }
@ -1053,7 +1042,9 @@ fn post_check_drive_mount(
if used_partition_array.iter().any(|e| { if used_partition_array.iter().any(|e| {
(part_name == &e.partition.part_name && part_name != &row.partition()) (part_name == &e.partition.part_name && part_name != &row.partition())
&& (subvol_partition_array.iter().any(|e| *e.part_name.borrow() == *part_name)) && (subvol_partition_array
.iter()
.any(|e| *e.part_name.borrow() == *part_name))
}) { }) {
if *partition_row_struct.never.borrow() == false if *partition_row_struct.never.borrow() == false
&& *partition_row_struct.swap_fs_error.borrow() == false && *partition_row_struct.swap_fs_error.borrow() == false
@ -1065,7 +1056,9 @@ fn post_check_drive_mount(
} else if used_partition_array.iter().any(|e| { } else if used_partition_array.iter().any(|e| {
part_name == &e.partition.part_name part_name == &e.partition.part_name
&& e.used_by != row.id() && e.used_by != row.id()
&& !subvol_partition_array.iter().any(|e| *e.part_name.borrow() == *part_name) && !subvol_partition_array
.iter()
.any(|e| *e.part_name.borrow() == *part_name)
}) { }) {
if &row.partition() == part_name { if &row.partition() == part_name {
null_checkbutton.set_active(true); null_checkbutton.set_active(true);

View File

@ -1,12 +1,16 @@
use crate::drive_mount_row::DriveMountRow; use crate::drive_mount_row::DriveMountRow;
use crate::{build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}, installer_stack_page, partitioning_page::{get_partitions, get_luks_uuid, test_luks_passwd}}; use crate::{
build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration},
installer_stack_page,
partitioning_page::{get_luks_uuid, get_partitions, test_luks_passwd},
};
use adw::gio; use adw::gio;
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{glib, Orientation}; use gtk::{glib, Orientation};
use std::{cell::RefCell, collections::HashSet, rc::Rc};
use std::sync::Arc;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::{cell::RefCell, collections::HashSet, rc::Rc};
mod func; mod func;
@ -30,13 +34,13 @@ pub fn manual_partitioning_page(
let partition_array_refcell = Rc::new(RefCell::new(get_partitions())); let partition_array_refcell = Rc::new(RefCell::new(get_partitions()));
let used_partition_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::default()); let used_partition_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::default());
let subvol_partition_array_refcell: Rc<RefCell<Vec<SubvolDeclaration>>> = Rc::new(RefCell::default()); let subvol_partition_array_refcell: Rc<RefCell<Vec<SubvolDeclaration>>> =
Rc::new(RefCell::default());
let extra_mount_id_refcell: Rc<RefCell<i32>> = Rc::new(RefCell::new(3)); let extra_mount_id_refcell: Rc<RefCell<i32>> = Rc::new(RefCell::new(3));
// //
let partition_changed_action = let partition_changed_action = gio::SimpleAction::new("partition-changed", None);
gio::SimpleAction::new("partition-changed", None);
// //
@ -281,12 +285,10 @@ pub fn manual_partitioning_page(
} else { } else {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
partition_method_manual_mountpoint_invalid_error_label.set_visible(true); partition_method_manual_mountpoint_invalid_error_label.set_visible(true);
} }
if fs_entry.partition.part_name.is_empty() { if fs_entry.partition.part_name.is_empty() {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
partition_method_manual_partition_empty_error_label.set_visible(true); partition_method_manual_partition_empty_error_label.set_visible(true);
} }
if !seen_mountpoints.insert(fs_entry.clone().mountpoint) { if !seen_mountpoints.insert(fs_entry.clone().mountpoint) {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
@ -324,7 +326,13 @@ pub fn manual_partitioning_page(
while let Ok(state) = check_delay_receiver.recv().await { while let Ok(state) = check_delay_receiver.recv().await {
if state.load(std::sync::atomic::Ordering::Relaxed) == false { if state.load(std::sync::atomic::Ordering::Relaxed) == false {
partition_method_manual_valid_label.set_visible(true); partition_method_manual_valid_label.set_visible(true);
set_crypttab_entries(&fs_entry_clone0, &seen_crypts, window.clone(), &partition_method_manual_crypttab_entry_array_refcell, &partition_method_manual_luks_enabled_refcell); set_crypttab_entries(
&fs_entry_clone0,
&seen_crypts,
window.clone(),
&partition_method_manual_crypttab_entry_array_refcell,
&partition_method_manual_luks_enabled_refcell,
);
manual_partitioning_page.set_next_sensitive(true); manual_partitioning_page.set_next_sensitive(true);
} }
} }
@ -415,15 +423,25 @@ pub fn manual_partitioning_page(
manual_partitioning_page.set_back_tooltip_label(t!("back")); manual_partitioning_page.set_back_tooltip_label(t!("back"));
manual_partitioning_page.set_next_tooltip_label(t!("next")); manual_partitioning_page.set_next_tooltip_label(t!("next"));
// //
partition_method_manual_mountpoint_empty_error_label.set_label(&t!("partition_method_manual_mountpoint_empty_error_label_label")); partition_method_manual_mountpoint_empty_error_label.set_label(&t!(
partition_method_manual_mountpoint_invalid_error_label.set_label(&t!("partition_method_manual_mountpoint_invalid_error_label_label")); "partition_method_manual_mountpoint_empty_error_label_label"
partition_method_manual_partition_empty_error_label.set_label(&t!("partition_method_manual_partition_empty_error_label_label")); ));
partition_method_manual_mountpoint_duplicate_label.set_label(&t!("partition_method_manual_mountpoint_duplicate_label_label")); partition_method_manual_mountpoint_invalid_error_label.set_label(&t!(
partition_method_manual_valid_label.set_label(&t!("partition_method_manual_valid_label_label")); "partition_method_manual_mountpoint_invalid_error_label_label"
));
partition_method_manual_partition_empty_error_label.set_label(&t!(
"partition_method_manual_partition_empty_error_label_label"
));
partition_method_manual_mountpoint_duplicate_label.set_label(&t!(
"partition_method_manual_mountpoint_duplicate_label_label"
));
partition_method_manual_valid_label
.set_label(&t!("partition_method_manual_valid_label_label"));
// //
open_disk_utility_button.set_label(&t!("open_disk_utility_button_label")); open_disk_utility_button.set_label(&t!("open_disk_utility_button_label"));
filesystem_table_refresh_button.set_label(&t!("filesystem_table_refresh_button_label")); filesystem_table_refresh_button.set_label(&t!("filesystem_table_refresh_button_label"));
filesystem_table_validate_button.set_label(&t!("filesystem_table_validate_button_label")) filesystem_table_validate_button
.set_label(&t!("filesystem_table_validate_button_label"))
} }
)); ));
// //
@ -544,10 +562,10 @@ fn set_crypttab_entries(
window: adw::ApplicationWindow, window: adw::ApplicationWindow,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>, partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>, partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
) { ) {
if fs_entry.partition.has_encryption if fs_entry.partition.has_encryption
&& (*seen_crypts.borrow_mut()).insert(fs_entry.clone().partition.part_name) && (*seen_crypts.borrow_mut()).insert(fs_entry.clone().partition.part_name)
{ {
let fs_entry = fs_entry.clone(); let fs_entry = fs_entry.clone();
let (luks_manual_password_sender, luks_manual_password_receiver) = let (luks_manual_password_sender, luks_manual_password_receiver) =
async_channel::unbounded::<bool>(); async_channel::unbounded::<bool>();
@ -557,11 +575,19 @@ fn set_crypttab_entries(
.margin_start(10) .margin_start(10)
.margin_end(10) .margin_end(10)
.build(); .build();
let crypttab_password_status_label = gtk::Label::builder() let crypttab_password_status_label = gtk::Label::builder().build();
.build();
crypttab_password_listbox.add_css_class("boxed-list"); crypttab_password_listbox.add_css_class("boxed-list");
let crypttab_password_entry_row = adw::PasswordEntryRow::builder() let crypttab_password_entry_row = adw::PasswordEntryRow::builder()
.title(strfmt::strfmt(&t!("crypttab_password_entry_row_title"), &std::collections::HashMap::from([("LUKS_NAME".to_string(), fs_entry.clone().partition.part_name)])).unwrap()) .title(
strfmt::strfmt(
&t!("crypttab_password_entry_row_title"),
&std::collections::HashMap::from([(
"LUKS_NAME".to_string(),
fs_entry.clone().partition.part_name,
)]),
)
.unwrap(),
)
.build(); .build();
crypttab_password_entry_row.set_show_apply_button(true); crypttab_password_entry_row.set_show_apply_button(true);
crypttab_password_listbox.append(&crypttab_password_entry_row); crypttab_password_listbox.append(&crypttab_password_entry_row);
@ -574,11 +600,25 @@ fn set_crypttab_entries(
.extra_child(&crypttab_password_child_box) .extra_child(&crypttab_password_child_box)
.width_request(400) .width_request(400)
.height_request(200) .height_request(200)
.heading(strfmt::strfmt(&t!("crypttab_password_entry_row_title"), &std::collections::HashMap::from([("LUKS_NAME".to_string(), fs_entry.clone().partition.part_name)])).unwrap()) .heading(
strfmt::strfmt(
&t!("crypttab_password_entry_row_title"),
&std::collections::HashMap::from([(
"LUKS_NAME".to_string(),
fs_entry.clone().partition.part_name,
)]),
)
.unwrap(),
)
.build(); .build();
crypttab_dialog crypttab_dialog.add_response(
.add_response("crypttab_dialog_boot", &t!("crypttab_dialog_response_crypttab_dialog_boot")); "crypttab_dialog_boot",
crypttab_dialog.add_response("crypttab_dialog_auto", &t!("crypttab_dialog_response_crypttab_dialog_auto")); &t!("crypttab_dialog_response_crypttab_dialog_boot"),
);
crypttab_dialog.add_response(
"crypttab_dialog_auto",
&t!("crypttab_dialog_response_crypttab_dialog_auto"),
);
crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false); crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false);
crypttab_password_entry_row.connect_apply(clone!( crypttab_password_entry_row.connect_apply(clone!(
#[weak] #[weak]
@ -595,7 +635,8 @@ fn set_crypttab_entries(
let fs_entry_clone1 = fs_entry.clone(); let fs_entry_clone1 = fs_entry.clone();
crypttab_password_status_label.set_label(&t!("crypttab_password_status_label_label_checking")); crypttab_password_status_label
.set_label(&t!("crypttab_password_status_label_label_checking"));
std::thread::spawn(move || { std::thread::spawn(move || {
luks_manual_password_sender luks_manual_password_sender
@ -618,7 +659,8 @@ fn set_crypttab_entries(
while let Ok(state) = luks_manual_password_receiver.recv().await { while let Ok(state) = luks_manual_password_receiver.recv().await {
crypttab_dialog.set_response_enabled("crypttab_dialog_auto", state); crypttab_dialog.set_response_enabled("crypttab_dialog_auto", state);
if state == false { if state == false {
crypttab_password_status_label.set_label(&t!("crypttab_password_status_label_label_wrong_password")) crypttab_password_status_label
.set_label(&t!("crypttab_password_status_label_label_wrong_password"))
} else { } else {
crypttab_password_status_label.set_label("") crypttab_password_status_label.set_label("")
} }
@ -634,25 +676,25 @@ fn set_crypttab_entries(
crypttab_dialog.choose(None::<&gio::Cancellable>, move |choice| { crypttab_dialog.choose(None::<&gio::Cancellable>, move |choice| {
let part_name = fs_entry.partition.part_name; let part_name = fs_entry.partition.part_name;
if choice == "crypttab_dialog_auto" { if choice == "crypttab_dialog_auto" {
(*partition_method_manual_crypttab_entry_array_refcell_clone0 (*partition_method_manual_crypttab_entry_array_refcell_clone0.borrow_mut()).push(
.borrow_mut()) CrypttabEntry {
.push(CrypttabEntry {
partition: part_name.clone(), partition: part_name.clone(),
map: part_name.replace("mapper/", ""), map: part_name.replace("mapper/", ""),
uuid: get_luks_uuid(&part_name), uuid: get_luks_uuid(&part_name),
password: Some(crypttab_password_entry_row.text().to_string()), password: Some(crypttab_password_entry_row.text().to_string()),
}); },
);
} else { } else {
(*partition_method_manual_crypttab_entry_array_refcell_clone0 (*partition_method_manual_crypttab_entry_array_refcell_clone0.borrow_mut()).push(
.borrow_mut()) CrypttabEntry {
.push(CrypttabEntry {
partition: part_name.clone(), partition: part_name.clone(),
map: part_name.replace("mapper/", ""), map: part_name.replace("mapper/", ""),
uuid: get_luks_uuid(&part_name), uuid: get_luks_uuid(&part_name),
password: None, password: None,
}); },
);
} }
(*partition_method_manual_luks_enabled_refcell_clone0.borrow_mut()) = true; (*partition_method_manual_luks_enabled_refcell_clone0.borrow_mut()) = true;
}); });
} }
} }

View File

@ -1,4 +1,8 @@
use crate::{build_ui::{FstabEntry, CrypttabEntry, BlockDevice, SubvolDeclaration, Partition}, installer_stack_page, automatic_partitioning_page, manual_partitioning_page}; use crate::{
automatic_partitioning_page,
build_ui::{BlockDevice, CrypttabEntry, FstabEntry, Partition, SubvolDeclaration},
installer_stack_page, manual_partitioning_page,
};
use glib::{clone, closure_local, Properties}; use glib::{clone, closure_local, Properties};
use gtk::{gio, glib, prelude::*}; use gtk::{gio, glib, prelude::*};
use std::io::BufRead; use std::io::BufRead;