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_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_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_badfs": "Filesystem Table Error: Invalid filesystem: (/dev/",
"fstab_small_efi_size": ") Must at least be 512MBs!", "fstab_small_efi_size": "EFI Must at least be 512MBs!",
"fstab_badfs_efi": ") Must be FAT32/vFAT to be mounted at /boot/efi!", "fstab_badfs_efi": "EFI Must be FAT32/vFAT",
"fstab_small_boot_size": ") Must at least be 1GBs!", "fstab_small_boot_size": "Boot Must at least be 1GBs!",
"fstab_badfs_boot": ") Must not be FAT32/vFAT to be mounted at /boot!", "fstab_badfs_boot": "Boot Must be EXT4",
"fstab_small_root_size": ") Must at least be 26GBs!", "fstab_small_root_size": "Root 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_badfs_root": "Root Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs",
"fstab_small_home_size": ") Must at least be 11GBs!", "fstab_badfs_swap": "Swap must be linux-swap",
"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_bad_mountpoint": "Filesystem Table Error: Invalid mountpoint: (", "fstab_bad_mountpoint": "Filesystem Table Error: Invalid mountpoint: (",
"fstab_bad_mountpoint_msg": ") Is not a valid mountpoint!", "fstab_bad_mountpoint_msg": ") Is not a valid mountpoint!",
"select_a_language": "Select a Language", "select_a_language": "Select a Language",

View File

@ -1,10 +1,10 @@
use adw::gio;
use crate::installer_stack_page; use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib}; use crate::partitioning_page::get_block_devices;
use crate::partitioning_page::{get_block_devices}; use adw::gio;
use adw::{prelude::*}; use adw::prelude::*;
use glib::{clone, closure_local, ffi::gboolean}; 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 BOOT_AND_EFI_BYTE_SIZE: f64 = 1611661312.0;
const MINIMUM_ROOT_BYTE_SIZE: f64 = 39000000000.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_luks_refcell: &Rc<RefCell<String>>,
partition_method_automatic_ratio_refcell: &Rc<RefCell<f64>>, partition_method_automatic_ratio_refcell: &Rc<RefCell<f64>>,
partition_method_automatic_seperation_refcell: &Rc<RefCell<String>>, 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(); let automatic_partitioning_page = installer_stack_page::InstallerStackPage::new();
automatic_partitioning_page.set_page_icon("builder"); automatic_partitioning_page.set_page_icon("builder");
@ -41,8 +41,7 @@ pub fn automatic_partitioning_page(
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
.build(); .build();
let advanced_box_viewport = let advanced_box_viewport = gtk::ScrolledWindow::builder()
gtk::ScrolledWindow::builder()
.vexpand(true) .vexpand(true)
.hexpand(true) .hexpand(true)
.child(&advanced_box) .child(&advanced_box)
@ -54,13 +53,11 @@ pub fn automatic_partitioning_page(
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
.build(); .build();
let advanced_home_part_ratio_label_root = gtk::Label::builder() let advanced_home_part_ratio_label_root = gtk::Label::builder().build();
.build();
advanced_home_part_ratio_label_root.add_css_class("accent-text"); advanced_home_part_ratio_label_root.add_css_class("accent-text");
let advanced_home_part_ratio_label_home = gtk::Label::builder() let advanced_home_part_ratio_label_home = gtk::Label::builder().build();
.build();
advanced_home_part_ratio_label_home.add_css_class("green-text"); advanced_home_part_ratio_label_home.add_css_class("green-text");
@ -71,20 +68,27 @@ pub fn automatic_partitioning_page(
.margin_bottom(5) .margin_bottom(5)
.build(); .build();
let advanced_home_part_ratio_selection_slider= gtk::Scale::builder() let advanced_home_part_ratio_selection_slider = gtk::Scale::builder().draw_value(false).build();
.draw_value(false)
.build();
advanced_home_part_ratio_selection_slider.add_css_class("green-trough"); 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_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 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| { advanced_home_part_ratio_selection_slider.connect_change_value(move |slider, _, value| {
let home_size: f64 = slider.adjustment().upper() + 10000000000.0 - 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_root_clone0.set_label(&format!(
advanced_home_part_ratio_label_home_clone0.set_label(&format!("{}: {}", t!("Home Part Size"), pretty_bytes::converter::convert(home_size.into()))); "{}: {}",
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; *partition_method_automatic_ratio_refcell_clone0.borrow_mut() = value;
glib::Propagation::Proceed glib::Propagation::Proceed
}); });
@ -104,18 +108,18 @@ pub fn automatic_partitioning_page(
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("subvol"); *partition_method_automatic_seperation_refcell.borrow_mut() = String::from("subvol");
let advanced_home_seperation_selection_checkbutton_subvol = gtk::CheckButton::builder() let advanced_home_seperation_selection_checkbutton_subvol =
.active(true) gtk::CheckButton::builder().active(true).build();
.build();
let advanced_home_seperation_selection_checkbutton_partition = gtk::CheckButton::builder() let advanced_home_seperation_selection_checkbutton_partition =
.build(); gtk::CheckButton::builder().build();
let advanced_home_seperation_selection_checkbutton_none = gtk::CheckButton::builder() let advanced_home_seperation_selection_checkbutton_none = gtk::CheckButton::builder().build();
.build();
advanced_home_seperation_selection_checkbutton_partition.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol)); advanced_home_seperation_selection_checkbutton_partition
advanced_home_seperation_selection_checkbutton_none.set_group(Some(&advanced_home_seperation_selection_checkbutton_subvol)); .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 advanced_home_seperation_selection_checkbutton_partition
.bind_property( .bind_property(
@ -129,32 +133,26 @@ pub fn automatic_partitioning_page(
advanced_home_seperation_selection_checkbutton_subvol.connect_toggled(clone!( advanced_home_seperation_selection_checkbutton_subvol.connect_toggled(clone!(
#[strong] #[strong]
partition_method_automatic_seperation_refcell, partition_method_automatic_seperation_refcell,
move |_| move |_| {
{
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("subvol"); *partition_method_automatic_seperation_refcell.borrow_mut() = String::from("subvol");
} }
) ));
);
advanced_home_seperation_selection_checkbutton_partition.connect_toggled(clone!( advanced_home_seperation_selection_checkbutton_partition.connect_toggled(clone!(
#[strong] #[strong]
partition_method_automatic_seperation_refcell, partition_method_automatic_seperation_refcell,
move |_| move |_| {
{
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("partition"); *partition_method_automatic_seperation_refcell.borrow_mut() = String::from("partition");
} }
) ));
);
advanced_home_seperation_selection_checkbutton_none.connect_toggled(clone!( advanced_home_seperation_selection_checkbutton_none.connect_toggled(clone!(
#[strong] #[strong]
partition_method_automatic_seperation_refcell, partition_method_automatic_seperation_refcell,
move |_| move |_| {
{
*partition_method_automatic_seperation_refcell.borrow_mut() = String::from("none"); *partition_method_automatic_seperation_refcell.borrow_mut() = String::from("none");
} }
) ));
);
// //
@ -176,13 +174,11 @@ pub fn automatic_partitioning_page(
.active(true) .active(true)
.build(); .build();
let advanced_filesystem_selection_checkbutton_ext4 = gtk::CheckButton::builder() let advanced_filesystem_selection_checkbutton_ext4 =
.label("EXT4") gtk::CheckButton::builder().label("EXT4").build();
.build();
let advanced_filesystem_selection_checkbutton_xfs = gtk::CheckButton::builder() let advanced_filesystem_selection_checkbutton_xfs =
.label("XFS") gtk::CheckButton::builder().label("XFS").build();
.build();
advanced_filesystem_selection_checkbutton_btrfs advanced_filesystem_selection_checkbutton_btrfs
.bind_property( .bind_property(
@ -196,12 +192,10 @@ pub fn automatic_partitioning_page(
advanced_filesystem_selection_checkbutton_btrfs.connect_toggled(clone!( advanced_filesystem_selection_checkbutton_btrfs.connect_toggled(clone!(
#[strong] #[strong]
partition_method_automatic_target_fs_refcell, partition_method_automatic_target_fs_refcell,
move |_| move |_| {
{
*partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("btrfs"); *partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("btrfs");
} }
) ));
);
advanced_filesystem_selection_checkbutton_ext4.connect_toggled(clone!( advanced_filesystem_selection_checkbutton_ext4.connect_toggled(clone!(
#[weak] #[weak]
@ -212,15 +206,15 @@ pub fn automatic_partitioning_page(
advanced_home_seperation_selection_checkbutton_partition, advanced_home_seperation_selection_checkbutton_partition,
#[strong] #[strong]
partition_method_automatic_target_fs_refcell, 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) advanced_home_seperation_selection_checkbutton_partition.set_active(true)
} }
*partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("ext4"); *partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("ext4");
} }
) ));
);
advanced_filesystem_selection_checkbutton_xfs.connect_toggled(clone!( advanced_filesystem_selection_checkbutton_xfs.connect_toggled(clone!(
#[weak] #[weak]
@ -231,19 +225,20 @@ pub fn automatic_partitioning_page(
advanced_home_seperation_selection_checkbutton_partition, advanced_home_seperation_selection_checkbutton_partition,
#[strong] #[strong]
partition_method_automatic_target_fs_refcell, 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) advanced_home_seperation_selection_checkbutton_partition.set_active(true)
} }
*partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("xfs"); *partition_method_automatic_target_fs_refcell.borrow_mut() = String::from("xfs");
} }
) ));
);
advanced_filesystem_selection_checkbutton_ext4
advanced_filesystem_selection_checkbutton_ext4.set_group(Some(&advanced_filesystem_selection_checkbutton_btrfs)); .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_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() let devices_selection_expander_row = adw::ExpanderRow::builder().build();
.build();
let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder() let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .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("boxed-list");
devices_selection_expander_row_viewport_box.add_css_class("round-all-scroll"); devices_selection_expander_row_viewport_box.add_css_class("round-all-scroll");
let devices_selection_expander_row_viewport = let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder()
gtk::ScrolledWindow::builder()
.vexpand(true) .vexpand(true)
.hexpand(true) .hexpand(true)
.has_frame(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(); .build();
device_row.add_prefix(&device_button); device_row.add_prefix(&device_button);
devices_selection_expander_row_viewport_box.append(&device_row); devices_selection_expander_row_viewport_box.append(&device_row);
device_button.connect_toggled( device_button.connect_toggled(clone!(
clone!(
#[weak] #[weak]
device_button, device_button,
#[weak] #[weak]
@ -403,7 +400,13 @@ pub fn automatic_partitioning_page(
#[weak] #[weak]
automatic_partitioning_page, automatic_partitioning_page,
move |_| { 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); partition_method_automatic_disk_nodisk_error_label.set_visible(false);
let usable_disk_space = device.block_size - BOOT_AND_EFI_BYTE_SIZE; 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 { let default_root_size = if (usable_disk_space * 40.0) / 100.0 > 100000000000.0 {
@ -413,22 +416,25 @@ pub fn automatic_partitioning_page(
} else { } else {
(usable_disk_space * 40.0) / 100.0 (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.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()]); advanced_home_part_ratio_selection_slider.emit_by_name_with_values(
*partition_method_automatic_target_refcell.borrow_mut() = String::from(&device.block_name); "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) { if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true) automatic_partitioning_page.set_next_sensitive(true)
} else { } else {
automatic_partitioning_page.set_next_sensitive(false) automatic_partitioning_page.set_next_sensitive(false)
} }
} }
) ));
);
} }
partition_method_automatic_luks_checkbutton.connect_toggled( partition_method_automatic_luks_checkbutton.connect_toggled(clone!(
clone!(
#[strong] #[strong]
partition_method_automatic_luks_missmatch_error_label, partition_method_automatic_luks_missmatch_error_label,
#[strong] #[strong]
@ -450,18 +456,22 @@ pub fn automatic_partitioning_page(
true => *partition_method_automatic_luks_enabled_refcell.borrow_mut() = true, true => *partition_method_automatic_luks_enabled_refcell.borrow_mut() = true,
false => *partition_method_automatic_luks_enabled_refcell.borrow_mut() = false, 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) { if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true) automatic_partitioning_page.set_next_sensitive(true)
} else { } else {
automatic_partitioning_page.set_next_sensitive(false) automatic_partitioning_page.set_next_sensitive(false)
} }
} }
) ));
);
partition_method_automatic_luks_password_entry.connect_changed( partition_method_automatic_luks_password_entry.connect_changed(clone!(
clone!(
#[weak] #[weak]
partition_method_automatic_luks_missmatch_error_label, partition_method_automatic_luks_missmatch_error_label,
#[weak] #[weak]
@ -479,19 +489,24 @@ pub fn automatic_partitioning_page(
#[weak] #[weak]
automatic_partitioning_page, automatic_partitioning_page,
move |_| { move |_| {
*partition_method_automatic_luks_refcell.borrow_mut() = String::from(partition_method_automatic_luks_password_entry.text()); *partition_method_automatic_luks_refcell.borrow_mut() =
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); 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) { if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true) automatic_partitioning_page.set_next_sensitive(true)
} else { } else {
automatic_partitioning_page.set_next_sensitive(false) automatic_partitioning_page.set_next_sensitive(false)
} }
} }
) ));
);
partition_method_automatic_luks_password_confirm_entry.connect_changed( partition_method_automatic_luks_password_confirm_entry.connect_changed(clone!(
clone!(
#[weak] #[weak]
partition_method_automatic_luks_missmatch_error_label, partition_method_automatic_luks_missmatch_error_label,
#[weak] #[weak]
@ -509,30 +524,40 @@ pub fn automatic_partitioning_page(
#[weak] #[weak]
automatic_partitioning_page, automatic_partitioning_page,
move |_| { move |_| {
*partition_method_automatic_luks_refcell.borrow_mut() = String::from(partition_method_automatic_luks_password_entry.text()); *partition_method_automatic_luks_refcell.borrow_mut() =
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); 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) { if check_for_errors(&error_labels) {
automatic_partitioning_page.set_next_sensitive(true) automatic_partitioning_page.set_next_sensitive(true)
} else { } else {
automatic_partitioning_page.set_next_sensitive(false) automatic_partitioning_page.set_next_sensitive(false)
} }
} }
) ));
);
// //
devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row); 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_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_checkbutton);
partition_method_automatic_luks_box.append(&partition_method_automatic_luks_listbox); 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
advanced_home_seperation_selection_box.append(&advanced_home_seperation_selection_checkbutton_partition); .append(&advanced_home_seperation_selection_checkbutton_subvol);
advanced_home_seperation_selection_box.append(&advanced_home_seperation_selection_checkbutton_none); 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_btrfs);
advanced_filesystem_selection_box.append(&advanced_filesystem_selection_checkbutton_ext4); advanced_filesystem_selection_box.append(&advanced_filesystem_selection_checkbutton_ext4);
@ -560,11 +585,10 @@ pub fn automatic_partitioning_page(
closure_local!( closure_local!(
#[weak] #[weak]
partition_carousel, 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) partition_carousel.scroll_to(&partition_carousel.nth_page(0), true)
} }
) ),
); );
automatic_partitioning_page.connect_closure( automatic_partitioning_page.connect_closure(
@ -587,8 +611,7 @@ pub fn automatic_partitioning_page(
partition_method_automatic_ratio_refcell, partition_method_automatic_ratio_refcell,
#[strong] #[strong]
partition_method_automatic_seperation_refcell, 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_method_type_refcell.borrow_mut() = String::from("automatic");
//partition_carousel.scroll_to(&partition_carousel.nth_page(5), true) //partition_carousel.scroll_to(&partition_carousel.nth_page(5), true)
dbg!(partition_method_type_refcell.borrow()); 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_ratio_refcell.borrow());
dbg!(partition_method_automatic_seperation_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_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")); 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_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_expander.set_label(Some(&t!("advanced_options")));
// //
advanced_filesystem_selection_frame.set_label(Some(&t!("choose_fs_auto"))); 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 { if device_button.is_active() == true {
devices_selection_expander_row.set_title(device_block_name); devices_selection_expander_row.set_title(device_block_name);
if device_block_size >= MINIMUM_ROOT_BYTE_SIZE { 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_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) partition_method_automatic_luks_missmatch_error_label.set_visible(true)
} else { } else {
partition_method_automatic_luks_missmatch_error_label.set_visible(false) 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); partition_method_automatic_luks_empty_error_label.set_visible(true);
} else { } else {
partition_method_automatic_luks_empty_error_label.set_visible(false); 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 { fn check_for_errors(error_labels: &[gtk::Label]) -> bool {
for label in error_labels { for label in error_labels {
if label.is_visible() { if label.is_visible() {
return false return false;
} }
} }
true true

View File

@ -1,6 +1,10 @@
use std::{path::Path, rc::Rc, cell::RefCell}; use crate::{
use gtk::{prelude::*, glib as glib, gio as gio}; efi_error_page, eula_page, keyboard_page, language_page,
use crate::{efi_error_page, eula_page, keyboard_page, language_page, partitioning_page::{self, CrypttabEntry, FstabEntry}, timezone_page, welcome_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) { pub fn build_ui(app: &adw::Application) {
glib::set_prgname(Some("pikaos_installer")); 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() { match Path::new("/sys/firmware/efi/efivars").exists() {
true => welcome_page::welcome_page(&window, &carousel), 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()); 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 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 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_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_refcell: Rc<RefCell<String>> =
let partition_method_automatic_target_fs_refcell: Rc<RefCell<String>> = Rc::new(RefCell::default()); Rc::new(RefCell::default());
let partition_method_automatic_luks_enabled_refcell: Rc<RefCell<bool>> = Rc::new(RefCell::new(false)); 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_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_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_automatic_seperation_refcell: Rc<RefCell<String>> =
let partition_method_manual_fstab_entry_array_refcell: Rc<RefCell<Vec<FstabEntry>>> = Rc::new(RefCell::new(Vec::new())); Rc::new(RefCell::default());
let partition_method_manual_luks_enabled_refcell: Rc<RefCell<bool>> = Rc::new(RefCell::new(false)); let partition_method_manual_fstab_entry_array_refcell: Rc<RefCell<Vec<FstabEntry>>> =
let partition_method_manual_crypttab_entry_array_refcell: Rc<RefCell<Vec<CrypttabEntry>>> = Rc::new(RefCell::new(Vec::new())); 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); 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); 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( partitioning_page::partitioning_page(
&carousel, &carousel,
@ -86,7 +110,8 @@ pub fn build_ui(app: &adw::Application) {
&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,
&language_changed_action); &language_changed_action,
);
window.present() window.present()
} }

View File

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

View File

@ -21,10 +21,10 @@ impl DriveMountRow {
.build() .build()
} }
pub fn get_fstab_entry(&self) -> FstabEntry { pub fn get_fstab_entry(&self) -> FstabEntry {
FstabEntry{ FstabEntry {
partition: self.partition(), partition: self.partition(),
mountpoint: self.mountpoint(), 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 glib::clone;
use gtk::{glib, prelude::*, Justification};
pub fn efi_error_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) { pub fn efi_error_page(window: &adw::ApplicationWindow, main_carousel: &adw::Carousel) {
let efi_error_main_box = gtk::Box::builder() let efi_error_main_box = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical) .orientation(gtk::Orientation::Vertical)
.build(); .build();
@ -76,7 +75,6 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, main_carousel: &adw::Caro
exit_button.connect_clicked(clone!( exit_button.connect_clicked(clone!(
#[weak] #[weak]
window, window,
move |_| move |_| window.close()
window.close()
)); ));
} }

View File

@ -1,12 +1,9 @@
use adw::gio;
use crate::installer_stack_page; use crate::installer_stack_page;
use gtk::{prelude::*, glib as glib}; use adw::gio;
use glib::{clone, closure_local}; use glib::{clone, closure_local};
use gtk::{glib, prelude::*};
pub fn eula_page( pub fn eula_page(main_carousel: &adw::Carousel, language_changed_action: &gio::SimpleAction) {
main_carousel: &adw::Carousel,
language_changed_action: &gio::SimpleAction
) {
let eula_page = installer_stack_page::InstallerStackPage::new(); let eula_page = installer_stack_page::InstallerStackPage::new();
eula_page.set_page_icon("error-correct-symbolic"); eula_page.set_page_icon("error-correct-symbolic");
eula_page.set_back_visible(true); eula_page.set_back_visible(true);
@ -20,8 +17,7 @@ pub fn eula_page(
.vexpand(true) .vexpand(true)
.build(); .build();
let eula_buffer = gtk::TextBuffer::builder() let eula_buffer = gtk::TextBuffer::builder().build();
.build();
let eula_selection_text_view = gtk::TextView::builder() let eula_selection_text_view = gtk::TextView::builder()
.hexpand(true) .hexpand(true)
@ -45,29 +41,25 @@ pub fn eula_page(
.margin_end(15) .margin_end(15)
.build(); .build();
eula_accept_checkbutton.connect_toggled( eula_accept_checkbutton.connect_toggled(clone!(
clone!(
#[weak] #[weak]
eula_accept_checkbutton, eula_accept_checkbutton,
#[weak] #[weak]
eula_page, eula_page,
move |_| move |_| {
{
if eula_accept_checkbutton.is_active() == true { if eula_accept_checkbutton.is_active() == true {
eula_page.set_next_sensitive(true); eula_page.set_next_sensitive(true);
} else { } else {
eula_page.set_next_sensitive(false); eula_page.set_next_sensitive(false);
} }
} }
), ));
);
content_box.append(&eula_selection_text_scroll); content_box.append(&eula_selection_text_scroll);
content_box.append(&eula_accept_checkbutton); content_box.append(&eula_accept_checkbutton);
// //
language_changed_action.connect_activate( language_changed_action.connect_activate(clone!(
clone!(
#[weak] #[weak]
eula_page, eula_page,
#[weak] #[weak]
@ -84,8 +76,7 @@ pub fn eula_page(
// //
eula_buffer.set_text(&t!("eula_buffer")) eula_buffer.set_text(&t!("eula_buffer"))
} }
) ));
);
// //
eula_page.set_child_widget(&content_box); eula_page.set_child_widget(&content_box);
@ -96,11 +87,10 @@ pub fn eula_page(
closure_local!( closure_local!(
#[weak] #[weak]
main_carousel, 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) main_carousel.scroll_to(&main_carousel.nth_page(1), true)
} }
) ),
); );
eula_page.connect_closure( eula_page.connect_closure(
@ -109,11 +99,10 @@ pub fn eula_page(
closure_local!( closure_local!(
#[weak] #[weak]
main_carousel, 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.scroll_to(&main_carousel.nth_page(3), true)
} }
) ),
); );
main_carousel.append(&eula_page); 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 adw::{prelude::*, subclass::prelude::*};
use glib::{clone, subclass::Signal}; use glib::{clone, subclass::Signal};
use gtk::{glib, prelude::*, subclass::prelude::*, Justification};
use std::{cell::RefCell, rc::Rc, sync::OnceLock};
// ANCHOR: custom_button // ANCHOR: custom_button
// Object holding the state // Object holding the state
@ -45,7 +45,12 @@ impl ObjectSubclass for InstallerStackPage {
impl ObjectImpl for InstallerStackPage { impl ObjectImpl for InstallerStackPage {
fn signals() -> &'static [Signal] { fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new(); 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) { fn constructed(&self) {
self.parent_constructed(); self.parent_constructed();
@ -210,9 +215,7 @@ impl ObjectImpl for InstallerStackPage {
obj, obj,
#[weak] #[weak]
child_bin, child_bin,
move |_| { move |_| { child_bin.set_child(Some(&obj.property::<gtk::Box>("child_widget"))) }
child_bin.set_child(Some(&obj.property::<gtk::Box>("child_widget")))
}
)); ));
// //

View File

@ -1,15 +1,15 @@
use crate::installer_stack_page; use crate::installer_stack_page;
use gnome_desktop::XkbInfoExt; use adw::prelude::*;
use gtk::{prelude::*, glib as glib, gio as gio};
use adw::{prelude::*};
use glib::{clone, closure_local}; 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( pub fn keyboard_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,
keymap_base_data_refcell: &Rc<RefCell<String>>, keymap_base_data_refcell: &Rc<RefCell<String>>,
keymap_variant_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(); let keyboard_page = installer_stack_page::InstallerStackPage::new();
keyboard_page.set_page_icon("keyboard-symbolic"); keyboard_page.set_page_icon("keyboard-symbolic");
@ -24,8 +24,7 @@ pub fn keyboard_page(
.vexpand(true) .vexpand(true)
.build(); .build();
let null_checkbutton = gtk::CheckButton::builder() let null_checkbutton = gtk::CheckButton::builder().build();
.build();
let keyboard_selection_row_viewport_listbox = gtk::ListBox::builder() let keyboard_selection_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .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("boxed-list");
keyboard_selection_row_viewport_listbox.add_css_class("round-border-only"); keyboard_selection_row_viewport_listbox.add_css_class("round-border-only");
let keyboard_selection_row_viewport = let keyboard_selection_row_viewport = gtk::ScrolledWindow::builder()
gtk::ScrolledWindow::builder()
.vexpand(true) .vexpand(true)
.hexpand(true) .hexpand(true)
.has_frame(true) .has_frame(true)
@ -59,8 +57,7 @@ pub fn keyboard_page(
keyboard_test_entry_boxed_list.add_css_class("boxed-list"); keyboard_test_entry_boxed_list.add_css_class("boxed-list");
let keyboard_test_entry = adw::EntryRow::builder() let keyboard_test_entry = adw::EntryRow::builder().build();
.build();
keyboard_test_entry_boxed_list.append(&keyboard_test_entry); keyboard_test_entry_boxed_list.append(&keyboard_test_entry);
@ -75,7 +72,7 @@ pub fn keyboard_page(
for keymap in keymap_list.iter() { for keymap in keymap_list.iter() {
let keymap = keymap.to_string(); let keymap = keymap.to_string();
let keymap_name = xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string(); let keymap_name = xkbinfo.layout_info(&keymap).unwrap().0.unwrap().to_string();
let keymap_split: Vec<String> = keymap.split("+").map(|s|s.into()).collect(); let keymap_split: Vec<String> = keymap.split("+").map(|s| s.into()).collect();
let keymap_base = keymap_split.get(0).unwrap().clone(); let keymap_base = keymap_split.get(0).unwrap().clone();
let mut keymap_variant = String::new(); let mut keymap_variant = String::new();
let mut split_index = 0; let mut split_index = 0;
@ -108,8 +105,7 @@ pub fn keyboard_page(
keymap_variant_data_refcell, keymap_variant_data_refcell,
#[weak] #[weak]
keyboard_page, keyboard_page,
move |_| move |_| {
{
if keymap_checkbutton.is_active() == true { if keymap_checkbutton.is_active() == true {
keyboard_page.set_next_sensitive(true); keyboard_page.set_next_sensitive(true);
if keymap_variant.is_empty() { if keymap_variant.is_empty() {
@ -149,13 +145,20 @@ pub fn keyboard_page(
keyboard_search_bar, keyboard_search_bar,
#[weak] #[weak]
keyboard_selection_row_viewport_listbox, keyboard_selection_row_viewport_listbox,
move |_| move |_| {
{
let mut counter = keyboard_selection_row_viewport_listbox.first_child(); let mut counter = keyboard_selection_row_viewport_listbox.first_child();
while let Some(row) = counter { while let Some(row) = counter {
if row.widget_name() == "AdwActionRow" { if row.widget_name() == "AdwActionRow" {
if !keyboard_search_bar.text().is_empty() { 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); row.set_property("visible", true);
keyboard_search_bar.grab_focus(); keyboard_search_bar.grab_focus();
} else { } else {
@ -173,8 +176,7 @@ pub fn keyboard_page(
keyboard_page.set_child_widget(&content_box); keyboard_page.set_child_widget(&content_box);
// //
language_changed_action.connect_activate( language_changed_action.connect_activate(clone!(
clone!(
#[weak] #[weak]
keyboard_page, keyboard_page,
#[weak] #[weak]
@ -191,8 +193,7 @@ pub fn keyboard_page(
// //
keyboard_test_entry.set_title(&t!("test_your_keyboard")) keyboard_test_entry.set_title(&t!("test_your_keyboard"))
} }
) ));
);
// //
keyboard_page.connect_closure( keyboard_page.connect_closure(
@ -201,11 +202,10 @@ pub fn keyboard_page(
closure_local!( closure_local!(
#[weak] #[weak]
main_carousel, 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) main_carousel.scroll_to(&main_carousel.nth_page(2), true)
} }
) ),
); );
keyboard_page.connect_closure( keyboard_page.connect_closure(
@ -214,11 +214,10 @@ pub fn keyboard_page(
closure_local!( closure_local!(
#[weak] #[weak]
main_carousel, 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.scroll_to(&main_carousel.nth_page(4), true)
} }
) ),
); );
main_carousel.append(&keyboard_page); main_carousel.append(&keyboard_page);

View File

@ -1,13 +1,13 @@
use crate::installer_stack_page; 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 glib::{clone, closure_local};
use gtk::{gio, glib, prelude::*};
use std::{cell::RefCell, env, fs, path::Path, process::Command, rc::Rc}; use std::{cell::RefCell, env, fs, path::Path, process::Command, rc::Rc};
pub fn language_page( pub fn language_page(
main_carousel: &adw::Carousel, main_carousel: &adw::Carousel,
lang_data_refcell: &Rc<RefCell<String>>, lang_data_refcell: &Rc<RefCell<String>>,
language_changed_action: &gio::SimpleAction language_changed_action: &gio::SimpleAction,
) { ) {
let language_page = installer_stack_page::InstallerStackPage::new(); let language_page = installer_stack_page::InstallerStackPage::new();
language_page.set_page_title(t!("select_a_language")); language_page.set_page_title(t!("select_a_language"));
@ -26,8 +26,7 @@ pub fn language_page(
.vexpand(true) .vexpand(true)
.build(); .build();
let null_checkbutton = gtk::CheckButton::builder() let null_checkbutton = gtk::CheckButton::builder().build();
.build();
let language_selection_row_viewport_listbox = gtk::ListBox::builder() let language_selection_row_viewport_listbox = gtk::ListBox::builder()
.selection_mode(gtk::SelectionMode::None) .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("boxed-list");
language_selection_row_viewport_listbox.add_css_class("round-all-scroll"); language_selection_row_viewport_listbox.add_css_class("round-all-scroll");
let language_selection_row_viewport = let language_selection_row_viewport = gtk::ScrolledWindow::builder()
gtk::ScrolledWindow::builder()
.vexpand(true) .vexpand(true)
.hexpand(true) .hexpand(true)
.has_frame(true) .has_frame(true)
@ -56,176 +54,39 @@ pub fn language_page(
language_search_bar.add_css_class("rounded-all-25"); language_search_bar.add_css_class("rounded-all-25");
let current_locale = match env::var_os("LANG") { 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 != '.') .take_while(|&ch| ch != '.')
.collect::<String>(), .collect::<String>(),
None => panic!("$LANG is not set"), None => panic!("$LANG is not set"),
}; };
let locale_list = ["ab_GE", let locale_list = [
"aa_DJ", "ab_GE", "aa_DJ", "af_ZA", "ak_GH", "sq_AL", "am_ET", "ar_EG", "an_ES", "hy_AM", "as_IN",
"af_ZA", "ar_AE", "az_AZ", "bs_BA", "eu_ES", "be_BY", "bn_BD", "ar_BH", "bi_VU", "bs_BA", "br_FR",
"ak_GH", "bg_BG", "my_MM", "ca_ES", "de_CH", "ce_RU", "zh_CN", "cv_RU", "kw_GB", "es_CO", "es_CR",
"sq_AL", "hr_HR", "cs_CZ", "da_DK", "dv_MV", "nl_NL", "dz_BT", "en_US", "en_GB", "eo", "et_EE",
"am_ET", "et_EE", "fo_FO", "hif_FJ", "fi_FI", "fr_FR", "ff_SN", "gl_ES", "ka_GE", "de_DE", "el_GR",
"ar_EG", "gu_IN", "ht_HT", "ha_NG", "he_IL", "hi_IN", "hu_HU", "ia_FR", "id_ID", "en_IE", "ga_IE",
"an_ES", "ig_NG", "ik_CA", "is_IS", "it_IT", "iu_CA", "ja_JP", "kl_GL", "kn_IN", "ko_KR", "kk_KZ",
"hy_AM", "km_KH", "rw_RW", "ky_KG", "ky_KG", "ko_KR", "ku_TR", "lo_LA", "lb_LU", "lg_UG", "li_NL",
"as_IN", "ln_CD", "lo_LA", "lt_LT", "fr_LU", "lv_LV", "gv_GB", "mk_MK", "mg_MG", "ms_MY", "ml_IN",
"ar_AE", "mt_MT", "mi_NZ", "mr_IN", "mn_MN", "ne_NP", "en_NG", "nb_NO", "nn_NO", "no_NO", "nr_ZA",
"az_AZ", "oc_FR", "es_CU", "om_ET", "or_IN", "os_RU", "pa_IN", "fa_IR", "pl_PL", "ps_AF", "pt_BR",
"bs_BA", "ro_RO", "ru_RU", "sa_IN", "sc_IT", "sd_IN", "se_NO", "sm_WS", "en_SG", "sr_RS", "gd_GB",
"eu_ES", "wo_SN", "si_LK", "sk_SK", "sl_SI", "so_SO", "st_ZA", "es_ES", "sw_KE", "ss_ZA", "sv_SE",
"be_BY", "ta_IN", "te_IN", "tg_TJ", "th_TH", "ti_ER", "bo_CN", "tk_TM", "tl_PH", "tn_ZA", "to_TO",
"bn_BD", "tr_TR", "ts_ZA", "tt_RU", "zh_TW", "ug_CN", "uk_UA", "ur_PK", "ve_ZA", "vi_VN", "wa_BE",
"ar_BH", "cy_GB", "wo_SN", "fy_NL", "xh_ZA", "yi_US", "yo_NG", "zu_ZA", "zu_ZA", "pt_BR", "pt_PT",
"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() { for locale in locale_list.iter() {
let locale = locale.to_string(); 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_clone = locale.clone();
let locale_checkbutton = gtk::CheckButton::builder() let locale_checkbutton = gtk::CheckButton::builder()
.valign(gtk::Align::Center) .valign(gtk::Align::Center)
@ -246,8 +107,7 @@ pub fn language_page(
lang_data_refcell, lang_data_refcell,
#[weak] #[weak]
language_page, language_page,
move |_| move |_| {
{
if locale_checkbutton.is_active() == true { if locale_checkbutton.is_active() == true {
language_page.set_next_sensitive(true); language_page.set_next_sensitive(true);
*lang_data_refcell.borrow_mut() = String::from(&locale); *lang_data_refcell.borrow_mut() = String::from(&locale);
@ -274,13 +134,20 @@ pub fn language_page(
language_search_bar, language_search_bar,
#[weak] #[weak]
language_selection_row_viewport_listbox, language_selection_row_viewport_listbox,
move |_| move |_| {
{
let mut counter = language_selection_row_viewport_listbox.first_child(); let mut counter = language_selection_row_viewport_listbox.first_child();
while let Some(row) = counter { while let Some(row) = counter {
if row.widget_name() == "AdwActionRow" { if row.widget_name() == "AdwActionRow" {
if !language_search_bar.text().is_empty() { 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); row.set_property("visible", true);
language_search_bar.grab_focus(); language_search_bar.grab_focus();
} else { } else {
@ -303,11 +170,10 @@ pub fn language_page(
closure_local!( closure_local!(
#[weak] #[weak]
main_carousel, 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) main_carousel.scroll_to(&main_carousel.nth_page(0), true)
} }
) ),
); );
language_page.connect_closure( language_page.connect_closure(
@ -320,8 +186,7 @@ pub fn language_page(
lang_data_refcell, lang_data_refcell,
#[strong] #[strong]
language_changed_action, language_changed_action,
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")
@ -333,7 +198,7 @@ pub fn language_page(
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)
} }
) ),
); );
main_carousel.append(&language_page); 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 std::env;
use gtk::{CssProvider, gdk, STYLE_PROVIDER_PRIORITY_APPLICATION, prelude::*, glib as glib};
use gdk::{Display};
mod config;
mod build_ui; mod build_ui;
mod config;
mod efi_error_page; mod efi_error_page;
mod installer_stack_page; mod installer_stack_page;
// //
mod welcome_page; mod automatic_partitioning_page;
mod language_page; mod drive_mount_row;
mod eula_page; mod eula_page;
mod keyboard_page; mod keyboard_page;
mod timezone_page; mod language_page;
mod partitioning_page;
mod automatic_partitioning_page;
mod manual_partitioning_page; mod manual_partitioning_page;
mod drive_mount_row; mod partitioning_page;
mod timezone_page;
mod welcome_page;
#[macro_use] #[macro_use]
extern crate rust_i18n; extern crate rust_i18n;
@ -24,14 +24,19 @@ i18n!("locales", fallback = "en_US");
fn main() -> glib::ExitCode { fn main() -> glib::ExitCode {
let current_locale = match env::var_os("LANG") { 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 != '.') .take_while(|&ch| ch != '.')
.collect::<String>(), .collect::<String>(),
None => panic!("$LANG is not set"), None => panic!("$LANG is not set"),
}; };
rust_i18n::set_locale(&current_locale); 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| { app.connect_startup(|app| {
load_css(); 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::drive_mount_row::DriveMountRow;
use crate::installer_stack_page; 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 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::io::BufRead;
use std::{cell::RefCell, rc::Rc};
pub fn partitioning_page( pub fn partitioning_page(
main_carousel: &adw::Carousel, 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_fstab_entry_array_refcell: &Rc<RefCell<Vec<FstabEntry>>>,
partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>, partition_method_manual_luks_enabled_refcell: &Rc<RefCell<bool>>,
partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>, partition_method_manual_crypttab_entry_array_refcell: &Rc<RefCell<Vec<CrypttabEntry>>>,
language_changed_action: &gio::SimpleAction language_changed_action: &gio::SimpleAction,
) { ) {
let partitioning_page = installer_stack_page::InstallerStackPage::new(); let partitioning_page = installer_stack_page::InstallerStackPage::new();
partitioning_page.set_page_icon("media-floppy-symbolic"); partitioning_page.set_page_icon("media-floppy-symbolic");
@ -46,31 +46,23 @@ pub fn partitioning_page(
content_box.add_css_class("linked"); content_box.add_css_class("linked");
let automatic_method_button = gtk::Button::builder() let automatic_method_button = gtk::Button::builder().icon_name("builder").build();
.icon_name("builder")
.build();
let manual_method_button = gtk::Button::builder() let manual_method_button = gtk::Button::builder()
.icon_name("emblem-system-symbolics") .icon_name("emblem-system-symbolics")
.build(); .build();
automatic_method_button.connect_clicked( automatic_method_button.connect_clicked(clone!(
clone!(
#[weak] #[weak]
partitioning_carousel, partitioning_carousel,
move |_| move |_| partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(1), true)
partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(1), true) ));
)
);
manual_method_button.connect_clicked( manual_method_button.connect_clicked(clone!(
clone!(
#[weak] #[weak]
partitioning_carousel, partitioning_carousel,
move |_| move |_| partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(2), true)
partitioning_carousel.scroll_to(&partitioning_carousel.nth_page(2), true) ));
)
);
content_box.append(&automatic_method_button); content_box.append(&automatic_method_button);
content_box.append(&manual_method_button); content_box.append(&manual_method_button);
@ -78,8 +70,7 @@ pub fn partitioning_page(
partitioning_page.set_child_widget(&content_box); partitioning_page.set_child_widget(&content_box);
// //
language_changed_action.connect_activate( language_changed_action.connect_activate(clone!(
clone!(
#[weak] #[weak]
partitioning_page, partitioning_page,
move |_, _| { move |_, _| {
@ -92,8 +83,7 @@ pub fn partitioning_page(
// //
manual_method_button.set_label(&t!("manual_partition_drive")); manual_method_button.set_label(&t!("manual_partition_drive"));
} }
) ));
);
// //
partitioning_carousel.append(&partitioning_page); partitioning_carousel.append(&partitioning_page);
@ -106,14 +96,16 @@ pub fn partitioning_page(
&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,
&language_changed_action); &language_changed_action,
);
manual_partitioning_page::manual_partitioning_page( manual_partitioning_page::manual_partitioning_page(
&partitioning_carousel, &partitioning_carousel,
&partition_method_type_refcell, &partition_method_type_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,
&language_changed_action); &language_changed_action,
);
partitioning_page.connect_closure( partitioning_page.connect_closure(
"back-button-pressed", "back-button-pressed",
@ -121,11 +113,10 @@ pub fn partitioning_page(
closure_local!( closure_local!(
#[weak] #[weak]
main_carousel, 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.scroll_to(&main_carousel.nth_page(4), true)
} }
) ),
); );
main_carousel.append(&partitioning_carousel) main_carousel.append(&partitioning_carousel)
@ -134,7 +125,7 @@ pub fn partitioning_page(
pub struct BlockDevice { pub struct BlockDevice {
pub block_name: String, pub block_name: String,
pub block_size: f64, pub block_size: f64,
pub block_size_pretty: String pub block_size_pretty: String,
} }
#[derive(Clone)] #[derive(Clone)]
@ -144,7 +135,7 @@ pub struct Partition {
pub has_encryption: bool, pub has_encryption: bool,
pub need_mapper: bool, pub need_mapper: bool,
pub part_size: f64, pub part_size: f64,
pub part_size_pretty: String pub part_size_pretty: String,
} }
#[derive(Default)] #[derive(Default)]
@ -168,9 +159,10 @@ pub fn get_block_devices() -> Vec<BlockDevice> {
.arg("get_block_devices") .arg("get_block_devices")
.stdin(std::process::Stdio::piped()) .stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped())
.spawn() { .spawn()
{
Ok(t) => t, Ok(t) => t,
Err(_) => return block_devices Err(_) => return block_devices,
}; };
match command.stdout { match command.stdout {
@ -179,19 +171,17 @@ pub fn get_block_devices() -> Vec<BlockDevice> {
match blockdev { match blockdev {
Ok(r) => { Ok(r) => {
let block_size = get_block_size(&r); let block_size = get_block_size(&r);
block_devices.push( block_devices.push(BlockDevice {
BlockDevice {
block_name: r, block_name: r,
block_size: block_size, 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 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("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_block_size") .arg("get_block_size")
.arg(block_dev) .arg(block_dev)
.output() { .output()
{
Ok(t) => t, Ok(t) => t,
Err(_) => return 0.0 Err(_) => return 0.0,
}; };
let size = match String::from_utf8(command.stdout) { let size = match String::from_utf8(command.stdout) {
Ok(t) => { Ok(t) => t.trim().parse::<f64>().unwrap_or(0.0),
t.trim().parse::<f64>().unwrap_or(0.0) Err(_) => 0.0,
}
Err(_) => 0.0
}; };
size size
@ -224,9 +213,10 @@ pub fn get_partitions() -> Vec<Partition> {
.arg("get_partitions") .arg("get_partitions")
.stdin(std::process::Stdio::piped()) .stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped())
.spawn() { .spawn()
{
Ok(t) => t, Ok(t) => t,
Err(_) => return partitions Err(_) => return partitions,
}; };
match command.stdout { match command.stdout {
@ -236,22 +226,20 @@ pub fn get_partitions() -> Vec<Partition> {
Ok(r) => { Ok(r) => {
let part_size = get_part_size(&r); let part_size = get_part_size(&r);
let part_fs = get_part_fs(&r); let part_fs = get_part_fs(&r);
partitions.push( partitions.push(Partition {
Partition {
has_encryption: is_encrypted(&r), has_encryption: is_encrypted(&r),
need_mapper: is_needs_mapper(&part_fs), need_mapper: is_needs_mapper(&part_fs),
part_name: r, part_name: r,
part_fs: part_fs, part_fs: part_fs,
part_size: part_size, 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 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("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_part_size") .arg("get_part_size")
.arg(part_dev) .arg(part_dev)
.output() { .output()
{
Ok(t) => t, Ok(t) => t,
Err(_) => return 0.0 Err(_) => return 0.0,
}; };
let size = match String::from_utf8(command.stdout) { let size = match String::from_utf8(command.stdout) {
Ok(t) => { Ok(t) => t.trim().parse::<f64>().unwrap_or(0.0),
t.trim().parse::<f64>().unwrap_or(0.0) Err(_) => 0.0,
}
Err(_) => 0.0
}; };
size 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("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("get_part_fs") .arg("get_part_fs")
.arg(part_dev.replace("mapper/", "")) .arg(part_dev.replace("mapper/", ""))
.output() { .output()
{
Ok(t) => t, 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) { let fs = match String::from_utf8(command.stdout) {
Ok(t) => { Ok(t) => t.trim().to_owned(),
t.trim().to_owned() Err(_) => String::from(t!("fs_unknown")),
}
Err(_) => String::from(t!("fs_unknown"))
}; };
fs fs
} }
fn is_needs_mapper(part_fs: &str) -> bool { 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 true
} else { } else {
false false
@ -308,9 +294,10 @@ fn is_encrypted(part_dev: &str) -> bool {
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
.arg("has_encryption") .arg("has_encryption")
.arg(part_dev) .arg(part_dev)
.output() { .output()
{
Ok(t) => t, Ok(t) => t,
Err(_) => return false Err(_) => return false,
}; };
if command.status.success() { if command.status.success() {

View File

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

View File

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