Fix Swap support

This commit is contained in:
Ward from fusion-voyager-3 2024-08-19 02:12:35 +03:00
parent 77d52d75a7
commit d152501356
16 changed files with 1448 additions and 1435 deletions

View File

@ -26,15 +26,13 @@
"fstab_no_mountpoint_err": "Filesystem Table Error: One or more partitions don't have a mountpoint configured!",
"fstab_no_partition_err": "Filesystem Table Error: One or more entries don't have a partition configured!",
"fstab_badfs": "Filesystem Table Error: Invalid filesystem: (/dev/",
"fstab_small_efi_size": ") Must at least be 512MBs!",
"fstab_badfs_efi": ") Must be FAT32/vFAT to be mounted at /boot/efi!",
"fstab_small_boot_size": ") Must at least be 1GBs!",
"fstab_badfs_boot": ") Must not be FAT32/vFAT to be mounted at /boot!",
"fstab_small_root_size": ") Must at least be 26GBs!",
"fstab_badfs_root": ") Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs to be mounted at /!",
"fstab_small_home_size": ") Must at least be 11GBs!",
"fstab_badfs_home": ") Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs to be mounted at /home!",
"fstab_badfs_swap": ") Must not be swap to be used as [SWAP]!",
"fstab_small_efi_size": "EFI Must at least be 512MBs!",
"fstab_badfs_efi": "EFI Must be FAT32/vFAT",
"fstab_small_boot_size": "Boot Must at least be 1GBs!",
"fstab_badfs_boot": "Boot Must be EXT4",
"fstab_small_root_size": "Root Must at least be 26GBs!",
"fstab_badfs_root": "Root Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs",
"fstab_badfs_swap": "Swap must be linux-swap",
"fstab_bad_mountpoint": "Filesystem Table Error: Invalid mountpoint: (",
"fstab_bad_mountpoint_msg": ") Is not a valid mountpoint!",
"select_a_language": "Select a Language",

View File

