From 20935ab35dbdcde4c9df43a917811d6943b8f670 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Thu, 22 Aug 2024 00:41:06 +0300 Subject: [PATCH] make data types location better --- src/build_ui.rs | 48 +++++++++++++++++++++++++++- src/installation_summary_page/mod.rs | 25 +++++++++------ src/main.rs | 19 ++++++----- src/manual_partitioning_page/func.rs | 7 ++-- src/manual_partitioning_page/mod.rs | 12 +++---- src/partitioning_page/mod.rs | 42 +----------------------- 6 files changed, 81 insertions(+), 72 deletions(-) diff --git a/src/build_ui.rs b/src/build_ui.rs index e1d3bc7..6f68afc 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -1,15 +1,21 @@ use crate::{ - config::APP_ID, efi_error_page, eula_page, keyboard_page, language_page, partitioning_page::{self, CrypttabEntry, FstabEntry}, timezone_page, welcome_page + config::APP_ID, efi_error_page, eula_page, keyboard_page, language_page, timezone_page, welcome_page, partitioning_page }; use gtk::{gio, glib, prelude::*}; use std::{cell::RefCell, path::Path, rc::Rc}; +// Custom Installer Data types + +/// Locale Data types + #[derive(Default, Clone, Debug)] pub struct PikaLocale { pub name: String, pub pretty_name: String } +/// Keyboard Data types + #[derive(Default, Clone, Debug)] pub struct PikaKeymap { pub name: String, @@ -17,6 +23,46 @@ pub struct PikaKeymap { pub pretty_name: String } +pub struct BlockDevice { + pub block_name: String, + pub block_size: f64, + pub block_size_pretty: String, +} + +/// Partitioning Data types + +#[derive(Default, Clone, Debug)] +pub struct Partition { + pub part_name: String, + pub part_fs: String, + pub part_uuid: String, + pub has_encryption: bool, + pub need_mapper: bool, + pub part_size: f64, + pub part_size_pretty: String, +} + +#[derive(Default, Clone, Debug)] +pub struct FstabEntry { + pub partition: Partition, + pub mountpoint: String, + pub mountopts: String, + pub used_by: i32, +} + +#[derive(Default, Clone, Debug)] +pub struct CrypttabEntry { + pub partition: String, + pub map: String, + pub uuid: String, + pub password: Option, +} + +pub struct SubvolDeclaration { + pub part_name: Rc>, + pub made_by: Rc>, +} + pub fn build_ui(app: &adw::Application) { glib::set_prgname(Some(t!("application_name").to_string())); glib::set_application_name(&t!("application_name")); diff --git a/src/installation_summary_page/mod.rs b/src/installation_summary_page/mod.rs index 80eb09c..379132f 100644 --- a/src/installation_summary_page/mod.rs +++ b/src/installation_summary_page/mod.rs @@ -1,20 +1,25 @@ -use crate::installer_stack_page; +use crate::{build_ui::{PikaLocale, PikaKeymap, FstabEntry, CrypttabEntry} installer_stack_page}; use adw::prelude::*; use glib::{clone, closure_local}; -use gnome_desktop::XkbInfoExt; -use gtk::{gio, glib, prelude::*}; +use gtk::{gio, glib}; use std::{cell::RefCell, fs, path::Path, process::Command, rc::Rc}; -struct PikaKeymap { - name: String, - pretty_name: String -} - pub fn keyboard_page( main_carousel: &adw::Carousel, - keymap_base_data_refcell: &Rc>, - keymap_variant_data_refcell: &Rc>, language_changed_action: &gio::SimpleAction, + language_selection_text_refcell: Rc>, + keymap_selection_text_refcell: Rc>, + timezone_selection_text_refcell: Rc>, + partition_method_type_refcell: Rc>, + partition_method_automatic_target_refcell: Rc>, + partition_method_automatic_target_fs_refcell: Rc>, + partition_method_automatic_luks_enabled_refcell: Rc>, + partition_method_automatic_luks_refcell: Rc>, + partition_method_automatic_ratio_refcell: Rc>, + partition_method_automatic_seperation_refcell: Rc>, + partition_method_manual_fstab_entry_array_refcell: Rc>>, + partition_method_manual_luks_enabled_refcell: Rc>, + partition_method_manual_crypttab_entry_array_refcell: Rc>> ) { let keyboard_page = installer_stack_page::InstallerStackPage::new(); keyboard_page.set_page_icon("keyboard-symbolic"); diff --git a/src/main.rs b/src/main.rs index 6555c2b..e3eb1d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,20 +3,23 @@ use gtk::{gdk, glib, prelude::*, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATIO use std::env; mod build_ui; mod config; -mod efi_error_page; -mod installer_stack_page; - // - -mod automatic_partitioning_page; +mod installer_stack_page; mod drive_mount_row; +// +mod welcome_page; +mod efi_error_page; +// mod eula_page; mod keyboard_page; mod language_page; -mod manual_partitioning_page; -mod partitioning_page; mod timezone_page; -mod welcome_page; +// +mod partitioning_page; +mod automatic_partitioning_page; +mod manual_partitioning_page; +// +mod installation_summary_page; #[macro_use] extern crate rust_i18n; diff --git a/src/manual_partitioning_page/func.rs b/src/manual_partitioning_page/func.rs index df2b273..55083e0 100644 --- a/src/manual_partitioning_page/func.rs +++ b/src/manual_partitioning_page/func.rs @@ -1,10 +1,9 @@ use crate::drive_mount_row::DriveMountRow; -use crate::installer_stack_page; -use crate::partitioning_page::{get_partitions, CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}; +use crate::{build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}, partitioning_page::{get_partitions}}; use adw::gio; use adw::prelude::*; -use glib::{clone, closure_local, ffi::gboolean}; -use gtk::{glib, prelude::*}; +use glib::{clone, closure_local}; +use gtk::glib; use std::{cell::RefCell, rc::Rc}; const MINIMUM_EFI_BYTE_SIZE: f64 = 500000000.0; diff --git a/src/manual_partitioning_page/mod.rs b/src/manual_partitioning_page/mod.rs index fbfe6dc..6c601e3 100644 --- a/src/manual_partitioning_page/mod.rs +++ b/src/manual_partitioning_page/mod.rs @@ -1,13 +1,9 @@ use crate::drive_mount_row::DriveMountRow; -use crate::installer_stack_page; -use crate::partitioning_page; -use crate::partitioning_page::get_luks_uuid; -use crate::partitioning_page::{get_partitions, CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}; +use crate::{build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}, installer_stack_page, partitioning_page::{get_partitions, get_luks_uuid, test_luks_passwd}}; use adw::gio; use adw::prelude::*; -use glib::{clone, closure_local, ffi::gboolean}; -use gtk::glib::Variant; -use gtk::{glib, prelude::*, Orientation}; +use glib::{clone, closure_local}; +use gtk::{glib, Orientation}; use std::{cell::RefCell, collections::HashSet, rc::Rc}; use std::sync::Arc; use std::sync::atomic::AtomicBool; @@ -599,7 +595,7 @@ fn set_crypttab_entries( std::thread::spawn(move || { luks_manual_password_sender - .send_blocking(partitioning_page::test_luks_passwd( + .send_blocking(test_luks_passwd( &fs_entry_clone1.partition.part_name, &luks_password, )) diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 5119b81..d96a4c5 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -1,6 +1,4 @@ -use crate::drive_mount_row::DriveMountRow; -use crate::installer_stack_page; -use crate::{automatic_partitioning_page, manual_partitioning_page}; +use crate::{build_ui::{FstabEntry, CrypttabEntry, BlockDevice, SubvolDeclaration, Partition}, installer_stack_page, automatic_partitioning_page, manual_partitioning_page}; use glib::{clone, closure_local, Properties}; use gtk::{gio, glib, prelude::*}; use std::io::BufRead; @@ -169,44 +167,6 @@ pub fn partitioning_page( main_carousel.append(&partitioning_carousel) } -pub struct BlockDevice { - pub block_name: String, - pub block_size: f64, - pub block_size_pretty: String, -} - -#[derive(Default, Clone, Debug)] -pub struct Partition { - pub part_name: String, - pub part_fs: String, - pub part_uuid: String, - pub has_encryption: bool, - pub need_mapper: bool, - pub part_size: f64, - pub part_size_pretty: String, -} - -#[derive(Default, Clone, Debug)] -pub struct FstabEntry { - pub partition: Partition, - pub mountpoint: String, - pub mountopts: String, - pub used_by: i32, -} - -#[derive(Default, Clone, Debug)] -pub struct CrypttabEntry { - pub partition: String, - pub map: String, - pub uuid: String, - pub password: Option, -} - -pub struct SubvolDeclaration { - pub part_name: Rc>, - pub made_by: Rc>, -} - pub fn get_block_devices() -> Vec { let mut block_devices = Vec::new();