make partition selection more intuitive
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 2m16s

This commit is contained in:
Ward from fusion-voyager-3 2024-10-11 23:51:38 +03:00
parent 93c4af1c05
commit 1af8042654
24 changed files with 1023 additions and 774 deletions

View File

@ -1 +1 @@
5 6

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
pika-installer-gtk4 (2.0.0-101pika6) pika; urgency=low
* Fix partition selection
-- Ward Nakchbandi <hotrod.master@hotmail.com> Thu, 20 Sep 2022 22:01:00 +0000
pika-installer-gtk4 (2.0.0-101pika5) pika; urgency=low pika-installer-gtk4 (2.0.0-101pika5) pika; urgency=low
* First Release of new installer * First Release of new installer

View File

@ -35,8 +35,9 @@
"eula_page_title": "EULA", "eula_page_title": "EULA",
"efi_error_header_text_label": "Un-Supported Boot Platform", "efi_error_header_text_label": "Un-Supported Boot Platform",
"efi_error_text_label": "PikaOS Only works on GPT UEFI Systems, This Machine is Booted in CSM/LEGACY mode.", "efi_error_text_label": "PikaOS Only works on GPT UEFI Systems, This Machine is Booted in CSM/LEGACY mode.",
"exit_button_label": "exit_button_label", "exit_button_label": "Exit",
"partition_row_expander_subtitle": "Partition", "partition_button_row_title": "Partition",
"partition_button_row_subtitle_none_selected": "No Partition Selected",
"mountpoint_entry_row_title": "Mountpoint\nE.g: /var", "mountpoint_entry_row_title": "Mountpoint\nE.g: /var",
"mountopts_entry_row_title": "Additional Mount Options\nE.g: subvol=@home", "mountopts_entry_row_title": "Additional Mount Options\nE.g: subvol=@home",
"automatic_partitioning_page_title": "Automatic Partitioning Installer", "automatic_partitioning_page_title": "Automatic Partitioning Installer",
@ -128,5 +129,7 @@
"installation_complete_page_subtitle_success": "The Installation of PikaOS Has Been Completed Sucessfully", "installation_complete_page_subtitle_success": "The Installation of PikaOS Has Been Completed Sucessfully",
"devices_selection_button_row_dialog_auto_title": "Automatic Partition Disk Selection", "devices_selection_button_row_dialog_auto_title": "Automatic Partition Disk Selection",
"devices_selection_button_row_dialog_auto_body": "Please Select A Disk for PikaOS to *Erase* And Install on.", "devices_selection_button_row_dialog_auto_body": "Please Select A Disk for PikaOS to *Erase* And Install on.",
"devices_selection_button_row_dialog_manual_title": "Manual Partition Disk Selection",
"devices_selection_button_row_dialog_manual_body": "Please Select a Partition for This Filesystem Mount",
"devices_selection_button_row_dialog_ok_label": "Done" "devices_selection_button_row_dialog_ok_label": "Done"
} }

View File