@ -1,10 +1,10 @@
use adw::gio;
use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib};
use crate::partitioning_page::{get_block_devices};
use adw::{prelude::*};
use crate::partitioning_page::get_block_devices;
use adw::gio;
use adw::prelude::*;
use glib::{clone, closure_local, ffi::gboolean};
use std::{rc::Rc, cell::RefCell};
use gtk::{glib, prelude::*};
use std::{cell::RefCell, rc::Rc};
const BOOT_AND_EFI_BYTE_SIZE: f64 = 1611661312.0;
const MINIMUM_ROOT_BYTE_SIZE: f64 = 39000000000.0;
@ -18,7 +18,7 @@ pub fn automatic_partitioning_page(
partition_method_automatic_luks_refcell: &Rc<RefCell<String>>,
partition_method_automatic_ratio_refcell: &Rc<RefCell<f64>>,
partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>,
language_changed_action: &gio::SimpleAction
language_changed_action: &gio::SimpleAction,
) {
let automatic_partitioning_page = installer_stack_page::InstallerStackPage::new();
automatic_partitioning_page.set_page_icon("builder");
@ -41,8 +41,7 @@ pub fn automatic_partitioning_page(
.orientation(gtk::Orientation::Vertical)
.build();
let advanced_box_viewport =
gtk::ScrolledWindow::builder()
let advanced_box_viewport = gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.child(&advanced_box)
@ -54,13 +53,11 @@ pub fn automatic_partitioning_page(
.orientation(gtk::Orientation::Vertical)
.build();
let advanced_home_part_ratio_label_root = gtk::Label::builder()
.build();
let advanced_home_part_ratio_label_root = gtk::Label::builder().build();
advanced_home_part_ratio_label_root.add_css_class("accent-text");
let advanced_home_part_ratio_label_home = gtk::Label::builder()
.build();
let advanced_home_part_ratio_label_home = gtk::Label::builder().build();
advanced_home_part_ratio_label_home.add_css_class("green-text");
@ -71,20 +68,27 @@ pub fn automatic_partitioning_page(
.margin_bottom(5)
.build();
let advanced_home_part_ratio_selection_slider= gtk::Scale::builder()
.draw_value(false)
.build();
let advanced_home_part_ratio_selection_slider = gtk::Scale::builder().draw_value(false).build();
advanced_home_part_ratio_selection_slider.add_css_class("green-trough");
let advanced_home_part_ratio_label_root_clone0 = advanced_home_part_ratio_label_root.clone();
let advanced_home_part_ratio_label_home_clone0 = advanced_home_part_ratio_label_home.clone();
let partition_method_automatic_ratio_refcell_clone0 = partition_method_automatic_ratio_refcell.clone();
let partition_method_automatic_ratio_refcell_clone0 =
partition_method_automatic_ratio_refcell.clone();
advanced_home_part_ratio_selection_slider.connect_change_value(move |slider, _, value| {
let home_size: f64 = slider.adjustment().upper() + 10000000000.0 - value;
advanced_home_part_ratio_label_root_clone0.set_label(&format!("{}: {}", t!("Root Part Size"), pretty_bytes::converter::convert(value.into())));
advanced_home_part_ratio_label_home_clone0.set_label(&format!("{}: {}", t!("Home Part Size"), pretty_bytes::converter::convert(home_size.into())));
advanced_home_part_ratio_label_root_clone0.set_label(&format!(
"{}: {}",
t!("Root Part Size"),
pretty_bytes::converter::convert(value.into())
));
advanced_home_part_ratio_label_home_clone0.set_label(&format!(
"{}: {}",
t!("Home Part Size"),
pretty_bytes::converter::convert(home_size.into())
));
*partition_method_automatic_ratio_refcell_clone0.borrow_mut() = value;
glib::Propagation::Proceed
});
@ -104,18 +108,18 @@ pub fn automatic_partitioning_page(
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("subvol");
let advanced_home_seperation_selection_checkbutton_subvol = gtk::CheckButton::builder()
.active(true)
.build();
let advanced_home_seperation_selection_checkbutton_subvol =
gtk::CheckButton::builder().active(true).build();
let advanced_home_seperation_selection_checkbutton_partition = gtk::CheckButton::builder()
.build();
let advanced_home_seperation_selection_checkbutton_partition =
gtk::CheckButton::builder().build();
let advanced_home_seperation_selection_checkbutton_none = gtk::CheckButton::builder()
.build();
let advanced_home_seperation_selection_checkbutton_none = gtk::CheckButton::builder().build();
advanced_home_seperation_selection_checkbutton_partition.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_none.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_partition
.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_none
.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol));
advanced_home_seperation_selection_checkbutton_partition
.bind_property(
@ -129,32 +133,26 @@ pub fn automatic_partitioning_page(
advanced_home_seperation_selection_checkbutton_subvol.connect_toggled(clone!(
#[strong]
partition_method_automatic_seperation_refcell,
move |_|
{
move |_| {
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("subvol");
}
)
);
));
advanced_home_seperation_selection_checkbutton_partition.connect_toggled(clone!(
#[strong]
partition_method_automatic_seperation_refcell,
move |_|
{
move |_| {
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("partition");
}
)
);
));
advanced_home_seperation_selection_checkbutton_none.connect_toggled(clone!(
#[strong]
partition_method_automatic_seperation_refcell,
move |_|
{
move |_| {
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("none");
}
)
);
));
//
@ -176,13 +174,11 @@ pub fn automatic_partitioning_page(
.active(true)
.build();
let advanced_filesystem_selection_checkbutton_ext4 = gtk::CheckButton::builder()
.label("EXT4")
.build();
let advanced_filesystem_selection_checkbutton_ext4 =
gtk::CheckButton::builder().label("EXT4").build();
let advanced_filesystem_selection_checkbutton_xfs = gtk::CheckButton::builder()
.label("XFS")
.build();
let advanced_filesystem_selection_checkbutton_xfs =
gtk::CheckButton::builder().label("XFS").build();
advanced_filesystem_selection_checkbutton_btrfs
.bind_property(
@ -196,12 +192,10 @@ pub fn automatic_partitioning_page(
advanced_filesystem_selection_checkbutton_btrfs.connect_toggled(clone!(
#[strong]
partition_method_automatic_target_fs_refcell,
move |_|
{
move |_| {
*partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("btrfs");
}
)
);
));
advanced_filesystem_selection_checkbutton_ext4.connect_toggled(clone!(
#[weak]
@ -212,15 +206,15 @@ pub fn automatic_partitioning_page(
advanced_home_seperation_selection_checkbutton_partition,
#[strong]
partition_method_automatic_target_fs_refcell,
move |_|
move |_| {
if advanced_filesystem_selection_checkbutton_ext4.is_active()
&& advanced_home_seperation_selection_checkbutton_subvol.is_active()
{
if advanced_filesystem_selection_checkbutton_ext4.is_active() && advanced_home_seperation_selection_checkbutton_subvol.is_active() {
advanced_home_seperation_selection_checkbutton_partition.set_active(true)
}
*partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("ext4");
}
)
);
));
advanced_filesystem_selection_checkbutton_xfs.connect_toggled(clone!(
#[weak]
@ -231,19 +225,20 @@ pub fn automatic_partitioning_page(
advanced_home_seperation_selection_checkbutton_partition,
#[strong]
partition_method_automatic_target_fs_refcell,
move |_|
move |_| {
if advanced_filesystem_selection_checkbutton_xfs.is_active()
&& advanced_home_seperation_selection_checkbutton_subvol.is_active()
{
if advanced_filesystem_selection_checkbutton_xfs.is_active() && advanced_home_seperation_selection_checkbutton_subvol.is_active() {
advanced_home_seperation_selection_checkbutton_partition.set_active(true)
}
*partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("xfs");
}
)
);
));
advanced_filesystem_selection_checkbutton_ext4.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
advanced_filesystem_selection_checkbutton_xfs.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
advanced_filesystem_selection_checkbutton_ext4
.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
advanced_filesystem_selection_checkbutton_xfs
.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs));
//
@ -255,8 +250,7 @@ pub fn automatic_partitioning_page(
//
let devices_selection_expander_row = adw::ExpanderRow::builder()
.build();
let devices_selection_expander_row = adw::ExpanderRow::builder().build();
let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
@ -275,8 +269,7 @@ pub fn automatic_partitioning_page(
devices_selection_expander_row_viewport_box.add_css_class("boxed-list");
devices_selection_expander_row_viewport_box.add_css_class("round-all-scroll");
let devices_selection_expander_row_viewport =
gtk::ScrolledWindow::builder()
let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.has_frame(true)
@ -316,7 +309,12 @@ pub fn automatic_partitioning_page(
//
let error_labels = [partition_method_automatic_disk_nodisk_error_label.clone(), partition_method_automatic_disk_small_error_label.clone(), partition_method_automatic_luks_empty_error_label.clone(), partition_method_automatic_luks_missmatch_error_label.clone()];
let error_labels = [
partition_method_automatic_disk_nodisk_error_label.clone(),
partition_method_automatic_disk_small_error_label.clone(),
partition_method_automatic_luks_empty_error_label.clone(),
partition_method_automatic_luks_missmatch_error_label.clone(),
];
//
@ -384,8 +382,7 @@ pub fn automatic_partitioning_page(
.build();
device_row.add_prefix(&device_button);
devices_selection_expander_row_viewport_box.append(&device_row);
device_button.connect_toggled(
clone!(
device_button.connect_toggled(clone!(
#[weak]
device_button,
#[weak]
@ -403,7 +400,13 @@ pub fn automatic_partitioning_page(
#[weak]
automatic_partitioning_page,
move |_| {
disk_check(&device_button, &devices_selection_expander_row, &partition_method_automatic_disk_small_error_label, &device.block_name, device.block_size);
disk_check(
&device_button,
&devices_selection_expander_row,
&partition_method_automatic_disk_small_error_label,
&device.block_name,
device.block_size,
);
partition_method_automatic_disk_nodisk_error_label.set_visible(false);
let usable_disk_space = device.block_size - BOOT_AND_EFI_BYTE_SIZE;
let default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 {
@ -413,22 +416,25 @@ pub fn automatic_partitioning_page(
} else {
(usable_disk_space * 40.0) / 100.0
};
advanced_home_part_ratio_selection_slider.set_range(MINIMUM_ROOT_BYTE_SIZE, device.block_size - 10000000000.0);
advanced_home_part_ratio_selection_slider
.set_range(MINIMUM_ROOT_BYTE_SIZE, device.block_size - 10000000000.0);
advanced_home_part_ratio_selection_slider.set_value(default_root_size);
advanced_home_part_ratio_selection_slider.emit_by_name_with_values("change_value", &[gtk::ScrollType::None.into(), default_root_size.into()]);
*partition_method_automatic_target_refcell.borrow_mut() = String::from(&device.block_name);
advanced_home_part_ratio_selection_slider.emit_by_name_with_values(
"change_value",
&[gtk::ScrollType::None.into(), default_root_size.into()],
);
*partition_method_automatic_target_refcell.borrow_mut() =
String::from(&device.block_name);
if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true)
} else {
automatic_partitioning_page.set_next_sensitive(false)
}
}
)
);
));
}
partition_method_automatic_luks_checkbutton.connect_toggled(
clone!(
partition_method_automatic_luks_checkbutton.connect_toggled(clone!(
#[strong]
partition_method_automatic_luks_missmatch_error_label,
#[strong]
@ -450,18 +456,22 @@ pub fn automatic_partitioning_page(
true => *partition_method_automatic_luks_enabled_refcell.borrow_mut() = true,
false => *partition_method_automatic_luks_enabled_refcell.borrow_mut() = false,
}
luks_check(&partition_method_automatic_luks_checkbutton, &partition_method_automatic_luks_password_entry, &partition_method_automatic_luks_password_confirm_entry, &partition_method_automatic_luks_missmatch_error_label, &partition_method_automatic_luks_empty_error_label);
luks_check(
&partition_method_automatic_luks_checkbutton,
&partition_method_automatic_luks_password_entry,
&partition_method_automatic_luks_password_confirm_entry,
&partition_method_automatic_luks_missmatch_error_label,
&partition_method_automatic_luks_empty_error_label,
);
if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true)
} else {
automatic_partitioning_page.set_next_sensitive(false)
}
}
)
);
));
partition_method_automatic_luks_password_entry.connect_changed(
clone!(
partition_method_automatic_luks_password_entry.connect_changed(clone!(
#[weak]
partition_method_automatic_luks_missmatch_error_label,
#[weak]
@ -479,19 +489,24 @@ pub fn automatic_partitioning_page(
#[weak]
automatic_partitioning_page,
move |_| {
*partition_method_automatic_luks_refcell.borrow_mut() = String::from(partition_method_automatic_luks_password_entry.text());
luks_check(&partition_method_automatic_luks_checkbutton, &partition_method_automatic_luks_password_entry, &partition_method_automatic_luks_password_confirm_entry, &partition_method_automatic_luks_missmatch_error_label, &partition_method_automatic_luks_empty_error_label);
*partition_method_automatic_luks_refcell.borrow_mut() =
String::from(partition_method_automatic_luks_password_entry.text());
luks_check(
&partition_method_automatic_luks_checkbutton,
&partition_method_automatic_luks_password_entry,
&partition_method_automatic_luks_password_confirm_entry,
&partition_method_automatic_luks_missmatch_error_label,
&partition_method_automatic_luks_empty_error_label,
);
if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true)
} else {
automatic_partitioning_page.set_next_sensitive(false)
}
}
)
);
));
partition_method_automatic_luks_password_confirm_entry.connect_changed(
clone!(
partition_method_automatic_luks_password_confirm_entry.connect_changed(clone!(
#[weak]
partition_method_automatic_luks_missmatch_error_label,
#[weak]
@ -509,30 +524,40 @@ pub fn automatic_partitioning_page(
#[weak]
automatic_partitioning_page,
move |_| {
*partition_method_automatic_luks_refcell.borrow_mut() = String::from(partition_method_automatic_luks_password_entry.text());
luks_check(&partition_method_automatic_luks_checkbutton, &partition_method_automatic_luks_password_entry, &partition_method_automatic_luks_password_confirm_entry, &partition_method_automatic_luks_missmatch_error_label, &partition_method_automatic_luks_empty_error_label);
*partition_method_automatic_luks_refcell.borrow_mut() =
String::from(partition_method_automatic_luks_password_entry.text());
luks_check(
&partition_method_automatic_luks_checkbutton,
&partition_method_automatic_luks_password_entry,
&partition_method_automatic_luks_password_confirm_entry,
&partition_method_automatic_luks_missmatch_error_label,
&partition_method_automatic_luks_empty_error_label,
);
if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true)
} else {
automatic_partitioning_page.set_next_sensitive(false)
}
}
)
);
));
//
devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row);
partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry);
partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_confirm_entry);
partition_method_automatic_luks_listbox
.append(&partition_method_automatic_luks_password_confirm_entry);
partition_method_automatic_luks_box.append(&partition_method_automatic_luks_checkbutton);
partition_method_automatic_luks_box.append(&partition_method_automatic_luks_listbox);
advanced_home_seperation_selection_box.append(&advanced_home_seperation_selection_checkbutton_subvol);
advanced_home_seperation_selection_box.append(&advanced_home_seperation_selection_checkbutton_partition);
advanced_home_seperation_selection_box.append(&advanced_home_seperation_selection_checkbutton_none);
advanced_home_seperation_selection_box
.append(&advanced_home_seperation_selection_checkbutton_subvol);
advanced_home_seperation_selection_box
.append(&advanced_home_seperation_selection_checkbutton_partition);
advanced_home_seperation_selection_box
.append(&advanced_home_seperation_selection_checkbutton_none);
advanced_filesystem_selection_box.append(&advanced_filesystem_selection_checkbutton_btrfs);
advanced_filesystem_selection_box.append(&advanced_filesystem_selection_checkbutton_ext4);
@ -560,11 +585,10 @@ pub fn automatic_partitioning_page(
closure_local!(
#[weak]
partition_carousel,
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage|
{
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage| {
partition_carousel.scroll_to(&partition_carousel.nth_page(0), true)
}
)
),
);
automatic_partitioning_page.connect_closure(
@ -587,8 +611,7 @@ pub fn automatic_partitioning_page(
partition_method_automatic_ratio_refcell,
#[strong]
partition_method_automatic_seperation_refcell,
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage|
{
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage| {
*partition_method_type_refcell.borrow_mut() = String::from("automatic");
//partition_carousel.scroll_to(&partition_carousel.nth_page(5), true)
dbg!(partition_method_type_refcell.borrow());
@ -599,7 +622,7 @@ pub fn automatic_partitioning_page(
dbg!(partition_method_automatic_ratio_refcell.borrow());
dbg!(partition_method_automatic_seperation_refcell.borrow());
}
)
),
);
//
@ -637,7 +660,8 @@ pub fn automatic_partitioning_page(
//
partition_method_automatic_disk_nodisk_error_label.set_label(&t!("no_disk_specified"));
//
partition_method_automatic_disk_small_error_label.set_label(&t!("disk_auto_target_small"));
partition_method_automatic_disk_small_error_label
.set_label(&t!("disk_auto_target_small"));
//
partition_method_automatic_luks_empty_error_label.set_label(&t!("luks_yes_but_empty"));
//
@ -647,27 +671,40 @@ pub fn automatic_partitioning_page(
//
partition_method_automatic_luks_password_entry.set_title(&t!("luks2_password"));
//
partition_method_automatic_luks_password_confirm_entry.set_title(&t!("luks2_password_confirm"));
partition_method_automatic_luks_password_confirm_entry
.set_title(&t!("luks2_password_confirm"));
//
advanced_expander.set_label(Some(&t!("advanced_options")));
//
advanced_filesystem_selection_frame.set_label(Some(&t!("choose_fs_auto")));
//
advanced_home_seperation_selection_frame.set_label(Some(&t!("choose_home_seperation_auto")));
advanced_home_seperation_selection_frame
.set_label(Some(&t!("choose_home_seperation_auto")));
//
advanced_home_seperation_selection_checkbutton_subvol.set_label(Some(&t!("advanced_home_seperation_selection_checkbutton_subvol_label")));
advanced_home_seperation_selection_checkbutton_subvol.set_label(Some(&t!(
"advanced_home_seperation_selection_checkbutton_subvol_label"
)));
//
advanced_home_seperation_selection_checkbutton_partition.set_label(Some(&t!("advanced_home_seperation_selection_checkbutton_partition_label")));
advanced_home_seperation_selection_checkbutton_partition.set_label(Some(&t!(
"advanced_home_seperation_selection_checkbutton_partition_label"
)));
//
advanced_home_seperation_selection_checkbutton_none.set_label(Some(&t!("advanced_home_seperation_selection_checkbutton_none_label")));
advanced_home_seperation_selection_checkbutton_none.set_label(Some(&t!(
"advanced_home_seperation_selection_checkbutton_none_label"
)));
//
}
)
);
));
//
}
fn disk_check(device_button: &gtk::CheckButton ,devices_selection_expander_row: &adw::ExpanderRow, partition_method_automatic_disk_size_error_label: &gtk::Label, device_block_name: &str, device_block_size: f64) {
fn disk_check(
device_button: &gtk::CheckButton,
devices_selection_expander_row: &adw::ExpanderRow,
partition_method_automatic_disk_size_error_label: &gtk::Label,
device_block_name: &str,
device_block_size: f64,
) {
if device_button.is_active() == true {
devices_selection_expander_row.set_title(device_block_name);
if device_block_size >= MINIMUM_ROOT_BYTE_SIZE {
@ -678,14 +715,26 @@ fn disk_check(device_button: &gtk::CheckButton ,devices_selection_expander_row:
}
}
fn luks_check(partition_method_automatic_luks_checkbutton: &gtk::CheckButton, partition_method_automatic_luks_password_entry: &adw::PasswordEntryRow, partition_method_automatic_luks_password_confirm_entry: &adw::PasswordEntryRow, partition_method_automatic_luks_missmatch_error_label: &gtk::Label, partition_method_automatic_luks_empty_error_label: &gtk::Label) {
fn luks_check(
partition_method_automatic_luks_checkbutton: &gtk::CheckButton,
partition_method_automatic_luks_password_entry: &adw::PasswordEntryRow,
partition_method_automatic_luks_password_confirm_entry: &adw::PasswordEntryRow,
partition_method_automatic_luks_missmatch_error_label: &gtk::Label,
partition_method_automatic_luks_empty_error_label: &gtk::Label,
) {
if partition_method_automatic_luks_checkbutton.is_active() == true {
if partition_method_automatic_luks_password_entry.text() != partition_method_automatic_luks_password_confirm_entry.text() {
if partition_method_automatic_luks_password_entry.text()
!= partition_method_automatic_luks_password_confirm_entry.text()
{
partition_method_automatic_luks_missmatch_error_label.set_visible(true)
} else {
partition_method_automatic_luks_missmatch_error_label.set_visible(false)
}
if partition_method_automatic_luks_password_entry.text().to_string().is_empty() {
if partition_method_automatic_luks_password_entry
.text()
.to_string()
.is_empty()
{
partition_method_automatic_luks_empty_error_label.set_visible(true);
} else {
partition_method_automatic_luks_empty_error_label.set_visible(false);
@ -699,7 +748,7 @@ fn luks_check(partition_method_automatic_luks_checkbutton: &gtk::CheckButton, pa
fn check_for_errors(error_labels: &[gtk::Label]) -> bool {
for label in error_labels {
if label.is_visible() {
return false
return false;
}
}
true

View File

@ -1,6 +1,10 @@
use std::{path::Path, rc::Rc, cell::RefCell};
use gtk::{prelude::*, glib as glib, gio as gio};
use crate::{efi_error_page, eula_page, keyboard_page, language_page, partitioning_page::{self, CrypttabEntry, FstabEntry}, timezone_page, welcome_page};
use crate::{
efi_error_page, eula_page, keyboard_page, language_page,
partitioning_page::{self, CrypttabEntry, FstabEntry},
timezone_page, welcome_page,
};
use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, path::Path, rc::Rc};
pub fn build_ui(app: &adw::Application) {
glib::set_prgname(Some("pikaos_installer"));
@ -46,7 +50,7 @@ pub fn build_ui(app: &adw::Application) {
match Path::new("/sys/firmware/efi/efivars").exists() {
true => welcome_page::welcome_page(&window, &carousel),
_ => efi_error_page::efi_error_page(&window, &carousel)
_ => efi_error_page::efi_error_page(&window, &carousel),
}
let language_selection_text_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
@ -54,25 +58,45 @@ pub fn build_ui(app: &adw::Application) {
let keymap_varient_selection_text_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let timezone_selection_text_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_type_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_automatic_target_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_automatic_target_fs_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_automatic_luks_enabled_refcell: Rc<RefCell<bool>> = Rc::new(RefCell::new(false));
let partition_method_automatic_target_refcell: Rc<RefCell<String>> =
Rc::new(RefCell::default());
let partition_method_automatic_target_fs_refcell: Rc<RefCell<String>> =
Rc::new(RefCell::default());
let partition_method_automatic_luks_enabled_refcell: Rc<RefCell<bool>> =
Rc::new(RefCell::new(false));
let partition_method_automatic_luks_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_automatic_ratio_refcell: Rc<RefCell<f64>> = Rc::new(RefCell::new(0.0));
let partition_method_automatic_seperation_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default());
let partition_method_manual_fstab_entry_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::new(Vec::new()));
let partition_method_manual_luks_enabled_refcell: Rc<RefCell<bool>> = Rc::new(RefCell::new(false));
let partition_method_manual_crypttab_entry_array_refcell: Rc<RefCell<Vec<CrypttabEntry>>> = Rc::new(RefCell::new(Vec::new()));
let partition_method_automatic_seperation_refcell: Rc<RefCell<String>> =
Rc::new(RefCell::default());
let partition_method_manual_fstab_entry_array_refcell: Rc<RefCell<Vec<FstabEntry>>> =
Rc::new(RefCell::new(Vec::new()));
let partition_method_manual_luks_enabled_refcell: Rc<RefCell<bool>> =
Rc::new(RefCell::new(false));
let partition_method_manual_crypttab_entry_array_refcell: Rc<RefCell<Vec<CrypttabEntry>>> =
Rc::new(RefCell::new(Vec::new()));
let language_changed_action = gio::SimpleAction::new("lang-changed", None);
language_page::language_page(&carousel, &language_selection_text_refcell, &language_changed_action);
language_page::language_page(
&carousel,
&language_selection_text_refcell,
&language_changed_action,
);
eula_page::eula_page(&carousel, &language_changed_action);
keyboard_page::keyboard_page(&carousel, &keymap_base_selection_text_refcell, &keymap_varient_selection_text_refcell, &language_changed_action);
keyboard_page::keyboard_page(
&carousel,
&keymap_base_selection_text_refcell,
&keymap_varient_selection_text_refcell,
&language_changed_action,
);
timezone_page::timezone_page(&carousel, &timezone_selection_text_refcell, &language_changed_action);
timezone_page::timezone_page(
&carousel,
&timezone_selection_text_refcell,
&language_changed_action,
);
partitioning_page::partitioning_page(
&carousel,
@ -86,7 +110,8 @@ pub fn build_ui(app: &adw::Application) {
&partition_method_manual_fstab_entry_array_refcell,
&partition_method_manual_luks_enabled_refcell,
&partition_method_manual_crypttab_entry_array_refcell,
&language_changed_action);
&language_changed_action,
);
window.present()
}

View File

@ -1,8 +1,8 @@
use std::{cell::RefCell, rc::Rc, sync::OnceLock};
use adw::{prelude::*, subclass::prelude::*, *};
use gtk::{glib as glib, Orientation::Horizontal};
use glib::{clone, subclass::Signal, Properties};
use gtk::{glib, Orientation::Horizontal};
use crate::partitioning_page::FstabEntry;
@ -24,7 +24,7 @@ pub struct DriveMountRow {
#[property(get, set)]
sizegroup: RefCell<Option<gtk::SizeGroup>>,
#[property(get, set)]
langaction: RefCell<Option<gio::SimpleAction>>
langaction: RefCell<Option<gio::SimpleAction>>,
}
// ANCHOR_END: custom_button
@ -45,7 +45,6 @@ impl ObjectImpl for DriveMountRow {
SIGNALS.get_or_init(|| vec![Signal::builder("row-deleted").build()])
}
fn constructed(&self) {
self.parent_constructed();
// Bind label to number
@ -142,12 +141,10 @@ impl ObjectImpl for DriveMountRow {
partition_row_delete_button.connect_clicked(clone!(
#[weak]
obj,
move |_|
{
move |_| {
obj.emit_by_name::<()>("row-deleted", &[]);
}
)
);
));
//
@ -176,21 +173,17 @@ impl ObjectImpl for DriveMountRow {
mountpoint_entry_row_adw_listbox,
#[weak]
mountopts_entry_row_adw_listbox,
move |_|
{
move |_| {
match obj.sizegroup() {
Some(t) => {
t.add_widget(&partition_row_expander_adw_listbox);
t.add_widget(&mountpoint_entry_row_adw_listbox);
t.add_widget(&mountopts_entry_row_adw_listbox);
}
None => {
None => {}
}
}
}
)
);
));
// Bind label to number
// `SYNC_CREATE` ensures that the label will be immediately set
@ -215,12 +208,11 @@ impl ObjectImpl for DriveMountRow {
obj,
#[weak]
partition_row_expander,
move |_|
{
partition_row_expander.add_row(&obj.property::<gtk::ScrolledWindow>("partitionscroll"));
move |_| {
partition_row_expander
.add_row(&obj.property::<gtk::ScrolledWindow>("partitionscroll"));
}
)
);
));
obj.connect_langaction_notify(clone!(
#[weak]
@ -231,34 +223,27 @@ impl ObjectImpl for DriveMountRow {
mountpoint_entry_row,
#[weak]
mountopts_entry_row,
move |_|
{
move |_| {
match obj.langaction() {
Some(t) => {
t.connect_activate(
clone!(
t.connect_activate(clone!(
#[weak]
partition_row_expander,
#[weak]
mountpoint_entry_row,
#[weak]
mountopts_entry_row,
move |_, _|
{
move |_, _| {
partition_row_expander.set_subtitle(&t!("subtitle_partition"));
mountpoint_entry_row.set_title(&t!("title_mountpoint"));
mountopts_entry_row.set_title(&t!("title_mountopts"));
}
)
);
));
}
None => {
None => {}
}
}
}
)
);
));
obj.set_child(Some(&action_row_content_box));
}

View File

@ -24,7 +24,7 @@ impl DriveMountRow {
FstabEntry {
partition: self.partition(),
mountpoint: self.mountpoint(),
mountopts: self.mountopts()
mountopts: self.mountopts(),
}
}
}

View File

@ -1,7 +1,6 @@
use gtk::{prelude::*, glib as glib, Justification};
use glib::clone;
use gtk::{glib, prelude::*, Justification};
pub fn efi_error_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) {
let efi_error_main_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
@ -76,7 +75,6 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, main_carousel: &adw::Caro
exit_button.connect_clicked(clone!(
#[weak]
window,
move |_|
window.close()
move |_| window.close()
));
}

View File

@ -1,12 +1,9 @@
use adw::gio;
use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib};
use adw::gio;
use glib::{clone, closure_local};
use gtk::{glib, prelude::*};
pub fn eula_page(
main_carousel: &adw::Carousel,
language_changed_action: &gio::SimpleAction
) {
pub fn eula_page(main_carousel: &adw::Carousel, language_changed_action: &gio::SimpleAction) {
let eula_page = installer_stack_page::InstallerStackPage::new();
eula_page.set_page_icon("error-correct-symbolic");
eula_page.set_back_visible(true);
@ -20,8 +17,7 @@ pub fn eula_page(
.vexpand(true)
.build();
let eula_buffer = gtk::TextBuffer::builder()
.build();
let eula_buffer = gtk::TextBuffer::builder().build();
let eula_selection_text_view = gtk::TextView::builder()
.hexpand(true)
@ -45,29 +41,25 @@ pub fn eula_page(
.margin_end(15)
.build();
eula_accept_checkbutton.connect_toggled(
clone!(
eula_accept_checkbutton.connect_toggled(clone!(
#[weak]
eula_accept_checkbutton,
#[weak]
eula_page,
move |_|
{
move |_| {
if eula_accept_checkbutton.is_active() == true {
eula_page.set_next_sensitive(true);
} else {
eula_page.set_next_sensitive(false);
}
}
),
);
));
content_box.append(&eula_selection_text_scroll);
content_box.append(&eula_accept_checkbutton);
//
language_changed_action.connect_activate(
clone!(
language_changed_action.connect_activate(clone!(
#[weak]
eula_page,
#[weak]
@ -84,8 +76,7 @@ pub fn eula_page(
//
eula_buffer.set_text(&t!("eula_buffer"))
}
)
);
));
//
eula_page.set_child_widget(&content_box);
@ -96,11 +87,10 @@ pub fn eula_page(
closure_local!(
#[weak]
main_carousel,
move |_language_page: installer_stack_page::InstallerStackPage|
{
move |_language_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(1), true)
}
)
),
);
eula_page.connect_closure(
@ -109,11 +99,10 @@ pub fn eula_page(
closure_local!(
#[weak]
main_carousel,
move |_language_page: installer_stack_page::InstallerStackPage|
{
move |_language_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(3), true)
}
)
),
);
main_carousel.append(&eula_page);

View File

@ -1,7 +1,7 @@
use std::{cell::RefCell, rc::Rc, sync::OnceLock};
use gtk::{prelude::*, subclass::prelude::*, glib as glib, Justification};
use adw::{prelude::*, subclass::prelude::*};
use glib::{clone, subclass::Signal};
use gtk::{glib, prelude::*, subclass::prelude::*, Justification};
use std::{cell::RefCell, rc::Rc, sync::OnceLock};
// ANCHOR: custom_button
// Object holding the state
@ -45,7 +45,12 @@ impl ObjectSubclass for InstallerStackPage {
impl ObjectImpl for InstallerStackPage {
fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new();
SIGNALS.get_or_init(|| vec![Signal::builder("next-button-pressed").build(), Signal::builder("back-button-pressed").build()])
SIGNALS.get_or_init(|| {
vec![
Signal::builder("next-button-pressed").build(),
Signal::builder("back-button-pressed").build(),
]
})
}
fn constructed(&self) {
self.parent_constructed();
@ -210,9 +215,7 @@ impl ObjectImpl for InstallerStackPage {
obj,
#[weak]
child_bin,
move |_| {
child_bin.set_child(Some(&obj.property::<gtk::Box>("child_widget")))
}
move |_| { child_bin.set_child(Some(&obj.property::<gtk::Box>("child_widget"))) }
));
//

View File

@ -1,15 +1,15 @@
use crate::installer_stack_page;
use gnome_desktop::XkbInfoExt;
use gtk::{prelude::*, glib as glib, gio as gio};
use adw::{prelude::*};
use adw::prelude::*;
use glib::{clone, closure_local};
use std::{process::Command, fs, path::Path, rc::Rc, cell::RefCell};
use gnome_desktop::XkbInfoExt;
use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, fs, path::Path, process::Command, rc::Rc};
pub fn keyboard_page(
main_carousel: &adw::Carousel,
keymap_base_data_refcell: &Rc<RefCell<String>>,
keymap_variant_data_refcell: &Rc<RefCell<String>>,
language_changed_action: &gio::SimpleAction
language_changed_action: &gio::SimpleAction,
) {
let keyboard_page = installer_stack_page::InstallerStackPage::new();
keyboard_page.set_page_icon("keyboard-symbolic");
@ -24,8 +24,7 @@ pub fn keyboard_page(
.vexpand(true)
.build();
let null_checkbutton = gtk::CheckButton::builder()
.build();
let null_checkbutton = gtk::CheckButton::builder().build();
let keyboard_selection_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
@ -33,8 +32,7 @@ pub fn keyboard_page(
keyboard_selection_row_viewport_listbox.add_css_class("boxed-list");
keyboard_selection_row_viewport_listbox.add_css_class("round-border-only");
let keyboard_selection_row_viewport =
gtk::ScrolledWindow::builder()
let keyboard_selection_row_viewport = gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.has_frame(true)
@ -59,8 +57,7 @@ pub fn keyboard_page(
keyboard_test_entry_boxed_list.add_css_class("boxed-list");
let keyboard_test_entry = adw::EntryRow::builder()
.build();
let keyboard_test_entry = adw::EntryRow::builder().build();
keyboard_test_entry_boxed_list.append(&keyboard_test_entry);
@ -108,8 +105,7 @@ pub fn keyboard_page(
keymap_variant_data_refcell,
#[weak]
keyboard_page,
move |_|
{
move |_| {
if keymap_checkbutton.is_active() == true {
keyboard_page.set_next_sensitive(true);
if keymap_variant.is_empty() {
@ -149,13 +145,20 @@ pub fn keyboard_page(
keyboard_search_bar,
#[weak]
keyboard_selection_row_viewport_listbox,
move |_|
{
move |_| {
let mut counter = keyboard_selection_row_viewport_listbox.first_child();
while let Some(row) = counter {
if row.widget_name() == "AdwActionRow" {
if !keyboard_search_bar.text().is_empty() {
if row.property::<String>("subtitle").to_lowercase().contains(&keyboard_search_bar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&keyboard_search_bar.text().to_string().to_lowercase()) {
if row
.property::<String>("subtitle")
.to_lowercase()
.contains(&keyboard_search_bar.text().to_string().to_lowercase())
|| row
.property::<String>("title")
.to_lowercase()
.contains(&keyboard_search_bar.text().to_string().to_lowercase())
{
row.set_property("visible", true);
keyboard_search_bar.grab_focus();
} else {
@ -173,8 +176,7 @@ pub fn keyboard_page(
keyboard_page.set_child_widget(&content_box);
//
language_changed_action.connect_activate(
clone!(
language_changed_action.connect_activate(clone!(
#[weak]
keyboard_page,
#[weak]
@ -191,8 +193,7 @@ pub fn keyboard_page(
//
keyboard_test_entry.set_title(&t!("test_your_keyboard"))
}
)
);
));
//
keyboard_page.connect_closure(
@ -201,11 +202,10 @@ pub fn keyboard_page(
closure_local!(
#[weak]
main_carousel,
move |_keyboard_page: installer_stack_page::InstallerStackPage|
{
move |_keyboard_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(2), true)
}
)
),
);
keyboard_page.connect_closure(
@ -214,11 +214,10 @@ pub fn keyboard_page(
closure_local!(
#[weak]
main_carousel,
move |_keyboard_page: installer_stack_page::InstallerStackPage|
{
move |_keyboard_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(4), true)
}
)
),
);
main_carousel.append(&keyboard_page);

View File

@ -1,13 +1,13 @@
use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib, gio as gio};
use adw::{prelude::*};
use adw::prelude::*;
use glib::{clone, closure_local};
use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, env, fs, path::Path, process::Command, rc::Rc};
pub fn language_page(
main_carousel: &adw::Carousel,
lang_data_refcell: &Rc<RefCell<String>>,
language_changed_action: &gio::SimpleAction
language_changed_action: &gio::SimpleAction,
) {
let language_page = installer_stack_page::InstallerStackPage::new();
language_page.set_page_title(t!("select_a_language"));
@ -26,8 +26,7 @@ pub fn language_page(
.vexpand(true)
.build();
let null_checkbutton = gtk::CheckButton::builder()
.build();
let null_checkbutton = gtk::CheckButton::builder().build();
let language_selection_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
@ -35,8 +34,7 @@ pub fn language_page(
language_selection_row_viewport_listbox.add_css_class("boxed-list");
language_selection_row_viewport_listbox.add_css_class("round-all-scroll");
let language_selection_row_viewport =
gtk::ScrolledWindow::builder()
let language_selection_row_viewport = gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.has_frame(true)
@ -56,176 +54,39 @@ pub fn language_page(
language_search_bar.add_css_class("rounded-all-25");
let current_locale = match env::var_os("LANG") {
Some(v) => v.into_string().unwrap().chars()
Some(v) => v
.into_string()
.unwrap()
.chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
let locale_list = ["ab_GE",
"aa_DJ",
"af_ZA",
"ak_GH",
"sq_AL",
"am_ET",
"ar_EG",
"an_ES",
"hy_AM",
"as_IN",
"ar_AE",
"az_AZ",
"bs_BA",
"eu_ES",
"be_BY",
"bn_BD",
"ar_BH",
"bi_VU",
"bs_BA",
"br_FR",
"bg_BG",
"my_MM",
"ca_ES",
"de_CH",
"ce_RU",
"zh_CN",
"cv_RU",
"kw_GB",
"es_CO",
"es_CR",
"hr_HR",
"cs_CZ",
"da_DK",
"dv_MV",
"nl_NL",
"dz_BT",
"en_US",
"en_GB",
"eo",
"et_EE",
"et_EE",
"fo_FO",
"hif_FJ",
"fi_FI",
"fr_FR",
"ff_SN",
"gl_ES",
"ka_GE",
"de_DE",
"el_GR",
"gu_IN",
"ht_HT",
"ha_NG",
"he_IL",
"hi_IN",
"hu_HU",
"ia_FR",
"id_ID",
"en_IE",
"ga_IE",
"ig_NG",
"ik_CA",
"is_IS",
"it_IT",
"iu_CA",
"ja_JP",
"kl_GL",
"kn_IN",
"ko_KR",
"kk_KZ",
"km_KH",
"rw_RW",
"ky_KG",
"ky_KG",
"ko_KR",
"ku_TR",
"lo_LA",
"lb_LU",
"lg_UG",
"li_NL",
"ln_CD",
"lo_LA",
"lt_LT",
"fr_LU",
"lv_LV",
"gv_GB",
"mk_MK",
"mg_MG",
"ms_MY",
"ml_IN",
"mt_MT",
"mi_NZ",
"mr_IN",
"mn_MN",
"ne_NP",
"en_NG",
"nb_NO",
"nn_NO",
"no_NO",
"nr_ZA",
"oc_FR",
"es_CU",
"om_ET",
"or_IN",
"os_RU",
"pa_IN",
"fa_IR",
"pl_PL",
"ps_AF",
"pt_BR",
"ro_RO",
"ru_RU",
"sa_IN",
"sc_IT",
"sd_IN",
"se_NO",
"sm_WS",
"en_SG",
"sr_RS",
"gd_GB",
"wo_SN",
"si_LK",
"sk_SK",
"sl_SI",
"so_SO",
"st_ZA",
"es_ES",
"sw_KE",
"ss_ZA",
"sv_SE",
"ta_IN",
"te_IN",
"tg_TJ",
"th_TH",
"ti_ER",
"bo_CN",
"tk_TM",
"tl_PH",
"tn_ZA",
"to_TO",
"tr_TR",
"ts_ZA",
"tt_RU",
"zh_TW",
"ug_CN",
"uk_UA",
"ur_PK",
"ve_ZA",
"vi_VN",
"wa_BE",
"cy_GB",
"wo_SN",
"fy_NL",
"xh_ZA",
"yi_US",
"yo_NG",
"zu_ZA",
"zu_ZA",
"pt_BR",
"pt_PT",];
let locale_list = [
"ab_GE", "aa_DJ", "af_ZA", "ak_GH", "sq_AL", "am_ET", "ar_EG", "an_ES", "hy_AM", "as_IN",
"ar_AE", "az_AZ", "bs_BA", "eu_ES", "be_BY", "bn_BD", "ar_BH", "bi_VU", "bs_BA", "br_FR",
"bg_BG", "my_MM", "ca_ES", "de_CH", "ce_RU", "zh_CN", "cv_RU", "kw_GB", "es_CO", "es_CR",
"hr_HR", "cs_CZ", "da_DK", "dv_MV", "nl_NL", "dz_BT", "en_US", "en_GB", "eo", "et_EE",
"et_EE", "fo_FO", "hif_FJ", "fi_FI", "fr_FR", "ff_SN", "gl_ES", "ka_GE", "de_DE", "el_GR",
"gu_IN", "ht_HT", "ha_NG", "he_IL", "hi_IN", "hu_HU", "ia_FR", "id_ID", "en_IE", "ga_IE",
"ig_NG", "ik_CA", "is_IS", "it_IT", "iu_CA", "ja_JP", "kl_GL", "kn_IN", "ko_KR", "kk_KZ",
"km_KH", "rw_RW", "ky_KG", "ky_KG", "ko_KR", "ku_TR", "lo_LA", "lb_LU", "lg_UG", "li_NL",
"ln_CD", "lo_LA", "lt_LT", "fr_LU", "lv_LV", "gv_GB", "mk_MK", "mg_MG", "ms_MY", "ml_IN",
"mt_MT", "mi_NZ", "mr_IN", "mn_MN", "ne_NP", "en_NG", "nb_NO", "nn_NO", "no_NO", "nr_ZA",
"oc_FR", "es_CU", "om_ET", "or_IN", "os_RU", "pa_IN", "fa_IR", "pl_PL", "ps_AF", "pt_BR",
"ro_RO", "ru_RU", "sa_IN", "sc_IT", "sd_IN", "se_NO", "sm_WS", "en_SG", "sr_RS", "gd_GB",
"wo_SN", "si_LK", "sk_SK", "sl_SI", "so_SO", "st_ZA", "es_ES", "sw_KE", "ss_ZA", "sv_SE",
"ta_IN", "te_IN", "tg_TJ", "th_TH", "ti_ER", "bo_CN", "tk_TM", "tl_PH", "tn_ZA", "to_TO",
"tr_TR", "ts_ZA", "tt_RU", "zh_TW", "ug_CN", "uk_UA", "ur_PK", "ve_ZA", "vi_VN", "wa_BE",
"cy_GB", "wo_SN", "fy_NL", "xh_ZA", "yi_US", "yo_NG", "zu_ZA", "zu_ZA", "pt_BR", "pt_PT",
];
for locale in locale_list.iter() {
let locale = locale.to_string();
let locale_name = gnome_desktop::language_from_locale(&locale, None).unwrap_or(locale.clone().into()).to_string();
let locale_name = gnome_desktop::language_from_locale(&locale, None)
.unwrap_or(locale.clone().into())
.to_string();
let locale_clone = locale.clone();
let locale_checkbutton = gtk::CheckButton::builder()
.valign(gtk::Align::Center)
@ -246,8 +107,7 @@ pub fn language_page(
lang_data_refcell,
#[weak]
language_page,
move |_|
{
move |_| {
if locale_checkbutton.is_active() == true {
language_page.set_next_sensitive(true);
*lang_data_refcell.borrow_mut() = String::from(&locale);
@ -274,13 +134,20 @@ pub fn language_page(
language_search_bar,
#[weak]
language_selection_row_viewport_listbox,
move |_|
{
move |_| {
let mut counter = language_selection_row_viewport_listbox.first_child();
while let Some(row) = counter {
if row.widget_name() == "AdwActionRow" {
if !language_search_bar.text().is_empty() {
if row.property::<String>("subtitle").to_lowercase().contains(&language_search_bar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&language_search_bar.text().to_string().to_lowercase()) {
if row
.property::<String>("subtitle")
.to_lowercase()
.contains(&language_search_bar.text().to_string().to_lowercase())
|| row
.property::<String>("title")
.to_lowercase()
.contains(&language_search_bar.text().to_string().to_lowercase())
{
row.set_property("visible", true);
language_search_bar.grab_focus();
} else {
@ -303,11 +170,10 @@ pub fn language_page(
closure_local!(
#[weak]
main_carousel,
move |_language_page: installer_stack_page::InstallerStackPage|
{
move |_language_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(0), true)
}
)
),
);
language_page.connect_closure(
@ -320,8 +186,7 @@ pub fn language_page(
lang_data_refcell,
#[strong]
language_changed_action,
move |_language_page: installer_stack_page::InstallerStackPage|
{
move |_language_page: installer_stack_page::InstallerStackPage| {
let locale = &lang_data_refcell.borrow();
//Command::new("sudo")
// .arg("localectl")
@ -333,7 +198,7 @@ pub fn language_page(
language_changed_action.activate(None);
main_carousel.scroll_to(&main_carousel.nth_page(2), true)
}
)
),
);
main_carousel.append(&language_page);

View File

@ -1,22 +1,22 @@
use gdk::Display;
use gtk::{gdk, glib, prelude::*, CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION};
use std::env;
use gtk::{CssProvider, gdk, STYLE_PROVIDER_PRIORITY_APPLICATION, prelude::*, glib as glib};
use gdk::{Display};
mod config;
mod build_ui;
mod config;
mod efi_error_page;
mod installer_stack_page;
//
mod welcome_page;
mod language_page;
mod automatic_partitioning_page;
mod drive_mount_row;
mod eula_page;
mod keyboard_page;
mod timezone_page;
mod partitioning_page;
mod automatic_partitioning_page;
mod language_page;
mod manual_partitioning_page;
mod drive_mount_row;
mod partitioning_page;
mod timezone_page;
mod welcome_page;
#[macro_use]
extern crate rust_i18n;
@ -24,14 +24,19 @@ i18n!("locales", fallback = "en_US");
fn main() -> glib::ExitCode {
let current_locale = match env::var_os("LANG") {
Some(v) => v.into_string().unwrap().chars()
Some(v) => v
.into_string()
.unwrap()
.chars()
.take_while(|&ch| ch != '.')
.collect::<String>(),
None => panic!("$LANG is not set"),
};
rust_i18n::set_locale(&current_locale);
let app = adw::Application::builder().application_id(config::APP_ID).build();
let app = adw::Application::builder()
.application_id(config::APP_ID)
.build();
app.connect_startup(|app| {
load_css();

View File

@ -1,99 +0,0 @@
use adw::gio;
use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib};
use crate::partitioning_page::{get_block_devices};
use adw::{prelude::*};
use glib::{clone, closure_local, ffi::gboolean};
use std::{rc::Rc, cell::RefCell};
const MINIMUM_EFI_BYTE_SIZE: f64 = 500000000.0;
const MINIMUM_BOOT_BYTE_SIZE: f64 = 1000000000.0;
const MINIMUM_ROOT_BYTE_SIZE: f64 = 39000000000.0;
pub fn manual_partitioning(
partition_carousel: &adw::Carousel,
partition_method_type_refcell: &Rc<RefCell<String>>,
partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<String>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<String>>,
language_changed_action: &gio::SimpleAction
) {
let manual_partitioning_page = installer_stack_page::InstallerStackPage::new();
manual_partitioning_page.set_page_icon("emblem-system-symbolic");
manual_partitioning_page.set_back_visible(true);
manual_partitioning_page.set_next_visible(true);
manual_partitioning_page.set_back_sensitive(true);
manual_partitioning_page.set_next_sensitive(false);
//
let content_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.hexpand(true)
.vexpand(true)
.build();
//
manual_partitioning_page.connect_closure(
"back-button-pressed",
false,
closure_local!(
#[weak]
partition_carousel,
move |_manual_partitioning_page: installer_stack_page::InstallerStackPage|
{
partition_carousel.scroll_to(&partition_carousel.nth_page(0), true)
}
)
);
manual_partitioning_page.connect_closure(
"next-button-pressed",
false,
closure_local!(
#[weak]
partition_carousel,
#[strong]
partition_method_type_refcell,
#[strong]
partition_method_manual_fstab_entry_array_refcell,
#[strong]
partition_method_manual_luks_enabled_refcell,
#[strong]
partition_method_manual_crypttab_entry_array_refcell,
move |_automatic_partitioning_page: installer_stack_page::InstallerStackPage|
{
*partition_method_type_refcell.borrow_mut() = String::from("automatic");
//partition_carousel.scroll_to(&partition_carousel.nth_page(5), true)
dbg!(partition_method_type_refcell.borrow());
dbg!(partition_method_manual_fstab_entry_array_refcell.borrow());
dbg!(partition_method_manual_luks_enabled_refcell.borrow());
dbg!(partition_method_manual_crypttab_entry_array_refcell.borrow());
}
)
);
//
//
manual_partitioning_page.set_child_widget(&content_box);
partition_carousel.append(&manual_partitioning_page);
//
language_changed_action.connect_activate(clone!(
#[weak]
manual_partitioning_page,
move |_, _| {
manual_partitioning_page.set_page_title(t!("auto_part_installer"));
manual_partitioning_page.set_page_subtitle(t!("choose_drive_auto"));
manual_partitioning_page.set_back_tooltip_label(t!("back"));
manual_partitioning_page.set_next_tooltip_label(t!("next"));
}
)
);
//
}

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
use crate::drive_mount_row::DriveMountRow;
use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib, gio as gio};
use glib::{clone, closure_local, Properties};
use crate::{automatic_partitioning_page, manual_partitioning_page};
use std::{rc::Rc, cell::RefCell};
use glib::{clone, closure_local, Properties};
use gtk::{gio, glib, prelude::*};
use std::io::BufRead;
use std::{cell::RefCell, rc::Rc};
pub fn partitioning_page(
main_carousel: &adw::Carousel,
@ -18,7 +18,7 @@ pub fn partitioning_page(
partition_method_manual_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
language_changed_action: &gio::SimpleAction
language_changed_action: &gio::SimpleAction,
) {
let partitioning_page = installer_stack_page::InstallerStackPage::new();
partitioning_page.set_page_icon("media-floppy-symbolic");
@ -46,31 +46,23 @@ pub fn partitioning_page(
content_box.add_css_class("linked");
let automatic_method_button = gtk::Button::builder()
.icon_name("builder")
.build();
let automatic_method_button = gtk::Button::builder().icon_name("builder").build();
let manual_method_button = gtk::Button::builder()
.icon_name("emblem-system-symbolics")
.build();
automatic_method_button.connect_clicked(
clone!(
automatic_method_button.connect_clicked(clone!(
#[weak]
partitioning_carousel,
move |_|
partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(1), true)
)
);
move |_| partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(1), true)
));
manual_method_button.connect_clicked(
clone!(
manual_method_button.connect_clicked(clone!(
#[weak]
partitioning_carousel,
move |_|
partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(2), true)
)
);
move |_| partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(2), true)
));
content_box.append(&automatic_method_button);
content_box.append(&manual_method_button);
@ -78,8 +70,7 @@ pub fn partitioning_page(
partitioning_page.set_child_widget(&content_box);
//
language_changed_action.connect_activate(
clone!(
language_changed_action.connect_activate(clone!(
#[weak]
partitioning_page,
move |_, _| {
@ -92,8 +83,7 @@ pub fn partitioning_page(
//
manual_method_button.set_label(&t!("manual_partition_drive"));
}
)
);
));
//
partitioning_carousel.append(&partitioning_page);
@ -106,14 +96,16 @@ pub fn partitioning_page(
&partition_method_automatic_luks_refcell,
&partition_method_automatic_ratio_refcell,
&partition_method_automatic_seperation_refcell,
&language_changed_action);
&language_changed_action,
);
manual_partitioning_page::manual_partitioning_page(
&partitioning_carousel,
&partition_method_type_refcell,
&partition_method_manual_fstab_entry_array_refcell,
&partition_method_manual_luks_enabled_refcell,
&partition_method_manual_crypttab_entry_array_refcell,
&language_changed_action);
&language_changed_action,
);
partitioning_page.connect_closure(
"back-button-pressed",
@ -121,11 +113,10 @@ pub fn partitioning_page(
closure_local!(
#[weak]
main_carousel,
move |_partitioning_page: installer_stack_page::InstallerStackPage|
{
move |_partitioning_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(4), true)
}
)
),
);
main_carousel.append(&partitioning_carousel)
@ -134,7 +125,7 @@ pub fn partitioning_page(
pub struct BlockDevice {
pub block_name: String,
pub block_size: f64,
pub block_size_pretty: String
pub block_size_pretty: String,
}
#[derive(Clone)]
@ -144,7 +135,7 @@ pub struct Partition {
pub has_encryption: bool,
pub need_mapper: bool,
pub part_size: f64,
pub part_size_pretty: String
pub part_size_pretty: String,
}
#[derive(Default)]
@ -168,9 +159,10 @@ pub fn get_block_devices() -> Vec<BlockDevice> {
.arg("get_block_devices")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn() {
.spawn()
{
Ok(t) => t,
Err(_) => return block_devices
Err(_) => return block_devices,
};
match command.stdout {
@ -179,19 +171,17 @@ pub fn get_block_devices() -> Vec<BlockDevice> {
match blockdev {
Ok(r) => {
let block_size = get_block_size(&r);
block_devices.push(
BlockDevice {
block_devices.push(BlockDevice {
block_name: r,
block_size: block_size,
block_size_pretty: pretty_bytes::converter::convert(block_size)
block_size_pretty: pretty_bytes::converter::convert(block_size),
})
}
)
}
Err(_) => return block_devices
Err(_) => return block_devices,
}
}
},
None => return block_devices
}
None => return block_devices,
};
block_devices
@ -202,15 +192,14 @@ fn get_block_size(block_dev: &str) -> f64 {
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_block_size")
.arg(block_dev)
.output() {
.output()
{
Ok(t) => t,
Err(_) => return 0.0
Err(_) => return 0.0,
};
let size = match String::from_utf8(command.stdout) {
Ok(t) => {
t.trim().parse::<f64>().unwrap_or(0.0)
}
Err(_) => 0.0
Ok(t) => t.trim().parse::<f64>().unwrap_or(0.0),
Err(_) => 0.0,
};
size
@ -224,9 +213,10 @@ pub fn get_partitions() -> Vec<Partition> {
.arg("get_partitions")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn() {
.spawn()
{
Ok(t) => t,
Err(_) => return partitions
Err(_) => return partitions,
};
match command.stdout {
@ -236,22 +226,20 @@ pub fn get_partitions() -> Vec<Partition> {
Ok(r) => {
let part_size = get_part_size(&r);
let part_fs = get_part_fs(&r);
partitions.push(
Partition {
partitions.push(Partition {
has_encryption: is_encrypted(&r),
need_mapper: is_needs_mapper(&part_fs),
part_name: r,
part_fs: part_fs,
part_size: part_size,
part_size_pretty: pretty_bytes::converter::convert(part_size)
part_size_pretty: pretty_bytes::converter::convert(part_size),
})
}
)
}
Err(_) => return partitions
Err(_) => return partitions,
}
}
},
None => return partitions
}
None => return partitions,
};
partitions
@ -262,15 +250,14 @@ fn get_part_size(part_dev: &str) -> f64 {
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_part_size")
.arg(part_dev)
.output() {
.output()
{
Ok(t) => t,
Err(_) => return 0.0
Err(_) => return 0.0,
};
let size = match String::from_utf8(command.stdout) {
Ok(t) => {
t.trim().parse::<f64>().unwrap_or(0.0)
}
Err(_) => 0.0
Ok(t) => t.trim().parse::<f64>().unwrap_or(0.0),
Err(_) => 0.0,
};
size
@ -281,22 +268,21 @@ fn get_part_fs(part_dev: &str) -> String {
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_part_fs")
.arg(part_dev.replace("mapper/", ""))
.output() {
.output()
{
Ok(t) => t,
Err(_) => return String::from(t!("fs_unknown"))
Err(_) => return String::from(t!("fs_unknown")),
};
let fs = match String::from_utf8(command.stdout) {
Ok(t) => {
t.trim().to_owned()
}
Err(_) => String::from(t!("fs_unknown"))
Ok(t) => t.trim().to_owned(),
Err(_) => String::from(t!("fs_unknown")),
};
fs
}
fn is_needs_mapper(part_fs: &str) -> bool {
if part_fs.contains("crypto_LUKS") || part_fs.contains("lvm") {
if part_fs.contains("crypto_LUKS") || part_fs.contains("lvm") || part_fs.contains("BitLocker") {
true
} else {
false
@ -308,9 +294,10 @@ fn is_encrypted(part_dev: &str) -> bool {
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("has_encryption")
.arg(part_dev)
.output() {
.output()
{
Ok(t) => t,
Err(_) => return false
Err(_) => return false,
};
if command.status.success() {

View File

@ -1,14 +1,14 @@
use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib, gio as gio};
use adw::{prelude::*};
use adw::prelude::*;
use glib::{clone, closure_local};
use std::{process::Command, fs, path::Path, rc::Rc, cell::RefCell};
use gtk::{gio, glib, prelude::*};
use std::io::BufRead;
use std::{cell::RefCell, fs, path::Path, process::Command, rc::Rc};
pub fn timezone_page(
main_carousel: &adw::Carousel,
timezone_data_refcell: &Rc<RefCell<String>>,
language_changed_action: &gio::SimpleAction
language_changed_action: &gio::SimpleAction,
) {
let timezone_page = installer_stack_page::InstallerStackPage::new();
timezone_page.set_page_icon("alarm-symbolic");
@ -23,8 +23,7 @@ pub fn timezone_page(
.vexpand(true)
.build();
let null_checkbutton = gtk::CheckButton::builder()
.build();
let null_checkbutton = gtk::CheckButton::builder().build();
let timezone_selection_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None)
@ -32,8 +31,7 @@ pub fn timezone_page(
timezone_selection_row_viewport_listbox.add_css_class("boxed-list");
timezone_selection_row_viewport_listbox.add_css_class("round-all-scroll");
let timezone_selection_row_viewport =
gtk::ScrolledWindow::builder()
let timezone_selection_row_viewport = gtk::ScrolledWindow::builder()
.vexpand(true)
.hexpand(true)
.has_frame(true)
@ -62,7 +60,9 @@ pub fn timezone_page(
.unwrap_or_else(|e| panic!("failed {}", e));
let current_timezone_output = current_timezone_cli.wait_with_output().unwrap();
let current_timezone = String::from_utf8_lossy(&current_timezone_output.stdout).trim().to_owned();
let current_timezone = String::from_utf8_lossy(&current_timezone_output.stdout)
.trim()
.to_owned();
let timezone_cli = Command::new("timedatectl")
.arg("list-timezones")
@ -88,23 +88,20 @@ pub fn timezone_page(
timezone_row.add_prefix(&timezone_checkbutton);
timezone_checkbutton.set_group(Some(&null_checkbutton));
timezone_selection_row_viewport_listbox.append(&timezone_row);
timezone_checkbutton.connect_toggled(
clone!(
timezone_checkbutton.connect_toggled(clone!(
#[weak]
timezone_checkbutton,
#[weak]
timezone_page,
#[weak]
timezone_data_refcell,
move |_|
{
move |_| {
if timezone_checkbutton.is_active() == true {
timezone_page.set_next_sensitive(true);
*timezone_data_refcell.borrow_mut() = String::from(&timezone);
}
}
)
);
));
if &current_timezone == &timezone_clone {
timezone_checkbutton.set_active(true);
}
@ -120,13 +117,20 @@ pub fn timezone_page(
timezone_search_bar,
#[weak]
timezone_selection_row_viewport_listbox,
move |_|
{
move |_| {
let mut counter = timezone_selection_row_viewport_listbox.first_child();
while let Some(row) = counter {
if row.widget_name() == "AdwActionRow" {
if !timezone_search_bar.text().is_empty() {
if row.property::<String>("subtitle").to_lowercase().contains(&timezone_search_bar.text().to_string().to_lowercase()) || row.property::<String>("title").to_lowercase().contains(&timezone_search_bar.text().to_string().to_lowercase()) {
if row
.property::<String>("subtitle")
.to_lowercase()
.contains(&timezone_search_bar.text().to_string().to_lowercase())
|| row
.property::<String>("title")
.to_lowercase()
.contains(&timezone_search_bar.text().to_string().to_lowercase())
{
row.set_property("visible", true);
timezone_search_bar.grab_focus();
} else {
@ -144,8 +148,7 @@ pub fn timezone_page(
timezone_page.set_child_widget(&content_box);
//
language_changed_action.connect_activate(
clone!(
language_changed_action.connect_activate(clone!(
#[weak]
timezone_page,
#[weak]
@ -158,8 +161,7 @@ pub fn timezone_page(
//
timezone_search_bar.set_placeholder_text(Some(&t!("search_for_timezone")));
}
)
);
));
//
timezone_page.connect_closure(
@ -168,11 +170,10 @@ pub fn timezone_page(
closure_local!(
#[weak]
main_carousel,
move |_timezone_page: installer_stack_page::InstallerStackPage|
{
move |_timezone_page: installer_stack_page::InstallerStackPage| {
main_carousel.scroll_to(&main_carousel.nth_page(3), true)
}
)
),
);
timezone_page.connect_closure(
@ -183,8 +184,7 @@ pub fn timezone_page(
main_carousel,
#[strong]
timezone_data_refcell,
move |_timezone_page: installer_stack_page::InstallerStackPage|
{
move |_timezone_page: installer_stack_page::InstallerStackPage| {
let timezone = timezone_data_refcell.borrow();
Command::new("sudo")
.arg("timedatectl")
@ -194,7 +194,7 @@ pub fn timezone_page(
.expect("timezone failed to start");
main_carousel.scroll_to(&main_carousel.nth_page(5), true)
}
)
),
);
main_carousel.append(&timezone_page);

View File

@ -1,11 +1,8 @@
use crate::installer_stack_page;
use crate::config;
use gtk::{prelude::*, glib as glib};
use crate::installer_stack_page;
use glib::clone;
pub fn welcome_page(
window: &adw::ApplicationWindow,
main_carousel: &adw::Carousel,
) {
use gtk::{glib, prelude::*};
pub fn welcome_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) {
let welcome_page = installer_stack_page::InstallerStackPage::new();
welcome_page.set_page_title(t!("welcome"));
welcome_page.set_page_subtitle(t!("welcome_to_pikaos"));
@ -34,23 +31,17 @@ pub fn welcome_page(
.label(t!("install_distro_to_system"))
.build();
install_media_button.connect_clicked(
clone!(
install_media_button.connect_clicked(clone!(
#[weak]
main_carousel,
move |_|
main_carousel.scroll_to(&main_carousel.nth_page(1), true)
)
);
move |_| main_carousel.scroll_to(&main_carousel.nth_page(1), true)
));
live_media_button.connect_clicked(
clone!(
live_media_button.connect_clicked(clone!(
#[weak]
window,
move |_|
window.close()
)
);
move |_| window.close()
));
content_box.append(&install_media_button);
content_box.append(&live_media_button);