RR: Fix all warnings

This commit is contained in:
Ward from fusion-voyager-3 2024-02-17 16:52:07 +03:00
parent 36b0cf35c2
commit 44b90ff768
15 changed files with 45 additions and 140 deletions

View File

@ -1,27 +1,16 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use pretty_bytes::converter::convert;
use std::env;
use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::time::Instant;
use std::thread;
use std::time::*;
use std::fs;
use std::path::Path;
pub fn automatic_partitioning(
partitioning_stack: &gtk::Stack,
bottom_next_button: &gtk::Button,

View File

@ -1,12 +1,9 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use std::path::Path;
@ -36,23 +33,19 @@ pub fn build_ui(app: &adw::Application) {
// Widget Bank
/// Create A box
let _main_box = gtk::Box::builder()
// that puts items vertically
.orientation(Orientation::Vertical)
.build();
/// Add adwaita title box
let window_title_bar = adw::HeaderBar::builder().build();
/// Add page Stack containing all primary contents
let content_stack = gtk::Stack::builder()
.hexpand(true)
.vexpand(true)
.transition_type(StackTransitionType::SlideLeftRight)
.build();
/// Add a Visual Stack Switcher for content_stack
let content_stack_switcher = gtk::StackSwitcher::builder()
.stack(&content_stack)
.margin_top(15)
@ -69,9 +62,7 @@ pub fn build_ui(app: &adw::Application) {
_main_box.append(&content_stack_switcher);
//// Add the stack pager containing all the steps to _main_box
_main_box.append(&content_stack);
//// Add the the next and back buttons box to _main_box (moved)
///_main_box.append(&bottom_box);
// create the main Application window
let window = adw::ApplicationWindow::builder()
// The text on the titlebar
.title("PikaOS Installer")
@ -145,11 +136,6 @@ pub fn build_ui(app: &adw::Application) {
window.maximize()
}
// Connects the clicking of "_click_me_button" to the external function "print_why" and idk why but everyone tells me to be "move |_| " before the external function
/// and instead of () we put an aurgment for the target label with & before it so it's"
/// print_why() -> print_why(&_warning_label)
//_click_me_button.connect_clicked(move |_| print_why(&_warning_label));
// Connect the hiding of window to the save_window_size function and window destruction
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
window.connect_hide(clone!(@weak window => move |_| window.destroy()));

View File

@ -1,21 +1,16 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use std::fs;
use std::path::Path;
use std::process::Command;
pub fn done_page(
done_main_box: &gtk::Box,
content_stack: &gtk::Stack,
window: &adw::ApplicationWindow,
) {
// the header box for the installation_successful page

View File

@ -1,12 +1,12 @@
use std::{
cell::{Cell, RefCell},
cell::{RefCell},
rc::Rc,
sync::OnceLock,
};
use adw::{prelude::*, subclass::prelude::*, *};
use glib::{clone, subclass::Signal, Properties};
use gtk::{glib, prelude::*, subclass::prelude::*, Orientation::Horizontal, *};
use gtk::{glib, Orientation::Horizontal};
// ANCHOR: custom_button
// Object holding the state

View File

@ -1,12 +1,9 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {

View File

@ -1,20 +1,11 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::time::Instant;
pub fn eula_page(content_stack: &gtk::Stack) {
// create the bottom box for next and back buttons
let bottom_box = gtk::Box::builder()

View File

@ -2,19 +2,15 @@ use std::cell::RefCell;
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use vte::prelude::*;
use vte::*;
use crate::done_page::done_page;
use pretty_bytes::converter::convert;
use std::process::Command;
use std::fs;
@ -23,7 +19,6 @@ use std::rc::Rc;
use crate::manual_partitioning::DriveMount;
use serde::*;
use serde_json::*;
use duct::*;
#[derive(PartialEq, Debug, Eq, Hash, Clone, Serialize, Deserialize)]
@ -39,8 +34,8 @@ pub fn install_page(
window: &adw::ApplicationWindow,
manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>,
) {
let mut iter_count = 0;
iter_count = 0;
let mut _iter_count = 0;
_iter_count = 0;
let mut unlocked_array: Vec<String> = Default::default();
for partitions in manual_drive_mount_array.borrow_mut().iter() {
let new_crypt = if partitions.mountpoint != "/"
@ -118,7 +113,7 @@ pub fn install_page(
};
fs::write(
"/tmp/pika-installer-gtk4-target-manual-luks-p".to_owned()
+ &iter_count.to_string()
+ &_iter_count.to_string()
+ ".json",
serde_json::to_string(&crypttab_entry).unwrap(),
)
@ -130,7 +125,7 @@ pub fn install_page(
};
fs::write(
"/tmp/pika-installer-gtk4-target-manual-luks-p".to_owned()
+ &iter_count.to_string()
+ &_iter_count.to_string()
+ ".json",
serde_json::to_string(&crypttab_entry).unwrap(),
)
@ -143,7 +138,7 @@ pub fn install_page(
};
fs::write(
"/tmp/pika-installer-gtk4-target-manual-p".to_owned()
+ &iter_count.to_string()
+ &_iter_count.to_string()
+ ".json",
serde_json::to_string(partitions).unwrap(),
)
@ -152,7 +147,7 @@ pub fn install_page(
unlocked_array.push(new_crypt);
}
dbg!(&unlocked_array);
iter_count += 1;
_iter_count += 1;
}
// create the bottom box for next and back buttons
@ -296,67 +291,67 @@ pub fn install_page(
.trim()
.parse::<f64>()
.unwrap();
let mut target_p3_size = 0.0;
let mut _target_p3_size = 0.0;
if (target_size * 40.0) / 100.0 >= 150000000000.0 {
target_p3_size = 150000000000.0;
_target_p3_size = 150000000000.0;
} else if (target_size * 40.0) / 100.0 <= 36507222016.0 {
target_p3_size = 36507222016.0;
_target_p3_size = 36507222016.0
} else {
target_p3_size = (target_size * 40.0) / 100.0;
_target_p3_size = (target_size * 40.0) / 100.0;
}
let target_p4_size = target_size - (target_p3_size + 1536.0);
let target_p4_size = target_size - (_target_p3_size + 1536.0);
if Path::new("/tmp/pika-installer-p3-size.txt").exists() {
fs::remove_file("/tmp/pika-installer-p3-size.txt")
.expect("Bad permissions on /tmp/pika-installer-p3-size.txt");
}
let target_p3_sector = target_p3_size + 1537.0;
let target_p3_sector = _target_p3_size + 1537.0;
fs::write(
"/tmp/pika-installer-p3-size.txt",
target_p3_sector.to_string(),
)
.expect("Unable to write file");
let mut p1_row_text = String::new();
let mut p2_row_text = String::new();
let mut p3_row_text = String::new();
let mut p4_row_text = String::new();
let mut _p1_row_text = String::new();
let mut _p2_row_text = String::new();
let mut _p3_row_text = String::new();
let mut _p4_row_text = String::new();
if target_block_device.contains("nvme") {
p1_row_text =
_p1_row_text =
"512 MB ".to_owned() + target_block_device + "p1" + " as fat32" + " on /boot/efi";
p2_row_text =
_p2_row_text =
"1 GB ".to_owned() + target_block_device + "p2" + " as ext4" + " on /boot";
p3_row_text = pretty_bytes::converter::convert(target_p3_size)
_p3_row_text = pretty_bytes::converter::convert(_target_p3_size)
+ " "
+ target_block_device
+ "p3"
+ " as btrfs"
+ " on /";
p4_row_text = pretty_bytes::converter::convert(target_p4_size)
_p4_row_text = pretty_bytes::converter::convert(target_p4_size)
+ " "
+ target_block_device
+ "p4"
+ " as btrfs"
+ " on /home";
} else {
p1_row_text =
_p1_row_text =
"512 MB ".to_owned() + target_block_device + "1" + " as fat32" + " on /boot/efi";
p2_row_text = "1 GB ".to_owned() + target_block_device + "2" + " as ext4" + " on /boot";
p3_row_text = pretty_bytes::converter::convert(target_p3_size)
_p2_row_text = "1 GB ".to_owned() + target_block_device + "2" + " as ext4" + " on /boot";
_p3_row_text = pretty_bytes::converter::convert(_target_p3_size)
+ " "
+ target_block_device
+ "3"
+ " as btrfs"
+ " on /";
p4_row_text = pretty_bytes::converter::convert(target_p4_size)
_p4_row_text = pretty_bytes::converter::convert(target_p4_size)
+ " "
+ target_block_device
+ "4"
+ " as btrfs"
+ " on /home";
}
let install_confirm_p1 = adw::ActionRow::builder().title(p1_row_text.clone()).build();
let install_confirm_p2 = adw::ActionRow::builder().title(p2_row_text.clone()).build();
let install_confirm_p3 = adw::ActionRow::builder().title(p3_row_text.clone()).build();
let install_confirm_p4 = adw::ActionRow::builder().title(p4_row_text.clone()).build();
let install_confirm_p1 = adw::ActionRow::builder().title(_p1_row_text.clone()).build();
let install_confirm_p2 = adw::ActionRow::builder().title(_p2_row_text.clone()).build();
let install_confirm_p3 = adw::ActionRow::builder().title(_p3_row_text.clone()).build();
let install_confirm_p4 = adw::ActionRow::builder().title(_p4_row_text.clone()).build();
// / install_confirm_selection_box appends
//// add live and install media button to install page selections
install_confirm_details_boxed_list.append(&install_confirm_detail_language);
@ -408,7 +403,6 @@ pub fn install_page(
install_confirm_box.append(&bottom_box);
///
let install_progress_box = gtk::Box::builder()
.orientation(Orientation::Vertical)
.build();
@ -783,7 +777,7 @@ fn begin_install(
while let Ok(done_status_state) = done_status_receiver.recv().await {
if done_status_state == true {
println!("Installation status: Done");
done_page(&done_main_box ,&content_stack, &window);
done_page(&done_main_box, &window);
content_stack.set_visible_child_name("done_page");
}
}

View File

@ -1,12 +1,9 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use std::io::BufRead;
@ -14,7 +11,6 @@ use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::str;
use std::time::Instant;
use std::fs;
use std::path::Path;

View File

@ -1,12 +1,9 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use std::env;
@ -14,7 +11,6 @@ use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::time::Instant;
use std::fs;
use std::path::Path;

View File

@ -2,12 +2,10 @@
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
mod automatic_partitioning;
mod build_ui;
mod done_page;

View File

@ -1,36 +1,26 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::{layout_child, window};
use gtk::*;
use std::collections::HashMap;
use std::thread;
use std::cell::{RefCell, RefMut};
use std::rc::Rc;
use duct::*;
use duct::cmd;
use gtk::Orientation::Vertical;
use std::ops::{Deref, DerefMut};
use std::{
collections::HashSet,
fs,
hash::Hash,
io::{BufRead, BufReader},
path::Path,
process::{Command, Stdio},
time::{Duration, Instant},
process::{Command},
time::{Duration},
};
use crate::drive_mount_row::DriveMountRow;
use pretty_bytes::converter::convert;
use serde::*;
#[derive(PartialEq, Debug, Eq, Hash, Clone, Serialize, Deserialize)]
@ -44,7 +34,7 @@ fn create_mount_row(
listbox: &gtk::ListBox,
manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>,
part_table_array: &Rc<RefCell<Vec<String>>>,
check_part_unique: &Rc<RefCell<bool>>,
_check_part_unique: &Rc<RefCell<bool>>,
) -> DriveMountRow {
let partition_scroll_child = gtk::ListBox::builder().build();
@ -59,9 +49,7 @@ fn create_mount_row(
let null_checkbutton = gtk::CheckButton::builder().build();
let partition_method_manual_emitter = gtk::SignalAction::new("partchg");
let mut part_table_array_ref = part_table_array.borrow_mut();
let part_table_array_ref = part_table_array.borrow_mut();
for partition in part_table_array_ref.iter() {
let partition_size_cli = Command::new("sudo")
.arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh")
@ -121,8 +109,8 @@ fn create_mount_row(
row.connect_closure(
"row-deleted",
false,
closure_local!(@strong row => move |row: DriveMountRow| {
listbox_clone.remove(&row)
closure_local!(@strong row as _row => move |_row: DriveMountRow| {
listbox_clone.remove(&_row)
}),
);
@ -132,7 +120,6 @@ fn create_mount_row(
//pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: &gtk::Stack, bottom_next_button: &gtk::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) {
pub fn manual_partitioning(
window: &adw::ApplicationWindow,
partitioning_stack: &gtk::Stack,
bottom_next_button: &gtk::Button,
manual_drive_mount_array: &Rc<RefCell<Vec<DriveMount>>>,
@ -282,7 +269,7 @@ pub fn manual_partitioning(
}
counter = row.next_sibling();
}
let mut partition_method_manual_get_partitions_lines = BufReader::new(cmd!("bash", "-c", "sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions").reader().unwrap()).lines();
let partition_method_manual_get_partitions_lines = BufReader::new(cmd!("bash", "-c", "sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions").reader().unwrap()).lines();
let mut part_table_array_ref = part_table_array.borrow_mut();
part_table_array_ref.clear();
for partition in partition_method_manual_get_partitions_lines {

View File

@ -1,38 +1,23 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
use glob::glob;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use crate::automatic_partitioning::automatic_partitioning;
use crate::install_page::install_page;
use crate::manual_partitioning::manual_partitioning;
use pretty_bytes::converter::convert;
use std::env;
use std::io::BufRead;
use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::time::Instant;
use std::thread;
use std::time::*;
use std::fs;
use std::path::Path;
use std::cell::RefCell;
use std::ops::Deref;
use std::rc::Rc;
use crate::{install_page, manual_partitioning};
use crate::{manual_partitioning};
use manual_partitioning::DriveMount;
@ -220,7 +205,6 @@ pub fn partitioning_page(
manual_method_button_content_box.append(&manual_method_button_content_image);
/// add all pages to partitioning stack
partitioning_stack.add_titled(
&partitioning_method_main_box,
Some("partition_method_select_page"),
@ -228,8 +212,7 @@ pub fn partitioning_page(
);
let partitioning_page_automatic_partitioning =
automatic_partitioning(&partitioning_stack, &bottom_next_button);
let partitioning_page_manual_partitioning = manual_partitioning(
window,
let _partitioning_page_manual_partitioning = manual_partitioning(
&partitioning_stack,
&bottom_next_button,
&manual_drive_mount_array,
@ -292,7 +275,7 @@ pub fn partitioning_page(
if automatic_luks_result.is_empty() {
//
} else {
fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result);
let _ = fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result);
}
install_page(&done_main_box, &install_main_box, &content_stack, &window, &manual_drive_mount_array);
content_stack.set_visible_child_name("install_page");

View File

@ -1,11 +1,11 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
#[allow(unused_imports)]
use gtk::prelude::*;
#[allow(unused_imports)]
use gtk::*;
// Save current window size to glib

View File

@ -1,12 +1,9 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
use std::io::BufRead;
@ -14,7 +11,6 @@ use std::io::BufReader;
use std::process::Command;
use std::process::Stdio;
use std::str;
use std::time::Instant;
use std::fs;
use std::path::Path;

View File

@ -1,12 +1,9 @@
// Use libraries
use adw::prelude::*;
use adw::*;
use gdk::Display;
use glib::*;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::prelude::*;
use gtk::subclass::layout_child;
use gtk::*;
pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: &gtk::Stack) {