@ -3,8 +3,8 @@ use crate::config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE, MINIMUM_ROOT_
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 adw::prelude::*; use adw::prelude::*;
use gtk::{glib, gio};
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, rc::Rc}; use std::{cell::RefCell, rc::Rc};
pub fn automatic_partitioning_page( pub fn automatic_partitioning_page(
@ -262,6 +262,7 @@ pub fn automatic_partitioning_page(
devices_selection_button_row_listbox.add_css_class("boxed-list"); devices_selection_button_row_listbox.add_css_class("boxed-list");
let devices_selection_button_row = adw::ButtonRow::builder() let devices_selection_button_row = adw::ButtonRow::builder()
.start_icon_name("drive-harddisk-symbolic")
.build(); .build();
devices_selection_button_row.add_css_class("accent-blink"); devices_selection_button_row.add_css_class("accent-blink");
@ -292,11 +293,18 @@ pub fn automatic_partitioning_page(
.height_request(400) .height_request(400)
.build(); .build();
devices_selection_button_row_dialog.add_response("devices_selection_button_row_dialog_ok", "devices_selection_button_row_dialog_ok"); devices_selection_button_row_dialog.add_response(
"devices_selection_button_row_dialog_ok",
"devices_selection_button_row_dialog_ok",
);
devices_selection_button_row.connect_activated(clone!(#[weak] devices_selection_button_row_dialog, move |_| { devices_selection_button_row.connect_activated(clone!(
devices_selection_button_row_dialog.present(Some(&window)); #[weak]
})); devices_selection_button_row_dialog,
move |_| {
devices_selection_button_row_dialog.present(Some(&window));
}
));
//devices_selection_button_row.add_row(&devices_selection_button_row_viewport); //devices_selection_button_row.add_row(&devices_selection_button_row_viewport);
@ -670,13 +678,17 @@ pub fn automatic_partitioning_page(
automatic_partitioning_page.set_back_tooltip_label(t!("back")); automatic_partitioning_page.set_back_tooltip_label(t!("back"));
automatic_partitioning_page.set_next_tooltip_label(t!("next")); automatic_partitioning_page.set_next_tooltip_label(t!("next"));
// //
devices_selection_button_row.set_title(&t!( devices_selection_button_row
"devices_selection_button_row_title_no_drive_selected" .set_title(&t!("devices_selection_button_row_title_no_drive_selected"));
));
// //
devices_selection_button_row_dialog.set_title(&t!("devices_selection_button_row_dialog_auto_title")); devices_selection_button_row_dialog
devices_selection_button_row_dialog.set_body(&t!("devices_selection_button_row_dialog_auto_body")); .set_title(&t!("devices_selection_button_row_dialog_auto_title"));
devices_selection_button_row_dialog.set_response_label("devices_selection_button_row_dialog_ok", &t!("devices_selection_button_row_dialog_ok_label")); devices_selection_button_row_dialog
.set_body(&t!("devices_selection_button_row_dialog_auto_body"));
devices_selection_button_row_dialog.set_response_label(
"devices_selection_button_row_dialog_ok",
&t!("devices_selection_button_row_dialog_ok_label"),
);
// //
partition_method_automatic_disk_nodisk_error_label.set_label(&t!( partition_method_automatic_disk_nodisk_error_label.set_label(&t!(
"partition_method_automatic_disk_nodisk_error_label_label" "partition_method_automatic_disk_nodisk_error_label_label"
@ -740,7 +752,13 @@ fn disk_check(
device_block_size: f64, device_block_size: f64,
) { ) {
if device_button.is_active() { if device_button.is_active() {
devices_selection_button_row.set_title(&(device_block_model.to_owned() + ": " + device_block_name + " " + device_block_size_pretty)); devices_selection_button_row.set_title(
&(device_block_model.to_owned()
+ ": "
+ device_block_name
+ " "
+ device_block_size_pretty),
);
devices_selection_button_row.remove_css_class("accent-blink"); devices_selection_button_row.remove_css_class("accent-blink");
if device_block_size >= MINIMUM_ROOT_BYTE_SIZE { if device_block_size >= MINIMUM_ROOT_BYTE_SIZE {
partition_method_automatic_disk_size_error_label.set_visible(false); partition_method_automatic_disk_size_error_label.set_visible(false);

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
config::APP_ID, efi_error_page, eula_page, installation_progress_page, config::APP_ID, efi_error_page, eula_page, installation_complete_page,
installation_summary_page, keyboard_page, language_page, partitioning_page, timezone_page, installation_complete_page, installation_progress_page, installation_summary_page, keyboard_page, language_page,
welcome_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};
@ -22,11 +22,11 @@ pub struct PikaLocale {
pub struct KBDMap { pub struct KBDMap {
pub console: String, pub console: String,
pub layout: String, pub layout: String,
pub variant: String pub variant: String,
} }
#[derive(Default, Clone, Debug)] #[derive(Default, Clone, Debug)]
pub struct PikaKeymap { pub struct PikaKeymap {
pub kbdmap: KBDMap, pub kbdmap: KBDMap,
pub pretty_name: String, pub pretty_name: String,
} }
@ -78,10 +78,13 @@ pub fn build_ui(app: &adw::Application) {
glib::set_application_name(&t!("application_name")); glib::set_application_name(&t!("application_name"));
let (installation_log_loop_sender, installation_log_loop_receiver) = async_channel::unbounded(); let (installation_log_loop_sender, installation_log_loop_receiver) = async_channel::unbounded();
let installation_log_loop_sender: async_channel::Sender<String> = installation_log_loop_sender.clone(); let installation_log_loop_sender: async_channel::Sender<String> =
installation_log_loop_sender.clone();
let (installation_log_status_loop_sender, installation_log_status_loop_receiver) = async_channel::unbounded(); let (installation_log_status_loop_sender, installation_log_status_loop_receiver) =
let installation_log_status_loop_sender: async_channel::Sender<bool> = installation_log_status_loop_sender.clone(); async_channel::unbounded();
let installation_log_status_loop_sender: async_channel::Sender<bool> =
installation_log_status_loop_sender.clone();
let carousel = adw::Carousel::builder() let carousel = adw::Carousel::builder()
.allow_long_swipes(false) .allow_long_swipes(false)
@ -208,9 +211,18 @@ pub fn build_ui(app: &adw::Application) {
&partition_method_manual_crypttab_entry_array_refcell, &partition_method_manual_crypttab_entry_array_refcell,
); );
installation_progress_page::installation_progress_page(&carousel, &language_changed_action, installation_log_loop_receiver); installation_progress_page::installation_progress_page(
&carousel,
&language_changed_action,
installation_log_loop_receiver,
);
installation_complete_page::installation_complete_page(&carousel, &window, &language_changed_action, installation_log_status_loop_receiver); installation_complete_page::installation_complete_page(
&carousel,
&window,
&language_changed_action,
installation_log_status_loop_receiver,
);
window.present() window.present()
} }

View File

@ -20,6 +20,8 @@ pub struct DriveMountRow {
#[property(get, set)] #[property(get, set)]
partitionscroll: Rc<RefCell<gtk::ScrolledWindow>>, partitionscroll: Rc<RefCell<gtk::ScrolledWindow>>,
#[property(get, set)] #[property(get, set)]
transient_for: Rc<RefCell<adw::ApplicationWindow>>,
#[property(get, set)]
sizegroup: RefCell<Option<gtk::SizeGroup>>, sizegroup: RefCell<Option<gtk::SizeGroup>>,
#[property(get, set)] #[property(get, set)]
langaction: RefCell<Option<gio::SimpleAction>>, langaction: RefCell<Option<gio::SimpleAction>>,
@ -51,6 +53,8 @@ impl ObjectImpl for DriveMountRow {
// `SYNC_CREATE` ensures that the label will be immediately set // `SYNC_CREATE` ensures that the label will be immediately set
let obj = self.obj(); let obj = self.obj();
let is_selected = Rc::new(RefCell::new(false));
let action_row_content_box = gtk::Box::builder() let action_row_content_box = gtk::Box::builder()
.orientation(Horizontal) .orientation(Horizontal)
.spacing(0) .spacing(0)
@ -58,7 +62,7 @@ impl ObjectImpl for DriveMountRow {
.hexpand(true) .hexpand(true)
.build(); .build();
let partition_row_expander_adw_listbox = gtk::ListBox::builder() let partition_button_row_adw_listbox = gtk::ListBox::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
@ -67,7 +71,7 @@ impl ObjectImpl for DriveMountRow {
.margin_start(5) .margin_start(5)
.margin_end(5) .margin_end(5)
.build(); .build();
partition_row_expander_adw_listbox.add_css_class("boxed-list"); partition_button_row_adw_listbox.add_css_class("boxed-list");
let mountpoint_entry_row_adw_listbox = gtk::ListBox::builder() let mountpoint_entry_row_adw_listbox = gtk::ListBox::builder()
.hexpand(true) .hexpand(true)
@ -93,9 +97,21 @@ impl ObjectImpl for DriveMountRow {
.build(); .build();
mountopts_entry_row_adw_listbox.add_css_class("boxed-list"); mountopts_entry_row_adw_listbox.add_css_class("boxed-list");
let partition_row_expander = adw::ExpanderRow::builder() let partition_button_row = adw::ActionRow::builder()
.subtitle(t!("partition_row_expander_subtitle")) .title(t!("partition_button_row_title"))
.subtitle(t!("partition_button_row_subtitle_none_selected"))
.hexpand(true)
.vexpand(true)
.build(); .build();
partition_button_row.add_prefix(&gtk::Image::from_icon_name("drive-harddisk-symbolic"));
let partition_button = gtk::Button::builder()
.valign(gtk::Align::Center)
.hexpand(true)
.vexpand(true)
.child(&partition_button_row)
.build();
partition_button.add_css_class("flat");
let mountpoint_entry_row = adw::EntryRow::builder() let mountpoint_entry_row = adw::EntryRow::builder()
.title(t!("mountpoint_entry_row_title")) .title(t!("mountpoint_entry_row_title"))
@ -138,6 +154,24 @@ impl ObjectImpl for DriveMountRow {
.bidirectional() .bidirectional()
.build(); .build();
obj.connect_partition_notify(clone!(
#[strong]
is_selected,
#[strong]
partition_button_row,
move |obj| {
let partition = obj.property::<String>("partition");
let is_empty = partition.trim().is_empty();
*is_selected.borrow_mut() = !is_empty;
if is_empty {
partition_button_row
.set_subtitle(&t!("partition_button_row_subtitle_none_selected"));
} else {
partition_button_row.set_subtitle(&partition);
}
}
));
partition_row_delete_button.connect_clicked(clone!( partition_row_delete_button.connect_clicked(clone!(
#[weak] #[weak]
obj, obj,
@ -148,7 +182,7 @@ impl ObjectImpl for DriveMountRow {
// //
partition_row_expander_adw_listbox.append(&partition_row_expander); partition_button_row_adw_listbox.append(&partition_button);
mountpoint_entry_row_adw_listbox.append(&mountpoint_entry_row); mountpoint_entry_row_adw_listbox.append(&mountpoint_entry_row);
@ -156,7 +190,7 @@ impl ObjectImpl for DriveMountRow {
// //
action_row_content_box.append(&partition_row_expander_adw_listbox); action_row_content_box.append(&partition_button_row_adw_listbox);
action_row_content_box.append(&mountpoint_entry_row_adw_listbox); action_row_content_box.append(&mountpoint_entry_row_adw_listbox);
@ -168,27 +202,54 @@ impl ObjectImpl for DriveMountRow {
#[weak] #[weak]
obj, obj,
#[weak] #[weak]
partition_row_expander_adw_listbox, partition_button_row_adw_listbox,
#[weak] #[weak]
mountpoint_entry_row_adw_listbox, mountpoint_entry_row_adw_listbox,
#[weak] #[weak]
mountopts_entry_row_adw_listbox, mountopts_entry_row_adw_listbox,
move |_| { move |_| {
if let Some(t) = obj.sizegroup() { if let Some(t) = obj.sizegroup() {
t.add_widget(&partition_row_expander_adw_listbox); t.add_widget(&partition_button_row_adw_listbox);
t.add_widget(&mountpoint_entry_row_adw_listbox); t.add_widget(&mountpoint_entry_row_adw_listbox);
t.add_widget(&mountopts_entry_row_adw_listbox); t.add_widget(&mountopts_entry_row_adw_listbox);
} }
} }
)); ));
let partition_button_row_dialog_extra_child = adw::Bin::new();
let partition_button_row_dialog = adw::AlertDialog::builder()
.extra_child(&partition_button_row_dialog_extra_child)
.width_request(400)
.height_request(400)
.title(t!("devices_selection_button_row_dialog_manual_title"))
.body(t!("devices_selection_button_row_dialog_manual_body"))
.build();
partition_button_row_dialog.add_response(
"devices_selection_button_row_dialog_ok",
"devices_selection_button_row_dialog_ok_label",
);
partition_button.connect_clicked(clone!(
#[strong]
obj,
#[strong]
partition_button_row_dialog,
move |_| {
partition_button_row_dialog.present(Some(
&obj.property::<adw::ApplicationWindow>("transient_for"),
));
}
));
// Bind label to number // Bind label to number
// `SYNC_CREATE` ensures that the label will be immediately set // `SYNC_CREATE` ensures that the label will be immediately set
let obj = self.obj(); let obj = self.obj();
obj.bind_property("partition", &partition_row_expander, "title") /*obj.bind_property("partition", &partition_button_row, "subtitle")
.sync_create() .sync_create()
.bidirectional() .bidirectional()
.build(); .build();*/
obj.bind_property("mountpoint", &mountpoint_entry_row, "text") obj.bind_property("mountpoint", &mountpoint_entry_row, "text")
.sync_create() .sync_create()
@ -204,10 +265,11 @@ impl ObjectImpl for DriveMountRow {
#[weak] #[weak]
obj, obj,
#[weak] #[weak]
partition_row_expander, partition_button_row_dialog_extra_child,
move |_| { move |_| {
partition_row_expander partition_button_row_dialog_extra_child.set_child(Some(
.add_row(&obj.property::<gtk::ScrolledWindow>("partitionscroll")); &obj.property::<gtk::ScrolledWindow>("partitionscroll"),
));
} }
)); ));
@ -215,25 +277,45 @@ impl ObjectImpl for DriveMountRow {
#[weak] #[weak]
obj, obj,
#[weak] #[weak]
partition_row_expander, partition_button_row,
#[weak] #[weak]
mountpoint_entry_row, mountpoint_entry_row,
#[weak] #[weak]
mountopts_entry_row, mountopts_entry_row,
#[weak]
partition_button_row_dialog,
#[strong]
is_selected,
move |_| { move |_| {
if let Some(t) = obj.langaction() { if let Some(t) = obj.langaction() {
t.connect_activate(clone!( t.connect_activate(clone!(
#[weak] #[weak]
partition_row_expander, partition_button_row,
#[weak] #[weak]
mountpoint_entry_row, mountpoint_entry_row,
#[weak] #[weak]
mountopts_entry_row, mountopts_entry_row,
#[weak]
partition_button_row_dialog,
#[strong]
is_selected,
move |_, _| { move |_, _| {
partition_row_expander if !*is_selected.borrow() {
.set_subtitle(&t!("partition_row_expander_subtitle")); partition_button_row.set_subtitle(&t!(
"partition_button_row_subtitle_none_selected"
));
}
mountpoint_entry_row.set_title(&t!("mountpoint_entry_row_title")); mountpoint_entry_row.set_title(&t!("mountpoint_entry_row_title"));
mountopts_entry_row.set_title(&t!("mountopts_entry_row_title")); mountopts_entry_row.set_title(&t!("mountopts_entry_row_title"));
//
partition_button_row_dialog
.set_title(&t!("devices_selection_button_row_dialog_manual_title"));
partition_button_row_dialog
.set_body(&t!("devices_selection_button_row_dialog_manual_body"));
partition_button_row_dialog.set_response_label(
"devices_selection_button_row_dialog_ok",
&t!("devices_selection_button_row_dialog_ok_label"),
);
} }
)); ));
} }

View File

@ -15,9 +15,13 @@ impl DriveMountRow {
pub fn new() -> Self { pub fn new() -> Self {
Object::builder().build() Object::builder().build()
} }
pub fn new_with_scroll(partitions_scroll: &gtk::ScrolledWindow) -> Self { pub fn new_with_widgets(
partitions_scroll: &gtk::ScrolledWindow,
parent_window: &adw::ApplicationWindow,
) -> Self {
Object::builder() Object::builder()
.property("partitionscroll", partitions_scroll) .property("partitionscroll", partitions_scroll)
.property("transient-for", parent_window)
.build() .build()
} }
pub fn get_fstab_entry(&self) -> FstabEntry { pub fn get_fstab_entry(&self) -> FstabEntry {

View File

@ -1,7 +1,7 @@
use crate::{config::LOG_FILE_PATH, installer_stack_page}; use crate::{config::LOG_FILE_PATH, installer_stack_page};
use adw::prelude::*; use adw::prelude::*;
use gtk::{gio, glib};
use glib::clone; use glib::clone;
use gtk::{gio, glib};
use std::process::Command; use std::process::Command;
pub fn installation_complete_page( pub fn installation_complete_page(
@ -11,7 +11,7 @@ pub fn installation_complete_page(
installation_log_status_loop_receiver: async_channel::Receiver<bool>, installation_log_status_loop_receiver: async_channel::Receiver<bool>,
) { ) {
let installation_complete_page = installer_stack_page::InstallerStackPage::new(); let installation_complete_page = installer_stack_page::InstallerStackPage::new();
let content_box = gtk::Box::builder() let content_box = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal) .orientation(gtk::Orientation::Horizontal)
.homogeneous(true) .homogeneous(true)
@ -52,55 +52,52 @@ pub fn installation_complete_page(
let installation_status_context = glib::MainContext::default(); let installation_status_context = glib::MainContext::default();
// The main loop executes the asynchronous block // The main loop executes the asynchronous block
installation_status_context.spawn_local( installation_status_context.spawn_local(clone!(
clone!( #[strong]
#[strong] main_carousel,
main_carousel, #[strong]
#[strong] installation_complete_page,
installation_complete_page, #[strong]
#[strong] installation_log_status_loop_receiver,
installation_log_status_loop_receiver, async move {
async move while let Ok(state) = installation_log_status_loop_receiver.recv().await {
{ main_carousel.scroll_to(&installation_complete_page, true);
while let Ok(state) = installation_log_status_loop_receiver.recv().await { match state {
main_carousel.scroll_to(&installation_complete_page, true); true => {
match state { installation_complete_page.set_page_icon("emblem-ok-symbolic");
true => { installation_complete_page.set_back_visible(false);
installation_complete_page.set_page_icon("emblem-ok-symbolic"); installation_complete_page.set_next_visible(false);
installation_complete_page.set_back_visible(false); installation_complete_page.set_back_sensitive(false);
installation_complete_page.set_next_visible(false); installation_complete_page.set_next_sensitive(false);
installation_complete_page.set_back_sensitive(false); installation_complete_page
installation_complete_page.set_next_sensitive(false); .set_page_title(t!("installation_complete_page_title_success"));
installation_complete_page.set_page_title(t!("installation_complete_page_title_success")); installation_complete_page
installation_complete_page.set_page_subtitle(t!("installation_complete_page_subtitle_success")); .set_page_subtitle(t!("installation_complete_page_subtitle_success"));
}
false => {
installation_complete_page.set_page_icon("dialog-error-symbolic");
installation_complete_page.set_back_visible(false);
installation_complete_page.set_next_visible(false);
installation_complete_page.set_back_sensitive(false);
installation_complete_page.set_next_sensitive(false);
installation_complete_page.set_page_title(t!("installation_complete_page_title_failed"));
installation_complete_page.set_page_subtitle(t!("installation_complete_page_subtitle_failed"));
}
}
} }
false => {
installation_complete_page.set_page_icon("dialog-error-symbolic");
installation_complete_page.set_back_visible(false);
installation_complete_page.set_next_visible(false);
installation_complete_page.set_back_sensitive(false);
installation_complete_page.set_next_sensitive(false);
installation_complete_page
.set_page_title(t!("installation_complete_page_title_failed"));
installation_complete_page
.set_page_subtitle(t!("installation_complete_page_subtitle_failed"));
}
}
} }
) }
); ));
// //
installation_complete_exit_button.connect_clicked(clone!( installation_complete_exit_button.connect_clicked(clone!(
#[strong] #[strong]
window, window,
move |_| move |_| window.close()
{ ));
window.close()
}
)
);
installation_complete_reboot_button.connect_clicked(move |_| { installation_complete_reboot_button.connect_clicked(move |_| {
Command::new("reboot") Command::new("reboot")
.spawn() .spawn()
@ -127,9 +124,12 @@ pub fn installation_complete_page(
#[weak] #[weak]
installation_complete_view_logs_button, installation_complete_view_logs_button,
move |_, _| { move |_, _| {
installation_complete_exit_button.set_label(&t!("installation_complete_exit_button_label")); installation_complete_exit_button
installation_complete_reboot_button.set_label(&t!("installation_complete_reboot_button_label")); .set_label(&t!("installation_complete_exit_button_label"));
installation_complete_view_logs_button.set_label(&t!("installation_complete_view_logs_button_label")); installation_complete_reboot_button
.set_label(&t!("installation_complete_reboot_button_label"));
installation_complete_view_logs_button
.set_label(&t!("installation_complete_view_logs_button_label"));
} }
)); ));
// //

View File

@ -1,11 +1,10 @@
use crate::unix_socket_tools; use crate::unix_socket_tools;
use adw::prelude::*; use adw::prelude::*;
use gtk::{gio, glib};
use glib::{clone, GString}; use glib::{clone, GString};
use gtk::{gio, glib};
use std::thread; use std::thread;
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
pub fn installation_progress_page( pub fn installation_progress_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,
language_changed_action: &gio::SimpleAction, language_changed_action: &gio::SimpleAction,
@ -15,12 +14,14 @@ pub fn installation_progress_page(
let socket_status_sender: async_channel::Sender<String> = socket_status_sender.clone(); let socket_status_sender: async_channel::Sender<String> = socket_status_sender.clone();
thread::spawn(move || { thread::spawn(move || {
Runtime::new().unwrap().block_on(unix_socket_tools::start_socket_server( Runtime::new()
socket_status_sender, .unwrap()
"/tmp/pikainstall-status.sock", .block_on(unix_socket_tools::start_socket_server(
)); socket_status_sender,
"/tmp/pikainstall-status.sock",
));
}); });
let installation_progress_box = gtk::Box::builder() let installation_progress_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
.build(); .build();
@ -103,53 +104,55 @@ pub fn installation_progress_page(
// //
progress_log_button.connect_clicked( progress_log_button.connect_clicked(clone!(
clone!( #[weak]
#[weak] installation_progress_log_stack,
installation_progress_log_stack, move |_| {
move |_| if installation_progress_log_stack.visible_child_name()
== Some(GString::from_string_unchecked("slideshow_page".into()))
{ {
if installation_progress_log_stack.visible_child_name() == Some(GString::from_string_unchecked("slideshow_page".into())) { installation_progress_log_stack.set_visible_child_name("terminal_log_page");
installation_progress_log_stack.set_visible_child_name("terminal_log_page"); } else {
} else { installation_progress_log_stack.set_visible_child_name("slideshow_page");
installation_progress_log_stack.set_visible_child_name("slideshow_page");
}
} }
) }
); ));
// //
installation_progress_log_terminal_buffer.connect_changed(clone!( installation_progress_log_terminal_buffer.connect_changed(clone!(
#[weak] #[weak]
installation_progress_log_scroll, installation_progress_log_scroll,
move |_| move |_| {
if installation_progress_log_scroll.vadjustment().upper()
- installation_progress_log_scroll.vadjustment().value()
< (installation_progress_log_scroll.size(gtk::Orientation::Vertical) as f64 * 1.48)
{ {
if installation_progress_log_scroll.vadjustment().upper() - installation_progress_log_scroll.vadjustment().value() < (installation_progress_log_scroll.size(gtk::Orientation::Vertical) as f64 * 1.48 ) { installation_progress_log_scroll
installation_progress_log_scroll.vadjustment().set_value(installation_progress_log_scroll.vadjustment().upper()) .vadjustment()
} .set_value(installation_progress_log_scroll.vadjustment().upper())
} }
) }
); ));
// //
let installation_log_loop_context = glib::MainContext::default(); let installation_log_loop_context = glib::MainContext::default();
// The main loop executes the asynchronous block // The main loop executes the asynchronous block
installation_log_loop_context.spawn_local( installation_log_loop_context.spawn_local(clone!(
clone!( #[weak]
#[weak] installation_progress_log_terminal_buffer,
installation_progress_log_terminal_buffer, #[strong]
#[strong] installation_progress_log_terminal_buffer,
installation_progress_log_terminal_buffer, async move {
async move while let Ok(state) = installation_log_loop_receiver.recv().await {
{ installation_progress_log_terminal_buffer.insert(
while let Ok(state) = installation_log_loop_receiver.recv().await { &mut installation_progress_log_terminal_buffer.end_iter(),
installation_progress_log_terminal_buffer.insert(&mut installation_progress_log_terminal_buffer.end_iter(), &("\n".to_string() + &state)) &("\n".to_string() + &state),
} )
} }
) }
); ));
// //
@ -165,55 +168,68 @@ pub fn installation_progress_page(
match state.trim() { match state.trim() {
"PARTING" => { "PARTING" => {
installation_progress_bar.set_fraction(0.15); installation_progress_bar.set_fraction(0.15);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_parting"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_parting")));
} }
"IMAGE" => { "IMAGE" => {
installation_progress_bar.set_fraction(0.50); installation_progress_bar.set_fraction(0.50);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_image"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_image")));
} }
"FLAG" => { "FLAG" => {
installation_progress_bar.set_fraction(0.55); installation_progress_bar.set_fraction(0.55);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_flag"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_flag")));
} }
"BIND" => { "BIND" => {
installation_progress_bar.set_fraction(0.60); installation_progress_bar.set_fraction(0.60);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_bind"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_bind")));
} }
"ARCH_COPY" => { "ARCH_COPY" => {
installation_progress_bar.set_fraction(0.65); installation_progress_bar.set_fraction(0.65);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_arch_copy"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_arch_copy")));
} }
"ENCRYPTION" => { "ENCRYPTION" => {
installation_progress_bar.set_fraction(0.70); installation_progress_bar.set_fraction(0.70);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_encryption"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_encryption")));
} }
"SWAP" => { "SWAP" => {
installation_progress_bar.set_fraction(0.75); installation_progress_bar.set_fraction(0.75);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_swap"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_swap")));
} }
"GEN_FSTAB" => { "GEN_FSTAB" => {
installation_progress_bar.set_fraction(0.80); installation_progress_bar.set_fraction(0.80);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_gen_fstab"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_gen_fstab")));
} }
"LOCALE" => { "LOCALE" => {
installation_progress_bar.set_fraction(0.85); installation_progress_bar.set_fraction(0.85);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_locale"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_locale")));
} }
"BOOTLOADER" => { "BOOTLOADER" => {
installation_progress_bar.set_fraction(0.90); installation_progress_bar.set_fraction(0.90);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_bootloader"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_bootloader")));
} }
"LIVE_REMOVE" => { "LIVE_REMOVE" => {
installation_progress_bar.set_fraction(0.95); installation_progress_bar.set_fraction(0.95);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_live_remove"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_live_remove")));
} }
"BASIC_USER" => { "BASIC_USER" => {
installation_progress_bar.set_fraction(0.98); installation_progress_bar.set_fraction(0.98);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_basic_user"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_basic_user")));
} }
"UNBIND" => { "UNBIND" => {
installation_progress_bar.set_fraction(0.99); installation_progress_bar.set_fraction(0.99);
installation_progress_bar.set_text(Some(&t!("installation_progress_bar_text_unbind"))); installation_progress_bar
.set_text(Some(&t!("installation_progress_bar_text_unbind")));
} }
_ => {} _ => {}
} }
@ -232,4 +248,4 @@ pub fn installation_progress_page(
)); ));
main_carousel.append(&installation_progress_box); main_carousel.append(&installation_progress_box);
} }

View File

@ -1,13 +1,21 @@
use crate::{ use crate::{
build_ui::{BlockDevice, CrypttabEntry, FstabEntry, PikaKeymap, PikaLocale}, build_ui::{BlockDevice, CrypttabEntry, FstabEntry, PikaKeymap, PikaLocale},
config::{MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE, LOG_FILE_PATH}, config::{LOG_FILE_PATH, MINIMUM_BOOT_BYTE_SIZE, MINIMUM_EFI_BYTE_SIZE},
installer_stack_page, installer_stack_page,
}; };
use adw::prelude::*; use adw::prelude::*;
use gtk::{gio, glib};
use glib::{clone, closure_local};
use std::{cell::RefCell, fs, path::Path, rc::Rc, thread, io::{Write, prelude::*, BufReader}, error::Error};
use duct::cmd; use duct::cmd;
use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{
cell::RefCell,
error::Error,
fs,
io::{prelude::*, BufReader, Write},
path::Path,
rc::Rc,
thread,
};
mod script_gen; mod script_gen;
@ -36,7 +44,6 @@ fn run_install_process(
.send_blocking(line) .send_blocking(line)
.expect("Channel needs to be opened."); .expect("Channel needs to be opened.");
let mut log_file = fs::OpenOptions::new() let mut log_file = fs::OpenOptions::new()
.append(true) .append(true)
.open(log_file_path) .open(log_file_path)
.unwrap(); .unwrap();
@ -154,37 +161,42 @@ pub fn installation_summary_page(
partition_method_manual_luks_enabled_refcell, partition_method_manual_luks_enabled_refcell,
#[strong] #[strong]
partition_method_manual_crypttab_entry_array_refcell, partition_method_manual_crypttab_entry_array_refcell,
move |_| move |_| {
{ let cmd = script_gen::create_installation_script(
let cmd = script_gen::create_installation_script( &language_selection_text_refcell,
&language_selection_text_refcell, &keymap_selection_text_refcell,
&keymap_selection_text_refcell, &timezone_selection_text_refcell,
&timezone_selection_text_refcell, &partition_method_type_refcell,
&partition_method_type_refcell, &partition_method_automatic_target_refcell,
&partition_method_automatic_target_refcell, &partition_method_automatic_target_fs_refcell,
&partition_method_automatic_target_fs_refcell, &partition_method_automatic_luks_enabled_refcell,
&partition_method_automatic_luks_enabled_refcell, &partition_method_automatic_luks_refcell,
&partition_method_automatic_luks_refcell, &partition_method_automatic_ratio_refcell,
&partition_method_automatic_ratio_refcell, &partition_method_automatic_seperation_refcell,
&partition_method_automatic_seperation_refcell, &partition_method_manual_fstab_entry_array_refcell,
&partition_method_manual_fstab_entry_array_refcell, &partition_method_manual_luks_enabled_refcell,
&partition_method_manual_luks_enabled_refcell, &partition_method_manual_crypttab_entry_array_refcell,
&partition_method_manual_crypttab_entry_array_refcell,); );
let installation_log_loop_sender_clone0 = installation_log_loop_sender.clone(); let installation_log_loop_sender_clone0 = installation_log_loop_sender.clone();
let installation_log_status_loop_sender_clone0 = installation_log_status_loop_sender.clone(); let installation_log_status_loop_sender_clone0 =
thread::spawn(move || { installation_log_status_loop_sender.clone();
if Path::new(LOG_FILE_PATH).exists() { thread::spawn(move || {
fs::remove_file(LOG_FILE_PATH).expect("bad perms on log file"); if Path::new(LOG_FILE_PATH).exists() {
} fs::remove_file(LOG_FILE_PATH).expect("bad perms on log file");
match run_install_process(installation_log_loop_sender_clone0, &cmd, LOG_FILE_PATH) { }
Ok(_) => installation_log_status_loop_sender_clone0.send_blocking(true).expect("channel needs to be open"), match run_install_process(installation_log_loop_sender_clone0, &cmd, LOG_FILE_PATH)
Err(_) => installation_log_status_loop_sender_clone0.send_blocking(false).expect("channel needs to be open") {
} Ok(_) => installation_log_status_loop_sender_clone0
}); .send_blocking(true)
main_carousel.scroll_to(&main_carousel.nth_page(7), true); .expect("channel needs to be open"),
} Err(_) => installation_log_status_loop_sender_clone0
) .send_blocking(false)
); .expect("channel needs to be open"),
}
});
main_carousel.scroll_to(&main_carousel.nth_page(7), true);
}
));
// //

View File

@ -49,4 +49,4 @@ pikainstall -c "$PIKA_INSTALL_AUTO_LUKS_PASSWORD" -r "$PIKA_INSTALL_CHROOT_PATH"
else else
pikainstall -c "$PIKA_INSTALL_AUTO_LUKS_PASSWORD" -r "$PIKA_INSTALL_CHROOT_PATH" -l "$PIKA_INSTALL_LOCALE" -k "$PIKA_INSTALL_KEYMAP" -kl "$PIKA_INSTALL_XKB_LAYOUT" -t "$PIKA_INSTALL_TIMEZONE" -kv "$PIKA_INSTALL_XKB_VARIANT" pikainstall -c "$PIKA_INSTALL_AUTO_LUKS_PASSWORD" -r "$PIKA_INSTALL_CHROOT_PATH" -l "$PIKA_INSTALL_LOCALE" -k "$PIKA_INSTALL_KEYMAP" -kl "$PIKA_INSTALL_XKB_LAYOUT" -t "$PIKA_INSTALL_TIMEZONE" -kv "$PIKA_INSTALL_XKB_VARIANT"
fi fi
"###; "###;

View File

@ -58,7 +58,7 @@ fi
"###; "###;
pub const AUTOMATIC_HOME_SUBVOL_BTRFS_LOCKED_INSTALLATION_PROG: &str = r###" pub const AUTOMATIC_HOME_SUBVOL_BTRFS_LOCKED_INSTALLATION_PROG: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}' PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
@ -126,7 +126,7 @@ fi
// BTRFS WITH HOME PART // BTRFS WITH HOME PART
pub const AUTOMATIC_HOME_PART_BTRFS_OPEN_INSTALLATION_PROG: &str = r###" pub const AUTOMATIC_HOME_PART_BTRFS_OPEN_INSTALLATION_PROG: &str = r###"
PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB} PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB}
@ -197,7 +197,7 @@ fi
"###; "###;
pub const AUTOMATIC_HOME_PART_BTRFS_LOCKED_INSTALLATION_PROG: &str = r###" pub const AUTOMATIC_HOME_PART_BTRFS_LOCKED_INSTALLATION_PROG: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}' PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB} PIKA_INSTALL_AUTO_ROOT_SIZE={ROOT_PART_SIZE_AS_I64_MIB}
@ -279,7 +279,7 @@ fi
// BTRFS WITH NO HOME // BTRFS WITH NO HOME
pub const AUTOMATIC_HOME_NONE_BTRFS_OPEN_INSTALLATION_PROG: &str = r###" pub const AUTOMATIC_HOME_NONE_BTRFS_OPEN_INSTALLATION_PROG: &str = r###"
parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \ parted -s -a optimal /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK" mklabel gpt \
mkpart "linux-efi" 1MiB 500Mib \ mkpart "linux-efi" 1MiB 500Mib \
@ -333,7 +333,7 @@ fi
"###; "###;
pub const AUTOMATIC_HOME_NONE_BTRFS_LOCKED_INSTALLATION_PROG: &str = r###" pub const AUTOMATIC_HOME_NONE_BTRFS_LOCKED_INSTALLATION_PROG: &str = r###"
PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}' PIKA_INSTALL_AUTO_LUKS_PASSWORD='{AUTO_LUKS_PASSWORD}'
@ -390,4 +390,4 @@ mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"2 $PIKA_INSTALL_CHROOT_PATH/boot
mkdir -p $PIKA_INSTALL_CHROOT_PATH/boot/efi mkdir -p $PIKA_INSTALL_CHROOT_PATH/boot/efi
mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"1 $PIKA_INSTALL_CHROOT_PATH/boot/efi mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"1 $PIKA_INSTALL_CHROOT_PATH/boot/efi
fi fi
"###; "###;

View File

@ -216,4 +216,4 @@ mkdir -p $PIKA_INSTALL_CHROOT_PATH/boot/efi
mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"1 $PIKA_INSTALL_CHROOT_PATH/boot/efi mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"1 $PIKA_INSTALL_CHROOT_PATH/boot/efi
fi fi
"###; "###;

View File

@ -217,4 +217,4 @@ mkdir -p $PIKA_INSTALL_CHROOT_PATH/boot/efi
mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"1 $PIKA_INSTALL_CHROOT_PATH/boot/efi mount /dev/"$PIKA_INSTALL_AUTO_TARGET_DISK"1 $PIKA_INSTALL_CHROOT_PATH/boot/efi
fi fi
"###; "###;

View File

@ -46,4 +46,4 @@ pikainstall --manual 2 -r "$PIKA_INSTALL_CHROOT_PATH" -l "$PIKA_INSTALL_LOCALE"
else else
pikainstall --manual 2 -r "$PIKA_INSTALL_CHROOT_PATH" -l "$PIKA_INSTALL_LOCALE" -k "$PIKA_INSTALL_KEYMAP" -kl "$PIKA_INSTALL_XKB_LAYOUT" -t "$PIKA_INSTALL_TIMEZONE" -kv "$PIKA_INSTALL_XKB_VARIANT" pikainstall --manual 2 -r "$PIKA_INSTALL_CHROOT_PATH" -l "$PIKA_INSTALL_LOCALE" -k "$PIKA_INSTALL_KEYMAP" -kl "$PIKA_INSTALL_XKB_LAYOUT" -t "$PIKA_INSTALL_TIMEZONE" -kv "$PIKA_INSTALL_XKB_VARIANT"
fi fi
"###; "###;

View File

@ -46,23 +46,45 @@ pub fn create_installation_script(
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), ("CHROOT_PATH".to_string(), "/media/pikaos/installation"),
( (
"LOCALE".to_string(), "LOCALE".to_string(),
language_selection_text_refcell.borrow().name.replace("'", r###"'"'"'"###).as_str(), language_selection_text_refcell
.borrow()
.name
.replace("'", r###"'"'"'"###)
.as_str(),
), ),
( (
"KEYMAP".to_string(), "KEYMAP".to_string(),
keymap_selection_text_refcell.borrow().kbdmap.console.replace("'", r###"'"'"'"###).as_str(), keymap_selection_text_refcell
.borrow()
.kbdmap
.console
.replace("'", r###"'"'"'"###)
.as_str(),
), ),
( (
"XKB_LAYOUT".to_string(), "XKB_LAYOUT".to_string(),
keymap_selection_text_refcell.borrow().kbdmap.layout.replace("'", r###"'"'"'"###).as_str(), keymap_selection_text_refcell
.borrow()
.kbdmap
.layout
.replace("'", r###"'"'"'"###)
.as_str(),
), ),
( (
"XKB_VARIANT".to_string(), "XKB_VARIANT".to_string(),
keymap_selection_text_refcell.borrow().kbdmap.variant.replace("'", r###"'"'"'"###).as_str(), keymap_selection_text_refcell
.borrow()
.kbdmap
.variant
.replace("'", r###"'"'"'"###)
.as_str(),
), ),
( (
"TIMEZONE".to_string(), "TIMEZONE".to_string(),
timezone_selection_text_refcell.borrow().replace("'", r###"'"'"'"###).as_str(), timezone_selection_text_refcell
.borrow()
.replace("'", r###"'"'"'"###)
.as_str(),
), ),
]), ]),
) )
@ -76,21 +98,30 @@ pub fn create_installation_script(
// //
let automatic_standard_installation_format = strfmt::strfmt( let automatic_standard_installation_format = strfmt::strfmt(
auto_basic::AUTOMATIC_STANDARD_INSTALLATION_PROG, auto_basic::AUTOMATIC_STANDARD_INSTALLATION_PROG,
&std::collections::HashMap::from([ &std::collections::HashMap::from([(
( "AUTO_INSTALL_TARGET_DISK".to_string(),
"AUTO_INSTALL_TARGET_DISK".to_string(), partition_method_automatic_target_refcell
partition_method_automatic_target_refcell.borrow().block_name.replace("'", r###"'"'"'"###).as_str(), .borrow()
), .block_name
]), .replace("'", r###"'"'"'"###)
.as_str(),
)]),
) )
.unwrap(); .unwrap();
final_script.push_str(&automatic_standard_installation_format); final_script.push_str(&automatic_standard_installation_format);
// //
match &*partition_method_automatic_target_fs_refcell.borrow().as_str().to_lowercase() { match &*partition_method_automatic_target_fs_refcell
.borrow()
.as_str()
.to_lowercase()
{
"btrfs" => { "btrfs" => {
match partition_method_automatic_seperation_refcell.borrow().as_str() { match partition_method_automatic_seperation_refcell
.borrow()
.as_str()
{
"subvol" => { "subvol" => {
if is_encrypted { if is_encrypted {
final_script.push_str(&strfmt::strfmt( final_script.push_str(&strfmt::strfmt(
@ -168,11 +199,14 @@ pub fn create_installation_script(
.unwrap()); .unwrap());
} }
} }
_ => panic!() _ => panic!(),
} }
} }
"ext4" => { "ext4" => {
match partition_method_automatic_seperation_refcell.borrow().as_str() { match partition_method_automatic_seperation_refcell
.borrow()
.as_str()
{
"partition" => { "partition" => {
if is_encrypted { if is_encrypted {
final_script.push_str(&strfmt::strfmt( final_script.push_str(&strfmt::strfmt(
@ -191,17 +225,29 @@ pub fn create_installation_script(
) )
.unwrap()); .unwrap());
} else { } else {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
auto_ext4::AUTOMATIC_HOME_PART_EXT4_OPEN_INSTALLATION_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ auto_ext4::AUTOMATIC_HOME_PART_EXT4_OPEN_INSTALLATION_PROG,
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), &std::collections::HashMap::from([
( (
"ROOT_PART_SIZE_AS_I64_MIB".to_string(), "CHROOT_PATH".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(), "/media/pikaos/installation",
) ),
]), (
) "ROOT_PART_SIZE_AS_I64_MIB".to_string(),
.unwrap()); (partition_method_automatic_ratio_refcell
.borrow()
.round()
as i64
/ 1048576)
.to_string()
.replace("'", r###"'"'"'"###)
.as_str(),
),
]),
)
.unwrap(),
);
} }
} }
"none" => { "none" => {
@ -218,78 +264,122 @@ pub fn create_installation_script(
) )
.unwrap()); .unwrap());
} else { } else {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
auto_ext4::AUTOMATIC_HOME_NONE_EXT4_OPEN_INSTALLATION_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ auto_ext4::AUTOMATIC_HOME_NONE_EXT4_OPEN_INSTALLATION_PROG,
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), &std::collections::HashMap::from([(
]), "CHROOT_PATH".to_string(),
) "/media/pikaos/installation",
.unwrap()); )]),
)
.unwrap(),
);
} }
} }
_ => panic!() _ => panic!(),
} }
} }
"xfs" => { "xfs" => {
match partition_method_automatic_seperation_refcell.borrow().as_str() { match partition_method_automatic_seperation_refcell
.borrow()
.as_str()
{
"partition" => { "partition" => {
if is_encrypted { if is_encrypted {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
auto_xfs::AUTOMATIC_HOME_PART_XFS_LOCKED_INSTALLATION_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ auto_xfs::AUTOMATIC_HOME_PART_XFS_LOCKED_INSTALLATION_PROG,
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), &std::collections::HashMap::from([
( (
"AUTO_LUKS_PASSWORD".to_string(), "CHROOT_PATH".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(), "/media/pikaos/installation",
), ),
( (
"ROOT_PART_SIZE_AS_I64_MIB".to_string(), "AUTO_LUKS_PASSWORD".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(), partition_method_automatic_luks_refcell
) .borrow()
]), .replace("'", r###"'"'"'"###)
) .as_str(),
.unwrap()); ),
(
"ROOT_PART_SIZE_AS_I64_MIB".to_string(),
(partition_method_automatic_ratio_refcell
.borrow()
.round()
as i64
/ 1048576)
.to_string()
.replace("'", r###"'"'"'"###)
.as_str(),
),
]),
)
.unwrap(),
);
} else { } else {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
auto_xfs::AUTOMATIC_HOME_PART_XFS_OPEN_INSTALLATION_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ auto_xfs::AUTOMATIC_HOME_PART_XFS_OPEN_INSTALLATION_PROG,
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), &std::collections::HashMap::from([
( (
"ROOT_PART_SIZE_AS_I64_MIB".to_string(), "CHROOT_PATH".to_string(),
(partition_method_automatic_ratio_refcell.borrow().round() as i64 / 1048576).to_string().replace("'", r###"'"'"'"###).as_str(), "/media/pikaos/installation",
) ),
]), (
) "ROOT_PART_SIZE_AS_I64_MIB".to_string(),
.unwrap()); (partition_method_automatic_ratio_refcell
.borrow()
.round()
as i64
/ 1048576)
.to_string()
.replace("'", r###"'"'"'"###)
.as_str(),
),
]),
)
.unwrap(),
);
} }
} }
"none" => { "none" => {
if is_encrypted { if is_encrypted {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
auto_xfs::AUTOMATIC_HOME_NONE_XFS_LOCKED_INSTALLATION_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ auto_xfs::AUTOMATIC_HOME_NONE_XFS_LOCKED_INSTALLATION_PROG,
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), &std::collections::HashMap::from([
( (
"AUTO_LUKS_PASSWORD".to_string(), "CHROOT_PATH".to_string(),
partition_method_automatic_luks_refcell.borrow().replace("'", r###"'"'"'"###).as_str(), "/media/pikaos/installation",
) ),
]), (
) "AUTO_LUKS_PASSWORD".to_string(),
.unwrap()); partition_method_automatic_luks_refcell
.borrow()
.replace("'", r###"'"'"'"###)
.as_str(),
),
]),
)
.unwrap(),
);
} else { } else {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
auto_xfs::AUTOMATIC_HOME_NONE_XFS_OPEN_INSTALLATION_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ auto_xfs::AUTOMATIC_HOME_NONE_XFS_OPEN_INSTALLATION_PROG,
("CHROOT_PATH".to_string(), "/media/pikaos/installation"), &std::collections::HashMap::from([(
]), "CHROOT_PATH".to_string(),
) "/media/pikaos/installation",
.unwrap()); )]),
)
.unwrap(),
);
} }
} }
_ => panic!() _ => panic!(),
} }
} }
_ => panic!() _ => panic!(),
} }
// //
if is_encrypted { if is_encrypted {
@ -300,117 +390,143 @@ pub fn create_installation_script(
} }
"manual" => { "manual" => {
let is_encrypted = *partition_method_manual_luks_enabled_refcell.borrow(); let is_encrypted = *partition_method_manual_luks_enabled_refcell.borrow();
if is_encrypted { if is_encrypted {
final_script.push_str( final_script.push_str(
r###" r###"
mkdir -p /tmp/PIKA_CRYPT/ mkdir -p /tmp/PIKA_CRYPT/
touch /tmp/PIKA_CRYPT/crypttab touch /tmp/PIKA_CRYPT/crypttab
"### "###,
); );
for crypt_entry in partition_method_manual_crypttab_entry_array_refcell.borrow().iter() { for crypt_entry in partition_method_manual_crypttab_entry_array_refcell
.borrow()
.iter()
{
match &crypt_entry.password { match &crypt_entry.password {
Some(p) => { Some(p) => {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
manual_basic::MANUAL_CRYPT_ENTRY_WITH_KEYFILE, &strfmt::strfmt(
&std::collections::HashMap::from([ manual_basic::MANUAL_CRYPT_ENTRY_WITH_KEYFILE,
( &std::collections::HashMap::from([
"MAP".to_string(), (
crypt_entry.map.replace("'", r###"'"'"'"###).as_str() "MAP".to_string(),
), crypt_entry.map.replace("'", r###"'"'"'"###).as_str(),
( ),
"UUID".to_string(), (
crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str() "UUID".to_string(),
), crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str(),
( ),
"LUKS_PASSWD".to_string(), (
p.replace("'", r###"'"'"'"###).as_str() "LUKS_PASSWD".to_string(),
) p.replace("'", r###"'"'"'"###).as_str(),
]), ),
) ]),
.unwrap()); )
.unwrap(),
);
} }
None => { None => {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
manual_basic::MANUAL_CRYPT_ENTRY, &strfmt::strfmt(
&std::collections::HashMap::from([ manual_basic::MANUAL_CRYPT_ENTRY,
( &std::collections::HashMap::from([
"MAP".to_string(), (
crypt_entry.map.replace("'", r###"'"'"'"###).as_str() "MAP".to_string(),
), crypt_entry.map.replace("'", r###"'"'"'"###).as_str(),
( ),
"UUID".to_string(), (
crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str() "UUID".to_string(),
) crypt_entry.uuid.replace("'", r###"'"'"'"###).as_str(),
]), ),
) ]),
.unwrap()); )
.unwrap(),
);
} }
} }
}; }
} }
let mut did_make_swap_list = false; let mut did_make_swap_list = false;
for fstab_entry in partition_method_manual_fstab_entry_array_refcell.borrow().iter() { for fstab_entry in partition_method_manual_fstab_entry_array_refcell
.borrow()
.iter()
{
if fstab_entry.mountpoint == "[SWAP]" { if fstab_entry.mountpoint == "[SWAP]" {
if !did_make_swap_list { if !did_make_swap_list {
final_script.push_str( final_script.push_str(
r###" r###"
touch /tmp/pika-installer-gtk4-swaplist touch /tmp/pika-installer-gtk4-swaplist
"### "###,
); );
did_make_swap_list = true did_make_swap_list = true
} }
final_script.push_str(&strfmt::strfmt( final_script.push_str(
manual_basic::MANUAL_SWAP_MOUNT_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ manual_basic::MANUAL_SWAP_MOUNT_PROG,
( &std::collections::HashMap::from([(
"PART".to_string(), "PART".to_string(),
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str() fstab_entry
), .partition
]), .part_name
) .replace("'", r###"'"'"'"###)
.unwrap()); .as_str(),
)]),
)
.unwrap(),
);
} else if !fstab_entry.mountopts.is_empty() { } else if !fstab_entry.mountopts.is_empty() {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
manual_basic::MANUAL_PARTITION_MOUNT_WITH_OPTS_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ manual_basic::MANUAL_PARTITION_MOUNT_WITH_OPTS_PROG,
( &std::collections::HashMap::from([
"PART".to_string(), (
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str() "PART".to_string(),
), fstab_entry
( .partition
"MOUNTPOINT".to_string(), .part_name
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str() .replace("'", r###"'"'"'"###)
), .as_str(),
( ),
"OPTS".to_string(), (
fstab_entry.mountopts.replace("'", r###"'"'"'"###).as_str() "MOUNTPOINT".to_string(),
), fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str(),
]), ),
) (
.unwrap()); "OPTS".to_string(),
fstab_entry.mountopts.replace("'", r###"'"'"'"###).as_str(),
),
]),
)
.unwrap(),
);
} else { } else {
final_script.push_str(&strfmt::strfmt( final_script.push_str(
manual_basic::MANUAL_PARTITION_MOUNT_PROG, &strfmt::strfmt(
&std::collections::HashMap::from([ manual_basic::MANUAL_PARTITION_MOUNT_PROG,
( &std::collections::HashMap::from([
"PART".to_string(), (
fstab_entry.partition.part_name.replace("'", r###"'"'"'"###).as_str() "PART".to_string(),
), fstab_entry
( .partition
"MOUNTPOINT".to_string(), .part_name
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str() .replace("'", r###"'"'"'"###)
), .as_str(),
]), ),
) (
.unwrap()); "MOUNTPOINT".to_string(),
fstab_entry.mountpoint.replace("'", r###"'"'"'"###).as_str(),
),
]),
)
.unwrap(),
);
} }
} }
@ -420,7 +536,7 @@ touch /tmp/pika-installer-gtk4-swaplist
final_script.push_str(manual_basic::MANUAL_OPEN_PART_PIKAINSTALL_PROG); final_script.push_str(manual_basic::MANUAL_OPEN_PART_PIKAINSTALL_PROG);
} }
} }
_ => panic!() _ => panic!(),
} }
final_script final_script

View File

@ -1,8 +1,11 @@
use crate::{build_ui::{PikaKeymap, KBDMap}, installer_stack_page}; use crate::{
build_ui::{KBDMap, PikaKeymap},
installer_stack_page,
};
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local};
use gnome_desktop::XkbInfoExt; use gnome_desktop::XkbInfoExt;
use gtk::{gio, glib}; use gtk::{gio, glib};
use glib::{clone, closure_local};
use std::{cell::RefCell, process::Command, rc::Rc}; use std::{cell::RefCell, process::Command, rc::Rc};
pub fn keyboard_page( pub fn keyboard_page(
@ -67,377 +70,317 @@ pub fn keyboard_page(
let current_keymap_variant: Option<String> = None; let current_keymap_variant: Option<String> = None;
let kbd_map_list = [ let kbd_map_list = [
KBDMap { KBDMap {
console: "sg".to_string(), console: "sg".to_string(),
layout: "ch".to_string(), layout: "ch".to_string(),
variant: "de_nodeadkeys".to_string() variant: "de_nodeadkeys".to_string(),
}, },
KBDMap {
KBDMap { console: "nl".to_string(),
console: "nl".to_string(), layout: "nl".to_string(),
layout: "nl".to_string(), variant: "".to_string(),
variant: "".to_string() },
}, KBDMap {
console: "mk-utf".to_string(),
KBDMap { layout: "mk".to_string(),
console: "mk-utf".to_string(), variant: "".to_string(),
layout: "mk".to_string(), },
variant: "".to_string() KBDMap {
}, console: "trq".to_string(),
layout: "tr".to_string(),
KBDMap { variant: "".to_string(),
console: "trq".to_string(), },
layout: "tr".to_string(), KBDMap {
variant: "".to_string() console: "trf".to_string(),
}, layout: "tr".to_string(),
variant: "f".to_string(),
KBDMap { },
console: "trf".to_string(), KBDMap {
layout: "tr".to_string(), console: "uk".to_string(),
variant: "f".to_string() layout: "gb".to_string(),
}, variant: "".to_string(),
},
KBDMap { KBDMap {
console: "uk".to_string(), console: "is-latin1".to_string(),
layout: "gb".to_string(), layout: "is".to_string(),
variant: "".to_string() variant: "".to_string(),
}, },
KBDMap {
KBDMap { console: "de".to_string(),
console: "is-latin1".to_string(), layout: "de".to_string(),
layout: "is".to_string(), variant: "".to_string(),
variant: "".to_string() },
}, KBDMap {
console: "la-latin1".to_string(),
KBDMap { layout: "latam".to_string(),
console: "de".to_string(), variant: "".to_string(),
layout: "de".to_string(), },
variant: "".to_string() KBDMap {
}, console: "us".to_string(),
layout: "us".to_string(),
KBDMap { variant: "".to_string(),
console: "la-latin1".to_string(), },
layout: "latam".to_string(), KBDMap {
variant: "".to_string() console: "ko".to_string(),
}, layout: "kr".to_string(),
variant: "".to_string(),
KBDMap { },
console: "us".to_string(), KBDMap {
layout: "us".to_string(), console: "ro_std".to_string(),
variant: "".to_string() layout: "ro".to_string(),
}, variant: "std".to_string(),
},
KBDMap { KBDMap {
console: "ko".to_string(), console: "slovene".to_string(),
layout: "kr".to_string(), layout: "si".to_string(),
variant: "".to_string() variant: "".to_string(),
}, },
KBDMap {
KBDMap { console: "hu".to_string(),
console: "ro_std".to_string(), layout: "hu".to_string(),
layout: "ro".to_string(), variant: "".to_string(),
variant: "std".to_string() },
}, KBDMap {
console: "jp106".to_string(),
KBDMap { layout: "jp".to_string(),
console: "slovene".to_string(), variant: "".to_string(),
layout: "si".to_string(), },
variant: "".to_string() KBDMap {
}, console: "croat".to_string(),
layout: "hr".to_string(),
KBDMap { variant: "".to_string(),
console: "hu".to_string(), },
layout: "hu".to_string(), KBDMap {
variant: "".to_string() console: "hu101".to_string(),
}, layout: "hu".to_string(),
variant: "qwerty".to_string(),
KBDMap { },
console: "jp106".to_string(), KBDMap {
layout: "jp".to_string(), console: "sr-latin".to_string(),
variant: "".to_string() layout: "rs".to_string(),
}, variant: "latin".to_string(),
},
KBDMap { KBDMap {
console: "croat".to_string(), console: "fi".to_string(),
layout: "hr".to_string(), layout: "fi".to_string(),
variant: "".to_string() variant: "".to_string(),
}, },
KBDMap {
KBDMap { console: "fr_CH".to_string(),
console: "hu101".to_string(), layout: "ch".to_string(),
layout: "hu".to_string(), variant: "fr".to_string(),
variant: "qwerty".to_string() },
}, KBDMap {
console: "dk-latin1".to_string(),
KBDMap { layout: "dk".to_string(),
console: "sr-latin".to_string(), variant: "".to_string(),
layout: "rs".to_string(), },
variant: "latin".to_string() KBDMap {
}, console: "fr".to_string(),
layout: "fr".to_string(),
KBDMap { variant: "".to_string(),
console: "fi".to_string(), },
layout: "fi".to_string(), KBDMap {
variant: "".to_string() console: "ua-utf".to_string(),
}, layout: "ua".to_string(),
variant: "".to_string(),
KBDMap { },
console: "fr_CH".to_string(), KBDMap {
layout: "ch".to_string(), console: "fr-latin9".to_string(),
variant: "fr".to_string() layout: "fr".to_string(),
}, variant: "latin9".to_string(),
},
KBDMap { KBDMap {
console: "dk-latin1".to_string(), console: "sg-latin1".to_string(),
layout: "dk".to_string(), layout: "ch".to_string(),
variant: "".to_string() variant: "de_nodeadkeys".to_string(),
}, },
KBDMap {
KBDMap { console: "be-latin1".to_string(),
console: "fr".to_string(), layout: "be".to_string(),
layout: "fr".to_string(), variant: "".to_string(),
variant: "".to_string() },
}, KBDMap {
console: "dk".to_string(),
KBDMap { layout: "dk".to_string(),
console: "ua-utf".to_string(), variant: "".to_string(),
layout: "ua".to_string(), },
variant: "".to_string() KBDMap {
}, console: "bg_pho-utf8".to_string(),
layout: "bg".to_string(),
KBDMap { variant: "phonetic".to_string(),
console: "fr-latin9".to_string(), },
layout: "fr".to_string(), KBDMap {
variant: "latin9".to_string() console: "it-ibm".to_string(),
}, layout: "it".to_string(),
variant: "ibm".to_string(),
KBDMap { },
console: "sg-latin1".to_string(), KBDMap {
layout: "ch".to_string(), console: "cz-us-qwertz".to_string(),
variant: "de_nodeadkeys".to_string() layout: "cz".to_string(),
}, variant: "".to_string(),
},
KBDMap { KBDMap {
console: "be-latin1".to_string(), console: "cz-qwerty".to_string(),
layout: "be".to_string(), layout: "cz".to_string(),
variant: "".to_string() variant: "qwerty".to_string(),
}, },
KBDMap {
KBDMap { console: "br".to_string(),
console: "dk".to_string(), layout: "br".to_string(),
layout: "dk".to_string(), variant: "".to_string(),
variant: "".to_string() },
}, KBDMap {
console: "ro".to_string(),
KBDMap { layout: "ro".to_string(),
console: "bg_pho-utf8".to_string(), variant: "".to_string(),
layout: "bg".to_string(), },
variant: "phonetic".to_string() KBDMap {
}, console: "us-acentos".to_string(),
layout: "us".to_string(),
KBDMap { variant: "intl".to_string(),
console: "it-ibm".to_string(), },
layout: "it".to_string(), KBDMap {
variant: "ibm".to_string() console: "pt-latin1".to_string(),
}, layout: "pt".to_string(),
variant: "".to_string(),
KBDMap { },
console: "cz-us-qwertz".to_string(), KBDMap {
layout: "cz".to_string(), console: "tj_alt-UTF8".to_string(),
variant: "".to_string() layout: "tj".to_string(),
}, variant: "".to_string(),
},
KBDMap { KBDMap {
console: "cz-qwerty".to_string(), console: "de-latin1-nodeadkeys".to_string(),
layout: "cz".to_string(), layout: "de".to_string(),
variant: "qwerty".to_string() variant: "nodeadkeys".to_string(),
}, },
KBDMap {
KBDMap { console: "no".to_string(),
console: "br".to_string(), layout: "no".to_string(),
layout: "br".to_string(), variant: "".to_string(),
variant: "".to_string() },
}, KBDMap {
console: "bg_bds-utf8".to_string(),
KBDMap { layout: "bg".to_string(),
console: "ro".to_string(), variant: "".to_string(),
layout: "ro".to_string(), },
variant: "".to_string() KBDMap {
}, console: "dvorak".to_string(),
layout: "us".to_string(),
KBDMap { variant: "dvorak".to_string(),
console: "us-acentos".to_string(), },
layout: "us".to_string(), KBDMap {
variant: "intl".to_string() console: "ru".to_string(),
}, layout: "ru".to_string(),
variant: "".to_string(),
KBDMap { },
console: "pt-latin1".to_string(), KBDMap {
layout: "pt".to_string(), console: "cz-lat2".to_string(),
variant: "".to_string() layout: "cz".to_string(),
}, variant: "qwerty".to_string(),
},
KBDMap { KBDMap {
console: "tj_alt-UTF8".to_string(), console: "pl".to_string(),
layout: "tj".to_string(), layout: "pl".to_string(),
variant: "".to_string() variant: "".to_string(),
}, },
KBDMap {
KBDMap { console: "es".to_string(),
console: "de-latin1-nodeadkeys".to_string(), layout: "es".to_string(),
layout: "de".to_string(), variant: "".to_string(),
variant: "nodeadkeys".to_string() },
}, KBDMap {
console: "ie".to_string(),
KBDMap { layout: "ie".to_string(),
console: "no".to_string(), variant: "".to_string(),
layout: "no".to_string(), },
variant: "".to_string() KBDMap {
}, console: "et".to_string(),
layout: "ee".to_string(),
KBDMap { variant: "".to_string(),
console: "bg_bds-utf8".to_string(), },
layout: "bg".to_string(), KBDMap {
variant: "".to_string() console: "sk-qwerty".to_string(),
}, layout: "sk".to_string(),
variant: "qwerty".to_string(),
KBDMap { },
console: "dvorak".to_string(), KBDMap {
layout: "us".to_string(), console: "sk-qwertz".to_string(),
variant: "dvorak".to_string() layout: "sk".to_string(),
}, variant: "".to_string(),
},
KBDMap { KBDMap {
console: "ru".to_string(), console: "fr-latin9".to_string(),
layout: "ru".to_string(), layout: "fr".to_string(),
variant: "".to_string() variant: "latin9".to_string(),
}, },
KBDMap {
KBDMap { console: "fr_CH-latin1".to_string(),
console: "cz-lat2".to_string(), layout: "ch".to_string(),
layout: "cz".to_string(), variant: "fr".to_string(),
variant: "qwerty".to_string() },
}, KBDMap {
console: "cf".to_string(),
KBDMap { layout: "ca".to_string(),
console: "pl".to_string(), variant: "".to_string(),
layout: "pl".to_string(), },
variant: "".to_string() KBDMap {
}, console: "sv-latin1".to_string(),
layout: "se".to_string(),
KBDMap { variant: "".to_string(),
console: "es".to_string(), },
layout: "es".to_string(), KBDMap {
variant: "".to_string() console: "sr-cy".to_string(),
}, layout: "rs".to_string(),
variant: "".to_string(),
KBDMap { },
console: "ie".to_string(), KBDMap {
layout: "ie".to_string(), console: "gr".to_string(),
variant: "".to_string() layout: "gr".to_string(),
}, variant: "".to_string(),
},
KBDMap { KBDMap {
console: "et".to_string(), console: "by".to_string(),
layout: "ee".to_string(), layout: "by".to_string(),
variant: "".to_string() variant: "".to_string(),
}, },
KBDMap {
KBDMap { console: "il".to_string(),
console: "sk-qwerty".to_string(), layout: "il".to_string(),
layout: "sk".to_string(), variant: "".to_string(),
variant: "qwerty".to_string() },
}, KBDMap {
console: "kazakh".to_string(),
KBDMap { layout: "kz".to_string(),
console: "sk-qwertz".to_string(), variant: "".to_string(),
layout: "sk".to_string(), },
variant: "".to_string() KBDMap {
}, console: "lt".to_string(),
layout: "lt".to_string(),
KBDMap { variant: "".to_string(),
console: "fr-latin9".to_string(), },
layout: "fr".to_string(), KBDMap {
variant: "latin9".to_string() console: "khmer".to_string(),
}, layout: "kh".to_string(),
variant: "".to_string(),
KBDMap { },
console: "fr_CH-latin1".to_string(), KBDMap {
layout: "ch".to_string(), console: "dvorak-es".to_string(),
variant: "fr".to_string() layout: "es".to_string(),
}, variant: "dvorak".to_string(),
},
KBDMap { KBDMap {
console: "cf".to_string(), console: "lv".to_string(),
layout: "ca".to_string(), layout: "lv".to_string(),
variant: "".to_string() variant: "apostrophe".to_string(),
}, },
KBDMap {
KBDMap { console: "lv-tilde".to_string(),
console: "sv-latin1".to_string(), layout: "lv".to_string(),
layout: "se".to_string(), variant: "tilde".to_string(),
variant: "".to_string() },
}, ];
KBDMap {
console: "sr-cy".to_string(),
layout: "rs".to_string(),
variant: "".to_string()
},
KBDMap {
console: "gr".to_string(),
layout: "gr".to_string(),
variant: "".to_string()
},
KBDMap {
console: "by".to_string(),
layout: "by".to_string(),
variant: "".to_string()
},
KBDMap {
console: "il".to_string(),
layout: "il".to_string(),
variant: "".to_string()
},
KBDMap {
console: "kazakh".to_string(),
layout: "kz".to_string(),
variant: "".to_string()
},
KBDMap {
console: "lt".to_string(),
layout: "lt".to_string(),
variant: "".to_string()
},
KBDMap {
console: "khmer".to_string(),
layout: "kh".to_string(),
variant: "".to_string()
},
KBDMap {
console: "dvorak-es".to_string(),
layout: "es".to_string(),
variant: "dvorak".to_string()
},
KBDMap {
console: "lv".to_string(),
layout: "lv".to_string(),
variant: "apostrophe".to_string()
},
KBDMap {
console: "lv-tilde".to_string(),
layout: "lv".to_string(),
variant: "tilde".to_string()
}];
let xkbinfo = gnome_desktop::XkbInfo::new(); let xkbinfo = gnome_desktop::XkbInfo::new();
@ -447,12 +390,22 @@ pub fn keyboard_page(
if map.variant.is_empty() { if map.variant.is_empty() {
sorted_keymap_vec.push(PikaKeymap { sorted_keymap_vec.push(PikaKeymap {
kbdmap: kbd_map, kbdmap: kbd_map,
pretty_name: xkbinfo.layout_info(&map.layout).unwrap().0.unwrap().to_string(), pretty_name: xkbinfo
.layout_info(&map.layout)
.unwrap()
.0
.unwrap()
.to_string(),
}) })
} else { } else {
sorted_keymap_vec.push(PikaKeymap { sorted_keymap_vec.push(PikaKeymap {
kbdmap: kbd_map, kbdmap: kbd_map,
pretty_name: xkbinfo.layout_info(format!("{}+{}", map.layout, map.variant).as_str()).unwrap().0.unwrap().to_string(), pretty_name: xkbinfo
.layout_info(format!("{}+{}", map.layout, map.variant).as_str())
.unwrap()
.0
.unwrap()
.to_string(),
}) })
} }
} }
@ -521,7 +474,9 @@ pub fn keyboard_page(
} }
} }
)); ));
if current_keymap == keymap_clone0.kbdmap.layout && current_keymap_variant == keymap_variant_clone0 { if current_keymap == keymap_clone0.kbdmap.layout
&& current_keymap_variant == keymap_variant_clone0
{
keymap_checkbutton.set_active(true); keymap_checkbutton.set_active(true);
} }
} }

View File

@ -1,7 +1,7 @@
use crate::{build_ui::PikaLocale, installer_stack_page}; use crate::{build_ui::PikaLocale, installer_stack_page};
use adw::prelude::*; use adw::prelude::*;
use gtk::{gio, glib};
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, env, process::Command, rc::Rc}; use std::{cell::RefCell, env, process::Command, rc::Rc};
pub fn language_page( pub fn language_page(
@ -202,11 +202,11 @@ pub fn language_page(
move |_language_page: installer_stack_page::InstallerStackPage| { move |_language_page: installer_stack_page::InstallerStackPage| {
let locale = &lang_data_refcell.borrow(); let locale = &lang_data_refcell.borrow();
Command::new("sudo") Command::new("sudo")
.arg("localectl") .arg("localectl")
.arg("set-locale") .arg("set-locale")
.arg("LANG=".to_owned() + &locale.name + ".UTF-8") .arg("LANG=".to_owned() + &locale.name + ".UTF-8")
.spawn() .spawn()
.expect("locale failed to start"); .expect("locale failed to start");
rust_i18n::set_locale(&locale.name); rust_i18n::set_locale(&locale.name);
language_changed_action.activate(None); language_changed_action.activate(None);
main_carousel.scroll_to(&main_carousel.nth_page(2), true) main_carousel.scroll_to(&main_carousel.nth_page(2), true)

View File

@ -20,9 +20,9 @@ mod automatic_partitioning_page;
mod manual_partitioning_page; mod manual_partitioning_page;
mod partitioning_page; mod partitioning_page;
// //
mod installation_summary_page;
mod installation_progress_page;
mod installation_complete_page; mod installation_complete_page;
mod installation_progress_page;
mod installation_summary_page;
#[macro_use] #[macro_use]
extern crate rust_i18n; extern crate rust_i18n;

View File

@ -4,8 +4,8 @@ use crate::{
drive_mount_row::DriveMountRow, drive_mount_row::DriveMountRow,
}; };
use adw::prelude::*; use adw::prelude::*;
use gtk::{glib, gio};
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, rc::Rc}; use std::{cell::RefCell, rc::Rc};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -19,6 +19,7 @@ struct PartitionRow {
pub fn create_efi_row( pub fn create_efi_row(
listbox: &gtk::ListBox, listbox: &gtk::ListBox,
window: adw::ApplicationWindow,
drive_rows_size_group: &gtk::SizeGroup, drive_rows_size_group: &gtk::SizeGroup,
partition_array: &Vec<Partition>, partition_array: &Vec<Partition>,
partition_changed_action: &gio::SimpleAction, partition_changed_action: &gio::SimpleAction,
@ -29,15 +30,20 @@ pub fn create_efi_row(
let partition_scroll_child = gtk::ListBox::builder() let partition_scroll_child = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.build(); .build();
partition_scroll_child.add_css_class("boxed-list");
partition_scroll_child.add_css_class("no-round-borders");
let partitions_scroll = gtk::ScrolledWindow::builder() let partitions_scroll = gtk::ScrolledWindow::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
.overflow(gtk::Overflow::Hidden)
.has_frame(true)
.child(&partition_scroll_child) .child(&partition_scroll_child)
.build(); .build();
partitions_scroll.add_css_class("round-all-scroll-no-padding");
// Create row // Create row
let row = DriveMountRow::new_with_scroll(&partitions_scroll); let row = DriveMountRow::new_with_widgets(&partitions_scroll, &window);
row.set_deletable(false); row.set_deletable(false);
@ -92,7 +98,6 @@ pub fn create_efi_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -117,7 +122,6 @@ pub fn create_efi_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -169,7 +173,6 @@ pub fn create_efi_row(
} else { } else {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -244,6 +247,7 @@ pub fn create_efi_row(
pub fn create_boot_row( pub fn create_boot_row(
listbox: &gtk::ListBox, listbox: &gtk::ListBox,
window: adw::ApplicationWindow,
drive_rows_size_group: &gtk::SizeGroup, drive_rows_size_group: &gtk::SizeGroup,
partition_array: &Vec<Partition>, partition_array: &Vec<Partition>,
partition_changed_action: &gio::SimpleAction, partition_changed_action: &gio::SimpleAction,
@ -254,15 +258,20 @@ pub fn create_boot_row(
let partition_scroll_child = gtk::ListBox::builder() let partition_scroll_child = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.build(); .build();
partition_scroll_child.add_css_class("boxed-list");
partition_scroll_child.add_css_class("no-round-borders");
let partitions_scroll = gtk::ScrolledWindow::builder() let partitions_scroll = gtk::ScrolledWindow::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
.overflow(gtk::Overflow::Hidden)
.has_frame(true)
.child(&partition_scroll_child) .child(&partition_scroll_child)
.build(); .build();
partitions_scroll.add_css_class("round-all-scroll-no-padding");
// Create row // Create row
let row = DriveMountRow::new_with_scroll(&partitions_scroll); let row = DriveMountRow::new_with_widgets(&partitions_scroll, &window);
row.set_deletable(false); row.set_deletable(false);
@ -317,7 +326,6 @@ pub fn create_boot_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -342,7 +350,6 @@ pub fn create_boot_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -394,7 +401,6 @@ pub fn create_boot_row(
} else { } else {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -469,6 +475,7 @@ pub fn create_boot_row(
pub fn create_root_row( pub fn create_root_row(
listbox: &gtk::ListBox, listbox: &gtk::ListBox,
window: adw::ApplicationWindow,
drive_rows_size_group: &gtk::SizeGroup, drive_rows_size_group: &gtk::SizeGroup,
partition_array: &Vec<Partition>, partition_array: &Vec<Partition>,
partition_changed_action: &gio::SimpleAction, partition_changed_action: &gio::SimpleAction,
@ -479,15 +486,20 @@ pub fn create_root_row(
let partition_scroll_child = gtk::ListBox::builder() let partition_scroll_child = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.build(); .build();
partition_scroll_child.add_css_class("boxed-list");
partition_scroll_child.add_css_class("no-round-borders");
let partitions_scroll = gtk::ScrolledWindow::builder() let partitions_scroll = gtk::ScrolledWindow::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
.overflow(gtk::Overflow::Hidden)
.has_frame(true)
.child(&partition_scroll_child) .child(&partition_scroll_child)
.build(); .build();
partitions_scroll.add_css_class("round-all-scroll-no-padding");
// Create row // Create row
let row = DriveMountRow::new_with_scroll(&partitions_scroll); let row = DriveMountRow::new_with_widgets(&partitions_scroll, &window);
row.set_deletable(false); row.set_deletable(false);
@ -542,7 +554,6 @@ pub fn create_root_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -567,7 +578,6 @@ pub fn create_root_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -624,7 +634,6 @@ pub fn create_root_row(
} else { } else {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -699,6 +708,7 @@ pub fn create_root_row(
pub fn create_mount_row( pub fn create_mount_row(
listbox: &gtk::ListBox, listbox: &gtk::ListBox,
window: adw::ApplicationWindow,
drive_rows_size_group: &gtk::SizeGroup, drive_rows_size_group: &gtk::SizeGroup,
partition_array: &Vec<Partition>, partition_array: &Vec<Partition>,
partition_changed_action: &gio::SimpleAction, partition_changed_action: &gio::SimpleAction,
@ -710,15 +720,20 @@ pub fn create_mount_row(
let partition_scroll_child = gtk::ListBox::builder() let partition_scroll_child = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .selection_mode(gtk::SelectionMode::None)
.build(); .build();
partition_scroll_child.add_css_class("boxed-list");
partition_scroll_child.add_css_class("no-round-borders");
let partitions_scroll = gtk::ScrolledWindow::builder() let partitions_scroll = gtk::ScrolledWindow::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
.overflow(gtk::Overflow::Hidden)
.has_frame(true)
.child(&partition_scroll_child) .child(&partition_scroll_child)
.build(); .build();
partitions_scroll.add_css_class("round-all-scroll-no-padding");
// Create row // Create row
let row = DriveMountRow::new_with_scroll(&partitions_scroll); let row = DriveMountRow::new_with_widgets(&partitions_scroll, &window);
row.set_deletable(true); row.set_deletable(true);
@ -773,7 +788,6 @@ pub fn create_mount_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -798,7 +812,6 @@ pub fn create_mount_row(
{ {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -818,7 +831,6 @@ pub fn create_mount_row(
} else { } else {
PartitionRow { PartitionRow {
widget: { widget: {
adw::ActionRow::builder() adw::ActionRow::builder()
.activatable_widget(&partition_button) .activatable_widget(&partition_button)
.title(part_name) .title(part_name)
@ -984,7 +996,7 @@ fn post_check_drive_mount(
row, row,
move |_| { move |_| {
if row.mountpoint() == "[SWAP]" { if row.mountpoint() == "[SWAP]" {
if partition.part_fs == "linux-swap" || partition.part_fs == "swap" { if partition.part_fs == "linux-swap" || partition.part_fs == "swap" {
(*partition_row_struct.swap_fs_error.borrow_mut()) = false; (*partition_row_struct.swap_fs_error.borrow_mut()) = false;
if !(*partition_row_struct.never.borrow()) if !(*partition_row_struct.never.borrow())
&& !(*partition_row_struct.swap_fs_error.borrow()) && !(*partition_row_struct.swap_fs_error.borrow())

View File

@ -1,13 +1,18 @@
use crate::{ use crate::{
build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration}, build_ui::{CrypttabEntry, FstabEntry, Partition, SubvolDeclaration},
installer_stack_page,
drive_mount_row::DriveMountRow, drive_mount_row::DriveMountRow,
installer_stack_page,
partitioning_page::{get_luks_uuid, get_partitions, test_luks_passwd}, partitioning_page::{get_luks_uuid, get_partitions, test_luks_passwd},
}; };
use gtk::{glib, gio, Orientation};
use adw::prelude::*; use adw::prelude::*;
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use std::{cell::RefCell, collections::HashSet, rc::Rc, sync::{Arc, atomic::AtomicBool}}; use gtk::{gio, glib, Orientation};
use std::{
cell::RefCell,
collections::HashSet,
rc::Rc,
sync::{atomic::AtomicBool, Arc},
};
mod func; mod func;
@ -68,6 +73,7 @@ pub fn manual_partitioning_page(
create_hardcoded_rows( create_hardcoded_rows(
&drive_mounts_adw_listbox, &drive_mounts_adw_listbox,
window.clone(),
&drive_rows_size_group, &drive_rows_size_group,
&partition_array_refcell, &partition_array_refcell,
&partition_changed_action, &partition_changed_action,
@ -189,6 +195,8 @@ pub fn manual_partitioning_page(
partition_method_manual_valid_label, partition_method_manual_valid_label,
#[strong] #[strong]
manual_partitioning_page, manual_partitioning_page,
#[strong]
window,
move |_| { move |_| {
while let Some(row) = drive_mounts_adw_listbox.last_child() { while let Some(row) = drive_mounts_adw_listbox.last_child() {
drive_mounts_adw_listbox.remove(&row); drive_mounts_adw_listbox.remove(&row);
@ -209,6 +217,7 @@ pub fn manual_partitioning_page(
manual_partitioning_page.set_next_sensitive(false); manual_partitioning_page.set_next_sensitive(false);
create_hardcoded_rows( create_hardcoded_rows(
&drive_mounts_adw_listbox, &drive_mounts_adw_listbox,
window.clone(),
&drive_rows_size_group, &drive_rows_size_group,
&partition_array_refcell, &partition_array_refcell,
&partition_changed_action, &partition_changed_action,
@ -264,11 +273,15 @@ pub fn manual_partitioning_page(
for fs_entry in generate_filesystem_table_array(&drive_mounts_adw_listbox) { for fs_entry in generate_filesystem_table_array(&drive_mounts_adw_listbox) {
let fs_entry_clone0 = fs_entry.clone(); let fs_entry_clone0 = fs_entry.clone();
if subvol_partition_array_refcell.borrow().is_empty() && !seen_partitions.insert(fs_entry.clone().partition.part_name) { if subvol_partition_array_refcell.borrow().is_empty()
&& !seen_partitions.insert(fs_entry.clone().partition.part_name)
{
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
} }
if fs_entry.mountpoint == "[SWAP]" { if fs_entry.mountpoint == "[SWAP]" {
if fs_entry.partition.part_fs == "linux-swap" || fs_entry.partition.part_fs == "swap" { if fs_entry.partition.part_fs == "linux-swap"
|| fs_entry.partition.part_fs == "swap"
{
} else { } else {
(errored.store(true, std::sync::atomic::Ordering::Relaxed)); (errored.store(true, std::sync::atomic::Ordering::Relaxed));
} }
@ -339,7 +352,8 @@ pub fn manual_partitioning_page(
)); ));
} }
(*partition_method_manual_fstab_entry_array_refcell.borrow_mut()).sort_by_key(|p| p.mountpoint.clone()) (*partition_method_manual_fstab_entry_array_refcell.borrow_mut())
.sort_by_key(|p| p.mountpoint.clone())
} }
)); ));
@ -444,6 +458,7 @@ pub fn manual_partitioning_page(
fn create_hardcoded_rows( fn create_hardcoded_rows(
drive_mounts_adw_listbox: &gtk::ListBox, drive_mounts_adw_listbox: &gtk::ListBox,
window: adw::ApplicationWindow,
drive_rows_size_group: &gtk::SizeGroup, drive_rows_size_group: &gtk::SizeGroup,
partition_array_refcell: &Rc<RefCell<Vec<Partition>>>, partition_array_refcell: &Rc<RefCell<Vec<Partition>>>,
partition_changed_action: &gio::SimpleAction, partition_changed_action: &gio::SimpleAction,
@ -476,6 +491,7 @@ fn create_hardcoded_rows(
func::create_efi_row( func::create_efi_row(
drive_mounts_adw_listbox, drive_mounts_adw_listbox,
window.clone(),
drive_rows_size_group, drive_rows_size_group,
&partition_array_refcell.borrow(), &partition_array_refcell.borrow(),
partition_changed_action, partition_changed_action,
@ -485,6 +501,7 @@ fn create_hardcoded_rows(
); );
func::create_boot_row( func::create_boot_row(
drive_mounts_adw_listbox, drive_mounts_adw_listbox,
window.clone(),
drive_rows_size_group, drive_rows_size_group,
&partition_array_refcell.borrow(), &partition_array_refcell.borrow(),
partition_changed_action, partition_changed_action,
@ -494,6 +511,7 @@ fn create_hardcoded_rows(
); );
func::create_root_row( func::create_root_row(
drive_mounts_adw_listbox, drive_mounts_adw_listbox,
window.clone(),
drive_rows_size_group, drive_rows_size_group,
&partition_array_refcell.borrow(), &partition_array_refcell.borrow(),
partition_changed_action, partition_changed_action,
@ -524,6 +542,7 @@ fn create_hardcoded_rows(
move |_| { move |_| {
func::create_mount_row( func::create_mount_row(
&drive_mounts_adw_listbox, &drive_mounts_adw_listbox,
window.clone(),
&drive_rows_size_group, &drive_rows_size_group,
&partition_array_refcell.borrow(), &partition_array_refcell.borrow(),
&partition_changed_action, &partition_changed_action,

View File

@ -3,9 +3,9 @@ use crate::{
build_ui::{BlockDevice, CrypttabEntry, FstabEntry, Partition}, build_ui::{BlockDevice, CrypttabEntry, FstabEntry, Partition},
installer_stack_page, manual_partitioning_page, installer_stack_page, manual_partitioning_page,
}; };
use gtk::{gio, glib, prelude::*};
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use std::{cell::RefCell, rc::Rc, io::BufRead}; use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, io::BufRead, rc::Rc};
pub fn partitioning_page( pub fn partitioning_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,

View File

@ -1,7 +1,7 @@
use crate::installer_stack_page; use crate::installer_stack_page;
use adw::prelude::*; use adw::prelude::*;
use gtk::{gio, glib};
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{gio, glib};
use std::{cell::RefCell, io::BufRead, process::Command, rc::Rc}; use std::{cell::RefCell, io::BufRead, process::Command, rc::Rc};
pub fn timezone_page( pub fn timezone_page(

View File

@ -1,13 +1,10 @@
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use tokio::io::{AsyncReadExt}; use tokio::io::AsyncReadExt;
use tokio::net::{UnixListener, UnixStream}; use tokio::net::{UnixListener, UnixStream};
use tokio::task; use tokio::task;
pub async fn handle_client( pub async fn handle_client(mut stream: UnixStream, buffer_sender: async_channel::Sender<String>) {
mut stream: UnixStream,
buffer_sender: async_channel::Sender<String>,
) {
// Buffer to store incoming data // Buffer to store incoming data
let mut buffer = [0; 1024]; let mut buffer = [0; 1024];
@ -29,10 +26,7 @@ pub async fn handle_client(
} }
} }
pub async fn start_socket_server( pub async fn start_socket_server(buffer_sender: async_channel::Sender<String>, socket_path: &str) {
buffer_sender: async_channel::Sender<String>,
socket_path: &str,
) {
// Remove the socket file if it already exists // Remove the socket file if it already exists
if Path::new(socket_path).exists() { if Path::new(socket_path).exists() {
fs::remove_file(socket_path).expect("Could not remove existing socket file"); fs::remove_file(socket_path).expect("Could not remove existing socket file");
@ -57,4 +51,4 @@ pub async fn start_socket_server(
} }
} }
} }
} }