From 396560afe78757ad4428536fb10bf601de363611 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Wed, 24 Jan 2024 22:17:19 +0300 Subject: [PATCH 01/52] update to git --- .github/workflows/release.yml | 47 +++++++++++++++ Cargo.toml | 2 +- Makefile | 6 +- debian/changelog | 5 ++ debian/compat | 1 + debian/control | 19 +++++++ debian/extras/pika-installer | 16 ++++++ .../extras/pika-installer-autostart.desktop | 14 +++++ debian/extras/pika-installer.desktop | 13 +++++ debian/extras/powermanagementprofilesrc | 57 +++++++++++++++++++ debian/postinst | 11 ++++ debian/rules | 29 ++++++++++ debian/source/format | 1 + main.sh | 15 +++++ release.sh | 8 +++ src/build_ui.rs | 4 +- src/eula_page.rs | 13 ++++- 17 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/extras/pika-installer create mode 100644 debian/extras/pika-installer-autostart.desktop create mode 100644 debian/extras/pika-installer.desktop create mode 100644 debian/extras/powermanagementprofilesrc create mode 100644 debian/postinst create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 main.sh create mode 100644 release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8d34d97 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: PikaOS Package Release + +on: + workflow_dispatch + +jobs: + build: + runs-on: self-hosted + container: + image: ghcr.io/pikaos-linux/pika-package-container:latest + volumes: + - /proc:/proc + options: --privileged -it + + steps: + - uses: actions/checkout@v3 + + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_KEY }} + name: id_rsa + known_hosts: ${{ secrets.KNOWN_HOSTS }} + if_key_exists: replace + + - name: Build Package + run: chmod +x ./main.sh && ./main.sh + + - name: Release Package + run: chmod +x ./release.sh && ./release.sh + + - name: Purge cache + uses: strrife/cloudflare-chunked-purge-action@master + env: + # Zone is required by both authentication methods + CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }} + + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} + PURGE_URLS: ${{ vars.PURGE_URLS }} + \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 604d198..0b8f791 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pika-installer-gtk4" -version = "0.1.0" +version = "1.0.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/Makefile b/Makefile index ad4c118..bfb07da 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,13 @@ all: true install: - mkdir -p $(DESTDIR)/usr/bin/ + #mkdir -p $(DESTDIR)/usr/bin/ cargo fetch cargo build --release - cp -vf target/release/pika-installer-gtk4 $(DESTDIR)/usr/bin/ + #cp -vf target/release/pika-installer-gtk4 $(DESTDIR)/usr/bin/ chmod 755 $(DESTDIR)/usr/bin/pika-installer-gtk4 + mkdir -p $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/ + cp -vf target/release/pika-installer-gtk4 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/ mkdir -p $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/ mkdir -p $(DESTDIR)/usr/share/glib-2.0/schemas/ cp -rvf data/scripts/*.sh $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/ diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..853f11b --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pika-installer-gtk4 (1.0.0) pikauwu; urgency=low + + * First release + + -- Ward Nakchbandi Thu, 20 Sep 2022 22:01:00 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..59b462c --- /dev/null +++ b/debian/control @@ -0,0 +1,19 @@ +Source: pika-installer-gtk4 +Section: utils +Priority: optional +Maintainer: International Arms dealers +Build-Depends: build-essential, + debhelper, + cargo, + libadwaita-1-dev, + libgtk-4-dev, + desktop-file-utils, + make, + libvte-2.91-gtk4-dev +Rules-Requires-Root: no + +Package: pika-installer-gtk4 +Architecture: any +Depends: ${shlibs:Depends}, + pikainstall +Description: A frontend in GTK 4 and Libadwaita for pikainstall. diff --git a/debian/extras/pika-installer b/debian/extras/pika-installer new file mode 100644 index 0000000..c918053 --- /dev/null +++ b/debian/extras/pika-installer @@ -0,0 +1,16 @@ +#! /bin/bash + +if env | grep XDG_SESSION_DESKTOP | grep -i -E 'gnome|ubuntu|pika' +then + gnome-session-inhibit /usr/lib/pika/pika-installer-gtk4/bin/pika-installer-gtk4 +elif env | grep XDG_SESSION_DESKTOP | grep -i -E 'kde|plasma' +then + # Disable Auto Suspend + cp -vf /etc/pika-installer-gtk4/powermanagementprofilesrc ~/.config/ || exit 1 + # Disable screen lock + kwriteconfig5 --file kscreenlockerrc --group Daemon --key Autolock false + qdbus org.freedesktop.ScreenSaver /ScreenSaver configure + /usr/lib/pika/pika-installer-gtk4/bin/pika-installer-gtk4 +else + /usr/lib/pika/pika-installer-gtk4/bin/pika-installer-gtk4 +fi diff --git a/debian/extras/pika-installer-autostart.desktop b/debian/extras/pika-installer-autostart.desktop new file mode 100644 index 0000000..a77cc3c --- /dev/null +++ b/debian/extras/pika-installer-autostart.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Icon=calamares +Name=Install PikaOS Linux +Exec=pika-installer +Icon=calamares +Terminal=false +Type=Application +Terminal=false +StartupNotify=true +X-GNOME-Autostart-enabled=true +X-KDE-AutostartScript=true +Categories=GNOME;GTK;Utility; +Keywords=Gnome;GTK +NoDisplay=true \ No newline at end of file diff --git a/debian/extras/pika-installer.desktop b/debian/extras/pika-installer.desktop new file mode 100644 index 0000000..388d1ad --- /dev/null +++ b/debian/extras/pika-installer.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Icon=calamares +Name=Install PikaOS Linux +Exec=pika-installer +Icon=calamares +Terminal=false +Type=Application +Terminal=false +StartupNotify=true +X-GNOME-Autostart-enabled=true +X-KDE-AutostartScript=true +Categories=GNOME;GTK;Utility; +Keywords=Gnome;GTK \ No newline at end of file diff --git a/debian/extras/powermanagementprofilesrc b/debian/extras/powermanagementprofilesrc new file mode 100644 index 0000000..ae08fbe --- /dev/null +++ b/debian/extras/powermanagementprofilesrc @@ -0,0 +1,57 @@ +[AC] +icon=battery-charging + +[AC][DPMSControl] +idleTime=600 +lockBeforeTurnOff=0 + +[AC][DimDisplay] +idleTime=300000 + +[AC][HandleButtonEvents] +lidAction=1 +powerButtonAction=16 +powerDownAction=16 + +[Battery] +icon=battery-060 + +[Battery][DPMSControl] +idleTime=300 +lockBeforeTurnOff=0 + +[Battery][DimDisplay] +idleTime=120000 + +[Battery][HandleButtonEvents] +lidAction=1 +powerButtonAction=16 +powerDownAction=16 + +[Battery][SuspendSession] +idleTime=600000 +suspendThenHibernate=false +suspendType=1 + +[LowBattery] +icon=battery-low + +[LowBattery][BrightnessControl] +value=30 + +[LowBattery][DPMSControl] +idleTime=120 +lockBeforeTurnOff=0 + +[LowBattery][DimDisplay] +idleTime=60000 + +[LowBattery][HandleButtonEvents] +lidAction=1 +powerButtonAction=16 +powerDownAction=16 + +[LowBattery][SuspendSession] +idleTime=300000 +suspendThenHibernate=false +suspendType=1 diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..cef55bb --- /dev/null +++ b/debian/postinst @@ -0,0 +1,11 @@ +#!/bin/sh + + +set -e + + update-mime-database /usr/share/mime + update-desktop-database + glib-compile-schemas /usr/share/glib-2.0/schemas + + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..831e453 --- /dev/null +++ b/debian/rules @@ -0,0 +1,29 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ + + +override_dh_missing: + dh_missing + mkdir -pv debian/pika-installer-gtk4/usr/share/applications/ + mkdir -pv debian/pika-installer-gtk4/etc/xdg/autostart/ + mkdir -pv debian/pika-installer-gtk4/usr/bin/ + mkdir -pv debian/pika-installer-gtk4/etc/pika-installer-gtk4/ + cp -vf debian/extras/pika-installer.desktop debian/pika-installer-gtk4/usr/share/applications/ + cp -vf debian/extras/pika-installer-autostart.desktop debian/pika-installer-gtk4/etc/xdg/autostart/ + cp -vf debian/extras/pika-installer debian/pika-installer-gtk4/usr/bin/ + chmod +x debian/pika-installer-gtk4/usr/bin/pika-installer + cp -vf debian/extras/powermanagementprofilesrc debian/pika-installer-gtk4/etc/pika-installer-gtk4/ + + + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/main.sh b/main.sh new file mode 100644 index 0000000..fec177f --- /dev/null +++ b/main.sh @@ -0,0 +1,15 @@ +# Clone Upstream +mkdir -p ./pika-installer-gtk4 +rsync -av --progress ./* ./pika-installer-gtk4 --exclude ./pika-installer-gtk4 +cd ./pika-installer-gtk4 + +# Get build deps +apt-get build-dep ./ -y + +# Build package +dpkg-buildpackage --no-sign + +# Move the debs to output +cd ../ +mkdir -p ./output +mv ./*.deb ./output/ diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..1575255 --- /dev/null +++ b/release.sh @@ -0,0 +1,8 @@ +# send debs to server +rsync -azP --include './' --include '*.deb' --exclude '*' ./output/ ferreo@direct.pika-os.com:/srv/www/incoming/ + +# add debs to repo +ssh ferreo@direct.pika-os.com 'aptly repo add -force-replace -remove-files pikauwu-main /srv/www/incoming/' + +# publish the repo +ssh ferreo@direct.pika-os.com 'aptly publish update -batch -skip-contents -force-overwrite pikauwu filesystem:pikarepo:' \ No newline at end of file diff --git a/src/build_ui.rs b/src/build_ui.rs index bc508fa..9e69055 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -76,7 +76,7 @@ pub fn build_ui(app: &adw::Application) { // Add the box called "_main_box" to it .content(&_main_box) // Application icon - .icon_name("nautilus") + .icon_name("calamares") // Get current size from glib .default_width(glib_settings.int("window-width")) .default_height(glib_settings.int("window-height")) @@ -153,4 +153,4 @@ pub fn build_ui(app: &adw::Application) { //bottom_next_button.connect_clicked(move |_| content_stack_clone.set_visible_child(&content_stack_clone.visible_child().expect("null").next_sibling().unwrap())); //bottom_back_button.connect_clicked(move |_| content_stack_clone2.set_visible_child(&content_stack_clone2.visible_child().expect("null").prev_sibling().unwrap())); window.present(); -} \ No newline at end of file +} diff --git a/src/eula_page.rs b/src/eula_page.rs index 8724948..752dc04 100644 --- a/src/eula_page.rs +++ b/src/eula_page.rs @@ -116,7 +116,18 @@ pub fn eula_page(content_stack: >k::Stack) { eula_selection_text.add_css_class("medium_sized_text"); let eula_buffer = gtk::TextBuffer::builder() - .text("WE OWN YOU\nWE OWN YOUR SOUL\nWE OWN YOUR WIFE\nWE OWN YOUR FIRST BORN\nWE OWN YOUR HOUSE\nWE OWN YOUR FOOD\nWE OWN YOUR CAR\nWE WILL TRACK YOU\nWE WILL FIND YOU\nTHEN WE WILL KILL YOU") + .text("There are a few things to keep in mind: + 1 - You understand that this distribution is -NOT- to be considered an ‘Ubuntu Flavor’. + 2 - This is a hobby distribution, so we will try our best to provide formal support but it will -NOT- be guaranteed. + 3 - Although PikaOS might provide identical patches and user experience to the Nobara project, we are -NOT- directly a part of them so questions and bug reports should not be sent directly to them (they dont have to deal with it!) + 4 - While the installer is running DO NOT INTERRUPT IT! or you will end up with a corrupted system. + 5 - Try to use pikman instead of apt when using the terminal, it is much faster! + 6 - You understand the xone driver downloads needed binaries locally and does not directly package or distribute any copyrighted firmware or other related data. + 7 - Automatic partitioning will format all partitons on a drive, so if you want to dualboot make a separate EFI partition for PikaOS and use manual partitioning + 8 - In case you need the login info for this session: + - username: pikaos + - password: + MEANING: JUST PRESS ENTER") .build(); let eula_selection_text_view = gtk::TextView::builder() From 5da3d4db9572a453e10694780c351e9eaa0a122e Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Wed, 24 Jan 2024 22:27:01 +0300 Subject: [PATCH 02/52] update to git --- data/scripts/begin-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/scripts/begin-install.sh b/data/scripts/begin-install.sh index 7b534d5..5f2bc3f 100644 --- a/data/scripts/begin-install.sh +++ b/data/scripts/begin-install.sh @@ -1,5 +1,7 @@ #! /bin/bash +exec &> >(tee /tmp/pika-installer-gtk4-log) + if [[ -f /tmp/pika-installer-gtk4-target-manual.txt ]] then sudo /usr/lib/pika/pika-installer-gtk4/scripts/manual-partition-install.sh @@ -10,4 +12,4 @@ else else echo "critical installer error" && exit 1 && touch /tmp/pika-installer-gtk4-fail.txt fi -fi \ No newline at end of file +fi From bea660695c2f4e417d2567802163ff2e3648b4bd Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Wed, 24 Jan 2024 22:33:01 +0300 Subject: [PATCH 03/52] Update Makefile --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bfb07da..2c2aa5d 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,10 @@ install: cargo fetch cargo build --release #cp -vf target/release/pika-installer-gtk4 $(DESTDIR)/usr/bin/ - chmod 755 $(DESTDIR)/usr/bin/pika-installer-gtk4 + #chmod 755 $(DESTDIR)/usr/bin/pika-installer-gtk4 mkdir -p $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/ cp -vf target/release/pika-installer-gtk4 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/ + chmod 755 $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/bin/pika-installer-gtk4 mkdir -p $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/ mkdir -p $(DESTDIR)/usr/share/glib-2.0/schemas/ cp -rvf data/scripts/*.sh $(DESTDIR)/usr/lib/pika/pika-installer-gtk4/scripts/ From 7925665b8878193abb616245169bdabfe0b0e22d Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Wed, 24 Jan 2024 22:57:20 +0300 Subject: [PATCH 04/52] --- data/scripts/automatic-partition-install.sh | 4 ++-- debian/changelog | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/scripts/automatic-partition-install.sh b/data/scripts/automatic-partition-install.sh index fe0952a..731035a 100644 --- a/data/scripts/automatic-partition-install.sh +++ b/data/scripts/automatic-partition-install.sh @@ -39,7 +39,7 @@ then mount /dev/${DISK}p2 /media/pika-install-mount/boot mkdir -p /media/pika-install-mount/boot/efi mount /dev/${DISK}p1 /media/pika-install-mount/boot/efi - pikainstall -r /media/pika-install-mount/ -c ${LUKS_KEY} -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 + pikainstall -r /media/pika-install-mount/ -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 else sleep 10 # Add filesystems @@ -57,7 +57,7 @@ then mount /dev/${DISK}2 /media/pika-install-mount/boot mkdir -p /media/pika-install-mount/boot/efi mount /dev/${DISK}1 /media/pika-install-mount/boot/efi - pikainstall -r /media/pika-install-mount/ -c ${LUKS_KEY} -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 + pikainstall -r /media/pika-install-mount/ -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 fi else LUKS_KEY="$(cat "/tmp/pika-installer-gtk4-target-automatic-luks.txt")" diff --git a/debian/changelog b/debian/changelog index 853f11b..fe9c934 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika1) pikauwu; urgency=low * First release From addf076cfa5459e645324b3683e4cb85f8be491d Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Wed, 24 Jan 2024 22:59:09 +0300 Subject: [PATCH 05/52] --- data/scripts/partition-utility.sh | 2 +- debian/changelog | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/scripts/partition-utility.sh b/data/scripts/partition-utility.sh index 3881ad9..e7cf815 100755 --- a/data/scripts/partition-utility.sh +++ b/data/scripts/partition-utility.sh @@ -2,7 +2,7 @@ if [[ "$1" = "get_block_devices" ]] then - lsblk -dn -o NAME + lsblk -dn -o NAME | grep -v -i -E 'loop|zram|sr|cdrom|portal' fi if [[ "$1" = "get_block_size" ]] diff --git a/debian/changelog b/debian/changelog index fe9c934..3973e36 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika1) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika2) pikauwu; urgency=low * First release From 1cde6ad6f97358111de267e52d5015560f26faa3 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Wed, 24 Jan 2024 23:17:28 +0300 Subject: [PATCH 06/52] --- Cargo.lock | 2 +- debian/changelog | 2 +- src/install_page.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ece0703..00a2c6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -620,7 +620,7 @@ checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "pika-installer-gtk4" -version = "0.1.0" +version = "1.0.0" dependencies = [ "async-channel", "fragile", diff --git a/debian/changelog b/debian/changelog index 3973e36..4ebda7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika2) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika3) pikauwu; urgency=low * First release diff --git a/src/install_page.rs b/src/install_page.rs index 32b6d67..c73259f 100644 --- a/src/install_page.rs +++ b/src/install_page.rs @@ -363,7 +363,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress if flag1_status_state == true { println!("Installation status: Flag1"); install_progress_bar.set_fraction(0.65); - install_progress_bar.set_text(Some("Enabling bls_boot flag on /boot")); + install_progress_bar.set_text(Some("Enabling bls_boot flag on /boot.")); } } })); @@ -390,7 +390,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress if flag2_status_state == true { println!("Installation status: Flag2"); install_progress_bar.set_fraction(0.70); - install_progress_bar.set_text(Some("Enabling efi flag on /boot/efi")); + install_progress_bar.set_text(Some("Enabling efi flag on /boot/efi.")); } } })); @@ -417,7 +417,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress if crypt_status_state == true { println!("Installation status: Crypttab"); install_progress_bar.set_fraction(0.75); - install_progress_bar.set_text(Some("Setting up encryption crypttab")); + install_progress_bar.set_text(Some("Setting up encryption crypttab.")); } } })); @@ -471,7 +471,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress if boot_status_state == true { println!("Installation status: Bootloader"); install_progress_bar.set_fraction(0.85); - install_progress_bar.set_text(Some("Configuring bootloader")); + install_progress_bar.set_text(Some("Configuring bootloader.")); } } })); From cba0e002642ca7251b2b92bc656a8541e13bdd73 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Thu, 25 Jan 2024 18:18:52 +0300 Subject: [PATCH 07/52] Some fixes --- debian/changelog | 2 +- src/eula_page.rs | 9 +++++++-- src/keyboard_page.rs | 8 ++++++++ src/language_page.rs | 6 ++++++ src/timezone_page.rs | 6 ++++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4ebda7d..362c947 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika3) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika4) pikauwu; urgency=low * First release diff --git a/src/eula_page.rs b/src/eula_page.rs index 752dc04..c168615 100644 --- a/src/eula_page.rs +++ b/src/eula_page.rs @@ -129,7 +129,7 @@ pub fn eula_page(content_stack: >k::Stack) { - password: MEANING: JUST PRESS ENTER") .build(); - + let eula_selection_text_view = gtk::TextView::builder() .hexpand(true) .vexpand(true) @@ -141,6 +141,11 @@ pub fn eula_page(content_stack: >k::Stack) { .buffer(&eula_buffer) .build(); + let eula_selection_text_scroll = gtk::ScrolledWindow::builder() + .height_request(350) + .child(&eula_selection_text_view) + .build(); + let eula_accept_checkbutton = gtk::CheckButton::builder() .label("I Agree and Accept the User license Agreement") .margin_top(15) @@ -152,7 +157,7 @@ pub fn eula_page(content_stack: >k::Stack) { // / eula_selection_box appends //// add text and and entry to eula page selections eula_selection_box.append(&eula_selection_text); - eula_selection_box.append(&eula_selection_text_view); + eula_selection_box.append(&eula_selection_text_scroll); eula_selection_box.append(&eula_accept_checkbutton); // / eula_header_box appends diff --git a/src/keyboard_page.rs b/src/keyboard_page.rs index 2ca0cc2..5347de3 100644 --- a/src/keyboard_page.rs +++ b/src/keyboard_page.rs @@ -198,6 +198,11 @@ pub fn keyboard_page(content_stack: >k::Stack) { keyboard_selection_expander_row.set_title(&keyboard_layout); bottom_next_button.set_sensitive(true); keyboard_data_buffer.set_text(&keyboard_layout); + Command::new("setxkbmap") + .arg("-layout") + .arg(keyboard_layout.clone()) + .spawn() + .expect("keyboard failed to start"); } })); if current_keyboard.contains(&(keyboard_layout_clone)) { @@ -221,6 +226,9 @@ pub fn keyboard_page(content_stack: >k::Stack) { //// Add the keyboard selection/page content box to keyboard main box keyboard_main_box.append(&keyboard_selection_box); + //// Add the keyboard selection/page content box to keyboard main box + keyboard_main_box.append(>k::Entry::builder().hexpand(true).valign(Align::End).vexpand(false).margin_bottom(15).margin_top(15).margin_end(15).margin_start(15).build()); + keyboard_main_box.append(&bottom_box); // / Content stack appends diff --git a/src/language_page.rs b/src/language_page.rs index 2b5c584..3c04124 100644 --- a/src/language_page.rs +++ b/src/language_page.rs @@ -229,6 +229,12 @@ pub fn language_page(content_stack: >k::Stack) { fs::remove_file("/tmp/pika-installer-gtk4-lang.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-lang.txt"); } fs::write("/tmp/pika-installer-gtk4-lang.txt", lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + Command::new("sudo") + .arg("localectl") + .arg("set-locale") + .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string()) + .spawn() + .expect("locale failed to start"); content_stack.set_visible_child_name("eula_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { diff --git a/src/timezone_page.rs b/src/timezone_page.rs index 492835b..3941c66 100644 --- a/src/timezone_page.rs +++ b/src/timezone_page.rs @@ -224,6 +224,12 @@ pub fn timezone_page(content_stack: >k::Stack) { fs::remove_file("/tmp/pika-installer-gtk4-timezone.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-timezone.txt"); } fs::write("/tmp/pika-installer-gtk4-timezone.txt", timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + Command::new("sudo") + .arg("timedatectl") + .arg("set-timezone") + .arg(&timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()) + .spawn() + .expect("timezone failed to start"); content_stack.set_visible_child_name("keyboard_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { From ff6ed36a05b3f671fde2890770dde590a446abaf Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Tue, 30 Jan 2024 17:01:47 +0300 Subject: [PATCH 08/52] Keyboard tester + more confirm detail + no close + percent based auto root --- data/scripts/automatic-partition-install.sh | 10 +-- debian/changelog | 2 +- src/build_ui.rs | 2 + src/install_page.rs | 77 +++++++++++++++++++-- src/keyboard_page.rs | 2 +- 5 files changed, 81 insertions(+), 12 deletions(-) diff --git a/data/scripts/automatic-partition-install.sh b/data/scripts/automatic-partition-install.sh index 731035a..2a02d11 100644 --- a/data/scripts/automatic-partition-install.sh +++ b/data/scripts/automatic-partition-install.sh @@ -7,6 +7,8 @@ LOCALE="$(cat "/tmp/pika-installer-gtk4-lang.txt")" KEYBOARD="$(cat "/tmp/pika-installer-gtk4-keyboard.txt")" TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")" +p3_size=$(echo "scale=2 ; $(cat /tmp/pika-installer-p3-size.txt) / 1024 / 1024" | bc | cut -f1 -d".") + touch "/tmp/pika-installer-gtk4-status-parting.txt" if [[ ! -f "/tmp/pika-installer-gtk4-target-automatic-luks.txt" ]] @@ -16,8 +18,8 @@ then parted -s -a optimal /dev/${DISK} mklabel gpt \ mkpart "linux-efi" 1MiB 513Mib \ mkpart "linux-boot" 513Mib 1537Mib \ - mkpart "linux-root" 1537Mib 42497Mib \ - mkpart "linux-home" 42497Mib 100% \ + mkpart "linux-root" 1537Mib "$(p3_size)"Mib \ + mkpart "linux-home" "$(p3_size)"Mib 100% \ print # add p to partition if it's nvme if echo ${DISK} | grep -i "nvme" @@ -66,8 +68,8 @@ else parted -s -a optimal /dev/${DISK} mklabel gpt \ mkpart "linux-efi" 1MiB 513Mib \ mkpart "linux-boot" 513Mib 1537Mib \ - mkpart "linux-root" 1537Mib 42497Mib \ - mkpart "linux-home" 42497Mib 100% \ + mkpart "linux-root" 1537Mib "$(p3_size)"Mib \ + mkpart "linux-home" "$(p3_size)"Mib 100% \ print # add p to partition if it's nvme if echo ${DISK} | grep -i "nvme" diff --git a/debian/changelog b/debian/changelog index 362c947..837dfdc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika4) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika5) pikauwu; urgency=low * First release diff --git a/src/build_ui.rs b/src/build_ui.rs index 9e69055..c91ce68 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -85,6 +85,8 @@ pub fn build_ui(app: &adw::Application) { .height_request(500) // Hide window instead of destroy .hide_on_close(true) + // + .deletable(false) // Startup .startup_id("pika-installer-gtk4") // build the window diff --git a/src/install_page.rs b/src/install_page.rs index c73259f..e0e8c35 100644 --- a/src/install_page.rs +++ b/src/install_page.rs @@ -11,6 +11,10 @@ use gtk::subclass::layout_child; use vte::prelude::*; use vte::*; + +use std::process::Command; +use pretty_bytes::converter::convert; + use std::fs; use std::path::Path; @@ -124,6 +128,73 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file")); } install_confirm_detail_target.add_css_class("property"); + + if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { + let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file"); + let target_size_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_size") + .arg(target_block_device) + .output() + .expect("failed to execute process"); + let target_size = String::from_utf8(target_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let mut target_p3_size = 0.0; + if (target_size * 40.0) / 100.0 >= 150000000000.0 { + target_p3_size = 150000000000.0 ; + } else { + target_p3_size = (target_size * 40.0) / 100.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; + 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(); + if target_block_device.contains("nvme") { + p1_row_text = "512 MB ".to_owned() + target_block_device + "p1" + " as fat32" + " on /boot/efi"; + 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) + " " + target_block_device + "p3" + " as btrfs" + " on /"; + p4_row_text = pretty_bytes::converter::convert(target_p4_size) + " " + target_block_device + "p4" + " as btrfs" + " on /home"; + } else { + 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) + " " + target_block_device + "3" + " as btrfs" + " on /"; + 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(); + // / 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); + install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); + install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); + install_confirm_details_boxed_list.append(&install_confirm_detail_target); + install_confirm_details_boxed_list.append(&install_confirm_p1); + install_confirm_details_boxed_list.append(&install_confirm_p2); + install_confirm_details_boxed_list.append(&install_confirm_p3); + install_confirm_details_boxed_list.append(&install_confirm_p4); + } else { + // / 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); + install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); + install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); + install_confirm_details_boxed_list.append(&install_confirm_detail_target); + } let install_confirm_button = gtk::Button::builder() .label("Confirm & Install PikaOS") @@ -145,12 +216,6 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte // Start Appending widgets to boxes - // / 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); - install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); - install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); - install_confirm_details_boxed_list.append(&install_confirm_detail_target); // install_confirm_selection_box.append(&install_confirm_details_boxed_list); install_confirm_selection_box.append(&install_confirm_button); diff --git a/src/keyboard_page.rs b/src/keyboard_page.rs index 5347de3..5d9a403 100644 --- a/src/keyboard_page.rs +++ b/src/keyboard_page.rs @@ -227,7 +227,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { keyboard_main_box.append(&keyboard_selection_box); //// Add the keyboard selection/page content box to keyboard main box - keyboard_main_box.append(>k::Entry::builder().hexpand(true).valign(Align::End).vexpand(false).margin_bottom(15).margin_top(15).margin_end(15).margin_start(15).build()); + keyboard_main_box.append(>k::Entry::builder().hexpand(true).valign(Align::End).vexpand(false).margin_bottom(15).margin_top(15).margin_end(15).margin_start(15).placeholder_text("Test Your Keyboard here!").build()); keyboard_main_box.append(&bottom_box); From 0db98f106ea56aec65c6b7b96e9943426c809e3d Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Tue, 30 Jan 2024 17:30:01 +0300 Subject: [PATCH 09/52] minimum root size calc --- debian/changelog | 2 +- src/install_page.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 837dfdc..c834dcf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika5) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika6) pikauwu; urgency=low * First release diff --git a/src/install_page.rs b/src/install_page.rs index e0e8c35..c6aa932 100644 --- a/src/install_page.rs +++ b/src/install_page.rs @@ -141,6 +141,8 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte let mut target_p3_size = 0.0; if (target_size * 40.0) / 100.0 >= 150000000000.0 { target_p3_size = 150000000000.0 ; + } else if (target_size * 40.0) / 100.0 <= 42949672960.0 { + target_p3_size = 42949672960.0 ; } else { target_p3_size = (target_size * 40.0) / 100.0 ; } From 727c626a38aed9ceeea9ef87a0d94ed730a1fc10 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Tue, 30 Jan 2024 17:40:27 +0300 Subject: [PATCH 10/52] shit --- data/scripts/automatic-partition-install.sh | 8 ++++---- debian/changelog | 2 +- src/install_page.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/scripts/automatic-partition-install.sh b/data/scripts/automatic-partition-install.sh index 2a02d11..293cfd8 100644 --- a/data/scripts/automatic-partition-install.sh +++ b/data/scripts/automatic-partition-install.sh @@ -18,8 +18,8 @@ then parted -s -a optimal /dev/${DISK} mklabel gpt \ mkpart "linux-efi" 1MiB 513Mib \ mkpart "linux-boot" 513Mib 1537Mib \ - mkpart "linux-root" 1537Mib "$(p3_size)"Mib \ - mkpart "linux-home" "$(p3_size)"Mib 100% \ + mkpart "linux-root" 1537Mib "$p3_size"Mib \ + mkpart "linux-home" "$p3_size"Mib 100% \ print # add p to partition if it's nvme if echo ${DISK} | grep -i "nvme" @@ -68,8 +68,8 @@ else parted -s -a optimal /dev/${DISK} mklabel gpt \ mkpart "linux-efi" 1MiB 513Mib \ mkpart "linux-boot" 513Mib 1537Mib \ - mkpart "linux-root" 1537Mib "$(p3_size)"Mib \ - mkpart "linux-home" "$(p3_size)"Mib 100% \ + mkpart "linux-root" 1537Mib "$p3_size"Mib \ + mkpart "linux-home" "$p3_size"Mib 100% \ print # add p to partition if it's nvme if echo ${DISK} | grep -i "nvme" diff --git a/debian/changelog b/debian/changelog index c834dcf..9f97a96 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika6) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika8) pikauwu; urgency=low * First release diff --git a/src/install_page.rs b/src/install_page.rs index c6aa932..572d17e 100644 --- a/src/install_page.rs +++ b/src/install_page.rs @@ -141,8 +141,8 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte let mut target_p3_size = 0.0; if (target_size * 40.0) / 100.0 >= 150000000000.0 { target_p3_size = 150000000000.0 ; - } else if (target_size * 40.0) / 100.0 <= 42949672960.0 { - target_p3_size = 42949672960.0 ; + } else if (target_size * 40.0) / 100.0 <= 36507222016.0 { + target_p3_size = 36507222016.0 ; } else { target_p3_size = (target_size * 40.0) / 100.0 ; } From 42fa310a5fc0c119c7cfd661d05b95cde7a73333 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 10 Feb 2024 21:03:19 +0300 Subject: [PATCH 11/52] RR: Seperate Partitioning pages --- .idea/.gitignore | 8 + .idea/modules.xml | 8 + .idea/pkg-pika-installer-gtk4.iml | 11 + .idea/vcs.xml | 6 + src/automatic_paritioning.rs | 281 +++++++++++ src/main.rs | 5 + src/manual_partitioning.rs | 523 ++++++++++++++++++++ src/partitioning_page.rs | 759 +----------------------------- 8 files changed, 852 insertions(+), 749 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/pkg-pika-installer-gtk4.iml create mode 100644 .idea/vcs.xml create mode 100644 src/automatic_paritioning.rs create mode 100644 src/manual_partitioning.rs diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e957f63 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pkg-pika-installer-gtk4.iml b/.idea/pkg-pika-installer-gtk4.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/pkg-pika-installer-gtk4.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/automatic_paritioning.rs b/src/automatic_paritioning.rs new file mode 100644 index 0000000..4f53cb7 --- /dev/null +++ b/src/automatic_paritioning.rs @@ -0,0 +1,281 @@ +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::env; +use pretty_bytes::converter::convert; + +use std::thread; +use std::time::*; + +use std::fs; +use std::path::Path; + +use crate::install_page; +pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) { + let partition_method_automatic_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_end(15) + .margin_start(15) + .build(); + + let partition_method_automatic_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the partitioning page + let partition_method_automatic_header_text = gtk::Label::builder() + .label("Automatic Partitioning Installer") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + partition_method_automatic_header_text.add_css_class("header_sized_text"); + + // the header icon for the partitioning icon + let partition_method_automatic_header_icon = gtk::Image::builder() + .icon_name("media-playlist-shuffle") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + let partition_method_automatic_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let partition_method_automatic_selection_text = gtk::Label::builder() + .label("Choose the Drive you want to install PikaOS on\nNote: This will erase the entire drive backup your data!") + .justify(Justification::Center) + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + partition_method_automatic_selection_text.add_css_class("medium_sized_text"); + + let devices_selection_expander_row = adw::ExpanderRow::builder() + .title("No disk selected for selection") + .build(); + + let null_checkbutton = gtk::CheckButton::builder() + .build(); + + let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder() + .height_request(200) + .build(); + + let devices_selection_expander_row_viewport_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + devices_selection_expander_row_viewport.set_child(Some(&devices_selection_expander_row_viewport_box)); + + let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder() + .selection_mode(SelectionMode::None) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + devices_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); + devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row); + + devices_selection_expander_row.add_row(&devices_selection_expander_row_viewport); + + let partition_method_automatic_get_devices_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_devices") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout")); + + let partition_method_automatic_disk_error_label = gtk::Label::builder() + .label("No Disk specified.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .build(); + partition_method_automatic_disk_error_label.add_css_class("small_error_text"); + + let partition_method_automatic_luks_error_label = gtk::Label::builder() + .label("LUKS Encryption Enabled but no password provided.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_automatic_luks_error_label.add_css_class("small_error_text"); + + let partition_method_automatic_luks_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + let partition_method_automatic_luks_checkbutton = gtk::CheckButton::builder() + .label("Enable LUKS2 Disk Encryption") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let partition_method_automatic_luks_listbox = gtk::ListBox::builder() + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + partition_method_automatic_luks_listbox.add_css_class("boxed-list"); + + let partition_method_automatic_luks_password_entry = adw::PasswordEntryRow::builder() + .title("LUKS Password") + .hexpand(true) + .sensitive(false) + .build(); + + let partition_method_automatic_target_buffer = gtk::TextBuffer::builder() + .build(); + + let partition_method_automatic_luks_buffer = gtk::TextBuffer::builder() + .build(); + + for device in partition_method_automatic_get_devices_reader.lines() { + let device = device.unwrap(); + let device_size_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_size") + .arg(device.clone()) + .output() + .expect("failed to execute process"); + let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let device_button = gtk::CheckButton::builder() + .valign(Align::Center) + .can_focus(false) + .build(); + device_button.set_group(Some(&null_checkbutton)); + let device_row = adw::ActionRow::builder() + .activatable_widget(&device_button) + .title(device.clone()) + .subtitle(pretty_bytes::converter::convert(device_size)) + .build(); + device_row.add_prefix(&device_button); + devices_selection_expander_row_viewport_box.append(&device_row); + device_button.connect_toggled(clone!(@weak device_button,@weak partition_method_automatic_luks_password_entry, @weak devices_selection_expander_row, @weak bottom_next_button, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { + if device_button.is_active() == true { + devices_selection_expander_row.set_title(&device); + if device_size > 39000000000.0 { + partition_method_automatic_disk_error_label.set_visible(false); + if partition_method_automatic_luks_checkbutton.is_active() == true { + if partition_method_automatic_luks_error_label.get_visible() { + // + } else { + bottom_next_button.set_sensitive(true); + } + } else { + partition_method_automatic_target_buffer.set_text(&device); + partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); + bottom_next_button.set_sensitive(true); + } + } else { + partition_method_automatic_disk_error_label.set_visible(true); + partition_method_automatic_disk_error_label.set_label("Disk Size too small, PikaOS needs 40GB Disk"); + bottom_next_button.set_sensitive(false); + } + } + })); + } + + partition_method_automatic_luks_checkbutton.connect_toggled(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { + if partition_method_automatic_luks_checkbutton.is_active() == true { + partition_method_automatic_luks_password_entry.set_sensitive(true); + if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { + partition_method_automatic_luks_error_label.set_visible(true); + bottom_next_button.set_sensitive(false); + } else { + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + bottom_next_button.set_sensitive(true); + } + } + } else { + partition_method_automatic_luks_password_entry.set_sensitive(false); + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + bottom_next_button.set_sensitive(true); + } + } + })); + + partition_method_automatic_luks_password_entry.connect_changed(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_luks_buffer => move |_| { + if partition_method_automatic_luks_checkbutton.is_active() == true { + partition_method_automatic_luks_password_entry.set_sensitive(true); + if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { + partition_method_automatic_luks_error_label.set_visible(true); + bottom_next_button.set_sensitive(false); + } else { + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); + bottom_next_button.set_sensitive(true); + } + } + } else { + partition_method_automatic_luks_password_entry.set_sensitive(false); + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); + bottom_next_button.set_sensitive(true); + } + } + })); + + partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry); + 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_header_box.append(&partition_method_automatic_header_text); + partition_method_automatic_header_box.append(&partition_method_automatic_header_icon); + partition_method_automatic_selection_box.append(&partition_method_automatic_selection_text); + partition_method_automatic_main_box.append(&partition_method_automatic_header_box); + partition_method_automatic_main_box.append(&partition_method_automatic_selection_box); + partition_method_automatic_main_box.append(&devices_selection_expander_row_viewport_listbox); + partition_method_automatic_main_box.append(&partition_method_automatic_luks_box); + partition_method_automatic_main_box.append(&partition_method_automatic_luks_error_label); + partition_method_automatic_main_box.append(&partition_method_automatic_disk_error_label); + + partitioning_stack.add_titled(&partition_method_automatic_main_box, Some("partition_method_automatic_page"), "partition_method_automatic_page"); + + return(partition_method_automatic_target_buffer, partition_method_automatic_luks_buffer) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 782a880..5008e17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,9 @@ mod keyboard_page; mod partitioning_page; mod install_page; mod done_page; +mod automatic_paritioning; +mod manual_partitioning; + use crate::save_window_size::save_window_size; use crate::welcome_page::welcome_page; use crate::efi_error_page::efi_error_page; @@ -29,6 +32,8 @@ use crate::eula_page::eula_page; use crate::timezone_page::timezone_page; use crate::keyboard_page::keyboard_page; use crate::partitioning_page::partitioning_page; +use crate::automatic_paritioning::automatic_partitioning; +use crate::manual_partitioning::manual_partitioning; use crate::install_page::install_page; use crate::done_page::done_page; diff --git a/src/manual_partitioning.rs b/src/manual_partitioning.rs new file mode 100644 index 0000000..ce3e73c --- /dev/null +++ b/src/manual_partitioning.rs @@ -0,0 +1,523 @@ +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::env; +use pretty_bytes::converter::convert; + +use std::thread; +use std::time::*; + +use std::fs; +use std::path::Path; + +use crate::install_page; + + +pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { + let partition_method_manual_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_end(15) + .margin_start(15) + .build(); + + let partition_method_manual_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the partitioning page + let partition_method_manual_header_text = gtk::Label::builder() + .label("Manual Partitioning Installer") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + partition_method_manual_header_text.add_css_class("header_sized_text"); + + // the header icon for the partitioning icon + let partition_method_manual_header_icon = gtk::Image::builder() + .icon_name("input-tablet") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + let partition_method_manual_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let partition_method_manual_selection_text = gtk::Label::builder() + .label(" - Mount your custom root drive somewhere.\n - Mount all your additional mountpoints relative to it.\n - Make sure to have the the following mountpoints:\n (CUSTOM_ROOT)/boot ~ 1000mb ext4\n (CUSTOM_ROOT)/boot/efi ~ 512mb vfat/fat32\n- If (CUSTOM_ROOT)/home has LUKS encryption, make sure to enable it here.\n - Note: This doesn't erase any data automatically, format your drives manually.") + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + partition_method_manual_selection_text.add_css_class("medium_sized_text"); + + let partition_method_manual_chroot_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let partition_method_manual_chroot_listbox = gtk::ListBox::builder() + .build(); + partition_method_manual_chroot_listbox.add_css_class("boxed-list"); + + let partition_method_manual_chroot_dir_file_dialog = gtk::FileChooserNative::new( + Some("Open File"), + gtk::Window::NONE, + gtk::FileChooserAction::SelectFolder, + Some("Open"), + Some("Cancel"), + ); + + partition_method_manual_chroot_dir_file_dialog.set_transient_for(Some(window)); + + let partition_method_manual_chroot_dir_entry = adw::EntryRow::builder() + .title("Custom Root Mountpoint") + .hexpand(true) + .build(); + + let partition_method_manual_chroot_dir_button_content = adw::ButtonContent::builder() + .label("Open") + .icon_name("folder-open") + .build(); + + let partition_method_manual_chroot_dir_button = gtk::Button::builder() + .child(&partition_method_manual_chroot_dir_button_content) + .margin_start(10) + .build(); + + let partition_method_manual_luks_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + let partition_method_manual_luks_listbox = gtk::ListBox::builder() + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + partition_method_manual_luks_listbox.add_css_class("boxed-list"); + + let partition_method_manual_luks_password_entry = adw::PasswordEntryRow::builder() + .title("LUKS Password") + .hexpand(true) + .sensitive(false) + .build(); + + let partition_method_manual_chroot_error_label = gtk::Label::builder() + .label("No mountpoint specified.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .build(); + partition_method_manual_chroot_error_label.add_css_class("small_error_text"); + + let partition_method_manual_boot_error_label = gtk::Label::builder() + .label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_manual_boot_error_label.add_css_class("small_error_text"); + + let partition_method_manual_efi_error_label = gtk::Label::builder() + .label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_manual_efi_error_label.add_css_class("small_error_text"); + + let partition_method_manual_luks_error_label = gtk::Label::builder() + .label("Home partition encrypted, but no LUKS password provided.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_manual_luks_error_label.add_css_class("small_error_text"); + + let partition_method_manual_gparted_button_content_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let partition_method_manual_gparted_button_content_text = gtk::Label::builder() + .label("Use this utility to partition/mount/format your drives.") + .build(); + + let partition_method_manual_gparted_button_content = adw::ButtonContent::builder() + .label("Open GPARTED") + .icon_name("gparted") + .build(); + + let partition_method_manual_gparted_button = gtk::Button::builder() + .child(&partition_method_manual_gparted_button_content_box) + .halign(Align::Center) + .valign(Align::End) + .build(); + + partition_method_manual_luks_listbox.append(&partition_method_manual_luks_password_entry); + partition_method_manual_luks_box.append(&partition_method_manual_luks_listbox); + partition_method_manual_header_box.append(&partition_method_manual_header_text); + partition_method_manual_header_box.append(&partition_method_manual_header_icon); + partition_method_manual_selection_box.append(&partition_method_manual_selection_text); + partition_method_manual_main_box.append(&partition_method_manual_header_box); + partition_method_manual_main_box.append(&partition_method_manual_selection_box); + partition_method_manual_chroot_listbox.append(&partition_method_manual_chroot_dir_entry); + partition_method_manual_chroot_box.append(&partition_method_manual_chroot_listbox); + partition_method_manual_chroot_box.append(&partition_method_manual_chroot_dir_button); + partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); + partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content_text); + partition_method_manual_main_box.append(&partition_method_manual_chroot_box); + partition_method_manual_main_box.append(&partition_method_manual_luks_box); + partition_method_manual_main_box.append(&partition_method_manual_luks_error_label); + partition_method_manual_main_box.append(&partition_method_manual_chroot_error_label); + partition_method_manual_main_box.append(&partition_method_manual_boot_error_label); + partition_method_manual_main_box.append(&partition_method_manual_efi_error_label); + partition_method_manual_main_box.append(&partition_method_manual_gparted_button); + + // clone partition_method_manual_chroot_dir_file_dialog as rust becuase glib breaks it show function for some reason + let partition_method_manual_chroot_dir_file_dialog_clone = partition_method_manual_chroot_dir_file_dialog.clone(); + partition_method_manual_chroot_dir_button.connect_clicked(move |_| { + partition_method_manual_chroot_dir_file_dialog_clone.set_visible(true); + }); + + partition_method_manual_chroot_dir_file_dialog.connect_response(clone!(@weak partition_method_manual_chroot_dir_file_dialog, @weak partition_method_manual_chroot_dir_entry => move |_, response| { + if response == gtk::ResponseType::Accept { + if partition_method_manual_chroot_dir_file_dialog.file().is_some() { + partition_method_manual_chroot_dir_entry.set_text(&partition_method_manual_chroot_dir_file_dialog.file().expect("FILE PATHING FAIL").path().expect("PATH STRINGING FAIL").into_os_string().into_string().unwrap()); + } + } + })); + + let partition_method_manual_target_buffer = gtk::TextBuffer::builder() + .build(); + + let partition_method_manual_luks_buffer = gtk::TextBuffer::builder() + .build(); + + partition_method_manual_chroot_dir_entry.connect_changed(clone!(@weak bottom_next_button, @weak partition_method_manual_luks_password_entry, @weak partition_method_manual_luks_error_label, @weak partition_method_manual_chroot_dir_entry, @weak partition_method_manual_chroot_error_label, @weak partition_method_manual_boot_error_label, @weak partition_method_manual_efi_error_label, @weak partition_method_manual_target_buffer, @weak partition_method_manual_luks_buffer => move |_| { + bottom_next_button.set_sensitive(false); + let custom_root_mountpoint = partition_method_manual_chroot_dir_entry.text().to_string(); + // Mountpoint Check + if custom_root_mountpoint.is_empty() { + partition_method_manual_chroot_error_label.set_label("No mountpoint specified."); + partition_method_manual_chroot_error_label.set_visible(true); + } else if custom_root_mountpoint.contains("/dev") { + partition_method_manual_chroot_error_label.set_label("This Installer Takes mountpoints not devices."); + partition_method_manual_chroot_error_label.set_visible(true); + } else { + partition_method_manual_chroot_error_label.set_visible(false); + } + // Home partition Check + let home_not_root_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("home_not_root") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + if home_not_root_cli.status.success() { + // Home encryption Checking + let (luks_manual_is_encrypt_sender, luks_manual_is_encrypt_receiver) = async_channel::unbounded(); + let luks_manual_is_encrypt_sender = luks_manual_is_encrypt_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(clone!(@strong custom_root_mountpoint => move || { + let check_home_encryption_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("check_home_encryption") + .arg(custom_root_mountpoint) + .output() + .expect("failed to execute process"); + if check_home_encryption_cli.status.success() { + luks_manual_is_encrypt_sender + .send_blocking(true) + .expect("The channel needs to be open."); + } else { + luks_manual_is_encrypt_sender + .send_blocking(false) + .expect("The channel needs to be open."); + } + })); + let luks_manual_is_encrypt_main_context = MainContext::default(); + // The main loop executes the asynchronous block + luks_manual_is_encrypt_main_context.spawn_local(clone!(@weak partition_method_manual_luks_password_entry => async move { + while let Ok(state) = luks_manual_is_encrypt_receiver.recv().await { + partition_method_manual_luks_password_entry.set_sensitive(state); + } + })); + // Luks Password Checking + let luks_passwd = partition_method_manual_luks_password_entry.text().to_string(); + let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); + let luks_manual_password_sender = luks_manual_password_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(clone!(@strong custom_root_mountpoint, @strong luks_passwd, @strong custom_root_mountpoint => move || { + let luks_check_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("check_home_luks_passwd") + .arg(custom_root_mountpoint) + .arg(luks_passwd) + .output() + .expect("failed to execute process"); + if luks_check_cli.status.success() { + luks_manual_password_sender + .send_blocking(false) + .expect("The channel needs to be open."); + } else { + luks_manual_password_sender + .send_blocking(true) + .expect("The channel needs to be open."); + } + })); + let luks_manual_password_main_context = MainContext::default(); + // The main loop executes the asynchronous block + luks_manual_password_main_context.spawn_local(clone!(@weak partition_method_manual_luks_error_label, @weak bottom_next_button => async move { + while let Ok(state) = luks_manual_password_receiver.recv().await { + partition_method_manual_luks_error_label.set_visible(state); + bottom_next_button.set_sensitive(!state); + } + })); + } + // Boot partition Checks + let home_not_boot_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("home_not_boot") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + let root_not_boot_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("root_not_boot") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + let boot_not_efi_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("boot_not_efi") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + + if home_not_boot_cli.status.success() && root_not_boot_cli.status.success() && boot_not_efi_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false) + } else { + if home_not_boot_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false); + } else { + partition_method_manual_boot_error_label.set_label("the /home and /boot partitions are the same."); + partition_method_manual_boot_error_label.set_visible(true); + } + if boot_not_efi_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false); + } else { + partition_method_manual_boot_error_label.set_label("the /boot/efi and /boot partitions are the same."); + partition_method_manual_boot_error_label.set_visible(true); + } + if root_not_boot_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false); + } else { + partition_method_manual_boot_error_label.set_label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot."); + partition_method_manual_boot_error_label.set_visible(true); + } + } + // EFI partition Checks + let root_not_efi_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("root_not_efi") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + if root_not_efi_cli.status.success() { + partition_method_manual_efi_error_label.set_visible(false); + } else { + partition_method_manual_efi_error_label.set_label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi."); + partition_method_manual_efi_error_label.set_visible(true); + } + if partition_method_manual_chroot_error_label.get_visible() == false && partition_method_manual_luks_error_label.get_visible() == false && partition_method_manual_boot_error_label.get_visible() == false && partition_method_manual_efi_error_label.get_visible() == false { + partition_method_manual_target_buffer.set_text(&custom_root_mountpoint); + bottom_next_button.set_sensitive(true); + } + })); + + partition_method_manual_luks_password_entry.connect_changed(clone!(@weak bottom_next_button, @weak partition_method_manual_chroot_dir_entry, @weak partition_method_manual_luks_password_entry, @weak partition_method_manual_luks_error_label, @weak partition_method_manual_chroot_error_label, @weak partition_method_manual_boot_error_label, @weak partition_method_manual_efi_error_label, @weak partition_method_manual_target_buffer, @weak partition_method_manual_luks_buffer => move |_| { + bottom_next_button.set_sensitive(false); + let custom_root_mountpoint = partition_method_manual_chroot_dir_entry.text().to_string(); + // Mountpoint Check + if custom_root_mountpoint.is_empty() { + partition_method_manual_chroot_error_label.set_label("No mountpoint specified."); + partition_method_manual_chroot_error_label.set_visible(true); + } else if custom_root_mountpoint.contains("/dev") { + partition_method_manual_chroot_error_label.set_label("This Installer Takes mountpoints not devices."); + partition_method_manual_chroot_error_label.set_visible(true); + } else { + partition_method_manual_chroot_error_label.set_visible(false); + } + // Home partition Check + let home_not_root_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("home_not_root") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + if home_not_root_cli.status.success() { + // Home encryption Checking + let (luks_manual_is_encrypt_sender, luks_manual_is_encrypt_receiver) = async_channel::unbounded(); + let luks_manual_is_encrypt_sender = luks_manual_is_encrypt_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(clone!(@strong custom_root_mountpoint => move || { + let check_home_encryption_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("check_home_encryption") + .arg(custom_root_mountpoint) + .output() + .expect("failed to execute process"); + if check_home_encryption_cli.status.success() { + luks_manual_is_encrypt_sender + .send_blocking(true) + .expect("The channel needs to be open."); + } else { + luks_manual_is_encrypt_sender + .send_blocking(false) + .expect("The channel needs to be open."); + } + })); + let luks_manual_is_encrypt_main_context = MainContext::default(); + // The main loop executes the asynchronous block + luks_manual_is_encrypt_main_context.spawn_local(clone!(@weak partition_method_manual_luks_password_entry => async move { + while let Ok(state) = luks_manual_is_encrypt_receiver.recv().await { + partition_method_manual_luks_password_entry.set_sensitive(state); + } + })); + // Luks Password Checking + let luks_passwd = partition_method_manual_luks_password_entry.text().to_string(); + let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); + let luks_manual_password_sender = luks_manual_password_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(clone!(@strong custom_root_mountpoint, @strong luks_passwd => move || { + let luks_check_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("check_home_luks_passwd") + .arg(custom_root_mountpoint) + .arg(luks_passwd) + .output() + .expect("failed to execute process"); + if luks_check_cli.status.success() { + luks_manual_password_sender + .send_blocking(false) + .expect("The channel needs to be open."); + } else { + luks_manual_password_sender + .send_blocking(true) + .expect("The channel needs to be open."); + } + })); + let luks_manual_password_main_context = MainContext::default(); + // The main loop executes the asynchronous block + luks_manual_password_main_context.spawn_local(clone!(@weak partition_method_manual_luks_error_label, @weak bottom_next_button => async move { + while let Ok(state) = luks_manual_password_receiver.recv().await { + partition_method_manual_luks_error_label.set_visible(state); + bottom_next_button.set_sensitive(!state); + } + })); + } + // Boot partition Checks + let home_not_boot_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("home_not_boot") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + let root_not_boot_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("root_not_boot") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + let boot_not_efi_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("boot_not_efi") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + + if home_not_boot_cli.status.success() && root_not_boot_cli.status.success() && boot_not_efi_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false) + } else { + if home_not_boot_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false); + } else { + partition_method_manual_boot_error_label.set_label("the /home and /boot partitions are the same."); + partition_method_manual_boot_error_label.set_visible(true); + } + if boot_not_efi_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false); + } else { + partition_method_manual_boot_error_label.set_label("the /boot/efi and /boot partitions are the same."); + partition_method_manual_boot_error_label.set_visible(true); + } + if root_not_boot_cli.status.success() { + partition_method_manual_boot_error_label.set_visible(false); + } else { + partition_method_manual_boot_error_label.set_label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot."); + partition_method_manual_boot_error_label.set_visible(true); + } + } + // EFI partition Checks + let root_not_efi_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("root_not_efi") + .arg(custom_root_mountpoint.clone()) + .output() + .expect("failed to execute process"); + if root_not_efi_cli.status.success() { + partition_method_manual_efi_error_label.set_visible(false); + } else { + partition_method_manual_efi_error_label.set_label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi."); + partition_method_manual_efi_error_label.set_visible(true); + } + if partition_method_manual_chroot_error_label.get_visible() == false && partition_method_manual_luks_error_label.get_visible() == false && partition_method_manual_boot_error_label.get_visible() == false && partition_method_manual_efi_error_label.get_visible() == false { + partition_method_manual_target_buffer.set_text(&custom_root_mountpoint); + bottom_next_button.set_sensitive(true); + } + })); + + partition_method_manual_gparted_button.connect_clicked(move |_| { + Command::new("gparted") + .spawn() + .expect("gparted failed to start"); + }); + + partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); + + return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) +} \ No newline at end of file diff --git a/src/partitioning_page.rs b/src/partitioning_page.rs index c52fb56..e1ebe59 100644 --- a/src/partitioning_page.rs +++ b/src/partitioning_page.rs @@ -9,6 +9,9 @@ use glib::*; use gdk::Display; use gtk::subclass::layout_child; +use crate::automatic_paritioning::automatic_partitioning; +use crate::manual_partitioning::manual_partitioning; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; @@ -203,753 +206,11 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , partitioning_method_main_box.append(&partitioning_selection_box); manual_method_button_content_box.append(&manual_method_button_content_image); - - // Automatic Partitioning Yard - let partition_method_automatic_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_end(15) - .margin_start(15) - .build(); - - let partition_method_automatic_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the partitioning page - let partition_method_automatic_header_text = gtk::Label::builder() - .label("Automatic Partitioning Installer") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - partition_method_automatic_header_text.add_css_class("header_sized_text"); - - // the header icon for the partitioning icon - let partition_method_automatic_header_icon = gtk::Image::builder() - .icon_name("media-playlist-shuffle") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - let partition_method_automatic_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let partition_method_automatic_selection_text = gtk::Label::builder() - .label("Choose the Drive you want to install PikaOS on\nNote: This will erase the entire drive backup your data!") - .justify(Justification::Center) - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - partition_method_automatic_selection_text.add_css_class("medium_sized_text"); - - let devices_selection_expander_row = adw::ExpanderRow::builder() - .title("No disk selected for selection") - .build(); - - let null_checkbutton = gtk::CheckButton::builder() - .build(); - - let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); - - let devices_selection_expander_row_viewport_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - devices_selection_expander_row_viewport.set_child(Some(&devices_selection_expander_row_viewport_box)); - - let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder() - .selection_mode(SelectionMode::None) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - devices_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); - devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row); - - devices_selection_expander_row.add_row(&devices_selection_expander_row_viewport); - - let partition_method_automatic_get_devices_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("get_block_devices") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout")); - - let partition_method_automatic_disk_error_label = gtk::Label::builder() - .label("No Disk specified.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .build(); - partition_method_automatic_disk_error_label.add_css_class("small_error_text"); - - let partition_method_automatic_luks_error_label = gtk::Label::builder() - .label("LUKS Encryption Enabled but no password provided.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_automatic_luks_error_label.add_css_class("small_error_text"); - - let partition_method_automatic_luks_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - let partition_method_automatic_luks_checkbutton = gtk::CheckButton::builder() - .label("Enable LUKS2 Disk Encryption") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let partition_method_automatic_luks_listbox = gtk::ListBox::builder() - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - partition_method_automatic_luks_listbox.add_css_class("boxed-list"); - - let partition_method_automatic_luks_password_entry = adw::PasswordEntryRow::builder() - .title("LUKS Password") - .hexpand(true) - .sensitive(false) - .build(); - - let partition_method_automatic_target_buffer = gtk::TextBuffer::builder() - .build(); - - let partition_method_automatic_luks_buffer = gtk::TextBuffer::builder() - .build(); - - for device in partition_method_automatic_get_devices_reader.lines() { - let device = device.unwrap(); - let device_size_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("get_block_size") - .arg(device.clone()) - .output() - .expect("failed to execute process"); - let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); - let device_button = gtk::CheckButton::builder() - .valign(Align::Center) - .can_focus(false) - .build(); - device_button.set_group(Some(&null_checkbutton)); - let device_row = adw::ActionRow::builder() - .activatable_widget(&device_button) - .title(device.clone()) - .subtitle(pretty_bytes::converter::convert(device_size)) - .build(); - device_row.add_prefix(&device_button); - devices_selection_expander_row_viewport_box.append(&device_row); - device_button.connect_toggled(clone!(@weak device_button,@weak partition_method_automatic_luks_password_entry, @weak devices_selection_expander_row, @weak bottom_next_button, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { - if device_button.is_active() == true { - devices_selection_expander_row.set_title(&device); - if device_size > 39000000000.0 { - partition_method_automatic_disk_error_label.set_visible(false); - if partition_method_automatic_luks_checkbutton.is_active() == true { - if partition_method_automatic_luks_error_label.get_visible() { - // - } else { - bottom_next_button.set_sensitive(true); - } - } else { - partition_method_automatic_target_buffer.set_text(&device); - partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); - bottom_next_button.set_sensitive(true); - } - } else { - partition_method_automatic_disk_error_label.set_visible(true); - partition_method_automatic_disk_error_label.set_label("Disk Size too small, PikaOS needs 40GB Disk"); - bottom_next_button.set_sensitive(false); - } - } - })); - } - - partition_method_automatic_luks_checkbutton.connect_toggled(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { - if partition_method_automatic_luks_checkbutton.is_active() == true { - partition_method_automatic_luks_password_entry.set_sensitive(true); - if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { - partition_method_automatic_luks_error_label.set_visible(true); - bottom_next_button.set_sensitive(false); - } else { - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - bottom_next_button.set_sensitive(true); - } - } - } else { - partition_method_automatic_luks_password_entry.set_sensitive(false); - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - bottom_next_button.set_sensitive(true); - } - } - })); - - partition_method_automatic_luks_password_entry.connect_changed(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_luks_buffer => move |_| { - if partition_method_automatic_luks_checkbutton.is_active() == true { - partition_method_automatic_luks_password_entry.set_sensitive(true); - if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { - partition_method_automatic_luks_error_label.set_visible(true); - bottom_next_button.set_sensitive(false); - } else { - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); - bottom_next_button.set_sensitive(true); - } - } - } else { - partition_method_automatic_luks_password_entry.set_sensitive(false); - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); - bottom_next_button.set_sensitive(true); - } - } - })); - - partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry); - 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_header_box.append(&partition_method_automatic_header_text); - partition_method_automatic_header_box.append(&partition_method_automatic_header_icon); - partition_method_automatic_selection_box.append(&partition_method_automatic_selection_text); - partition_method_automatic_main_box.append(&partition_method_automatic_header_box); - partition_method_automatic_main_box.append(&partition_method_automatic_selection_box); - partition_method_automatic_main_box.append(&devices_selection_expander_row_viewport_listbox); - partition_method_automatic_main_box.append(&partition_method_automatic_luks_box); - partition_method_automatic_main_box.append(&partition_method_automatic_luks_error_label); - partition_method_automatic_main_box.append(&partition_method_automatic_disk_error_label); - - // Manual Partitioning Yard - let partition_method_manual_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_end(15) - .margin_start(15) - .build(); - - let partition_method_manual_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the partitioning page - let partition_method_manual_header_text = gtk::Label::builder() - .label("Manual Partitioning Installer") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - partition_method_manual_header_text.add_css_class("header_sized_text"); - - // the header icon for the partitioning icon - let partition_method_manual_header_icon = gtk::Image::builder() - .icon_name("input-tablet") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - let partition_method_manual_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let partition_method_manual_selection_text = gtk::Label::builder() - .label(" - Mount your custom root drive somewhere.\n - Mount all your additional mountpoints relative to it.\n - Make sure to have the the following mountpoints:\n (CUSTOM_ROOT)/boot ~ 1000mb ext4\n (CUSTOM_ROOT)/boot/efi ~ 512mb vfat/fat32\n- If (CUSTOM_ROOT)/home has LUKS encryption, make sure to enable it here.\n - Note: This doesn't erase any data automatically, format your drives manually.") - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - partition_method_manual_selection_text.add_css_class("medium_sized_text"); - - let partition_method_manual_chroot_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let partition_method_manual_chroot_listbox = gtk::ListBox::builder() - .build(); - partition_method_manual_chroot_listbox.add_css_class("boxed-list"); - - let partition_method_manual_chroot_dir_file_dialog = gtk::FileChooserNative::new( - Some("Open File"), - gtk::Window::NONE, - gtk::FileChooserAction::SelectFolder, - Some("Open"), - Some("Cancel"), - ); - - partition_method_manual_chroot_dir_file_dialog.set_transient_for(Some(window)); - - let partition_method_manual_chroot_dir_entry = adw::EntryRow::builder() - .title("Custom Root Mountpoint") - .hexpand(true) - .build(); - - let partition_method_manual_chroot_dir_button_content = adw::ButtonContent::builder() - .label("Open") - .icon_name("folder-open") - .build(); - - let partition_method_manual_chroot_dir_button = gtk::Button::builder() - .child(&partition_method_manual_chroot_dir_button_content) - .margin_start(10) - .build(); - - let partition_method_manual_luks_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - let partition_method_manual_luks_listbox = gtk::ListBox::builder() - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - partition_method_manual_luks_listbox.add_css_class("boxed-list"); - - let partition_method_manual_luks_password_entry = adw::PasswordEntryRow::builder() - .title("LUKS Password") - .hexpand(true) - .sensitive(false) - .build(); - - let partition_method_manual_chroot_error_label = gtk::Label::builder() - .label("No mountpoint specified.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .build(); - partition_method_manual_chroot_error_label.add_css_class("small_error_text"); - - let partition_method_manual_boot_error_label = gtk::Label::builder() - .label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_manual_boot_error_label.add_css_class("small_error_text"); - - let partition_method_manual_efi_error_label = gtk::Label::builder() - .label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_manual_efi_error_label.add_css_class("small_error_text"); - - let partition_method_manual_luks_error_label = gtk::Label::builder() - .label("Home partition encrypted, but no LUKS password provided.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_manual_luks_error_label.add_css_class("small_error_text"); - - let partition_method_manual_gparted_button_content_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let partition_method_manual_gparted_button_content_text = gtk::Label::builder() - .label("Use this utility to partition/mount/format your drives.") - .build(); - - let partition_method_manual_gparted_button_content = adw::ButtonContent::builder() - .label("Open GPARTED") - .icon_name("gparted") - .build(); - - let partition_method_manual_gparted_button = gtk::Button::builder() - .child(&partition_method_manual_gparted_button_content_box) - .halign(Align::Center) - .valign(Align::End) - .build(); - - partition_method_manual_luks_listbox.append(&partition_method_manual_luks_password_entry); - partition_method_manual_luks_box.append(&partition_method_manual_luks_listbox); - partition_method_manual_header_box.append(&partition_method_manual_header_text); - partition_method_manual_header_box.append(&partition_method_manual_header_icon); - partition_method_manual_selection_box.append(&partition_method_manual_selection_text); - partition_method_manual_main_box.append(&partition_method_manual_header_box); - partition_method_manual_main_box.append(&partition_method_manual_selection_box); - partition_method_manual_chroot_listbox.append(&partition_method_manual_chroot_dir_entry); - partition_method_manual_chroot_box.append(&partition_method_manual_chroot_listbox); - partition_method_manual_chroot_box.append(&partition_method_manual_chroot_dir_button); - partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); - partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content_text); - partition_method_manual_main_box.append(&partition_method_manual_chroot_box); - partition_method_manual_main_box.append(&partition_method_manual_luks_box); - partition_method_manual_main_box.append(&partition_method_manual_luks_error_label); - partition_method_manual_main_box.append(&partition_method_manual_chroot_error_label); - partition_method_manual_main_box.append(&partition_method_manual_boot_error_label); - partition_method_manual_main_box.append(&partition_method_manual_efi_error_label); - partition_method_manual_main_box.append(&partition_method_manual_gparted_button); - - // clone partition_method_manual_chroot_dir_file_dialog as rust becuase glib breaks it show function for some reason - let partition_method_manual_chroot_dir_file_dialog_clone = partition_method_manual_chroot_dir_file_dialog.clone(); - partition_method_manual_chroot_dir_button.connect_clicked(move |_| { - partition_method_manual_chroot_dir_file_dialog_clone.set_visible(true); - }); - - partition_method_manual_chroot_dir_file_dialog.connect_response(clone!(@weak partition_method_manual_chroot_dir_file_dialog, @weak partition_method_manual_chroot_dir_entry => move |_, response| { - if response == gtk::ResponseType::Accept { - if partition_method_manual_chroot_dir_file_dialog.file().is_some() { - partition_method_manual_chroot_dir_entry.set_text(&partition_method_manual_chroot_dir_file_dialog.file().expect("FILE PATHING FAIL").path().expect("PATH STRINGING FAIL").into_os_string().into_string().unwrap()); - } - } - })); - - let partition_method_manual_target_buffer = gtk::TextBuffer::builder() - .build(); - - let partition_method_manual_luks_buffer = gtk::TextBuffer::builder() - .build(); - - partition_method_manual_chroot_dir_entry.connect_changed(clone!(@weak bottom_next_button, @weak partition_method_manual_chroot_dir_entry, @weak partition_method_manual_luks_password_entry, @weak partition_method_manual_luks_error_label, @weak partition_method_manual_chroot_error_label, @weak partition_method_manual_boot_error_label, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer, @weak partition_method_manual_efi_error_label, @weak partition_method_manual_target_buffer, @weak partition_method_manual_luks_buffer => move |_| { - bottom_next_button.set_sensitive(false); - let custom_root_mountpoint = partition_method_manual_chroot_dir_entry.text().to_string(); - // Mountpoint Check - if custom_root_mountpoint.is_empty() { - partition_method_manual_chroot_error_label.set_label("No mountpoint specified."); - partition_method_manual_chroot_error_label.set_visible(true); - } else if custom_root_mountpoint.contains("/dev") { - partition_method_manual_chroot_error_label.set_label("This Installer Takes mountpoints not devices."); - partition_method_manual_chroot_error_label.set_visible(true); - } else { - partition_method_manual_chroot_error_label.set_visible(false); - } - // Home partition Check - let home_not_root_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_root") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if home_not_root_cli.status.success() { - // Home encryption Checking - let (luks_manual_is_encrypt_sender, luks_manual_is_encrypt_receiver) = async_channel::unbounded(); - let luks_manual_is_encrypt_sender = luks_manual_is_encrypt_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint => move || { - let check_home_encryption_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_encryption") - .arg(custom_root_mountpoint) - .output() - .expect("failed to execute process"); - if check_home_encryption_cli.status.success() { - luks_manual_is_encrypt_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } else { - luks_manual_is_encrypt_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } - })); - let luks_manual_is_encrypt_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_is_encrypt_main_context.spawn_local(clone!(@weak partition_method_manual_luks_password_entry => async move { - while let Ok(state) = luks_manual_is_encrypt_receiver.recv().await { - partition_method_manual_luks_password_entry.set_sensitive(state); - } - })); - // Luks Password Checking - let luks_passwd = partition_method_manual_luks_password_entry.text().to_string(); - let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); - let luks_manual_password_sender = luks_manual_password_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint, @strong luks_passwd => move || { - let luks_check_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_luks_passwd") - .arg(custom_root_mountpoint) - .arg(luks_passwd) - .output() - .expect("failed to execute process"); - if luks_check_cli.status.success() { - luks_manual_password_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } else { - luks_manual_password_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } - })); - let luks_manual_password_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_password_main_context.spawn_local(clone!(@weak partition_method_manual_luks_error_label, @weak bottom_next_button => async move { - while let Ok(state) = luks_manual_password_receiver.recv().await { - partition_method_manual_luks_error_label.set_visible(state); - bottom_next_button.set_sensitive(!state); - } - })); - } - // Boot partition Checks - let home_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let root_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let boot_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("boot_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - - if home_not_boot_cli.status.success() && root_not_boot_cli.status.success() && boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false) - } else { - if home_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /home and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /boot/efi and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if root_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot."); - partition_method_manual_boot_error_label.set_visible(true); - } - } - // EFI partition Checks - let root_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if root_not_efi_cli.status.success() { - partition_method_manual_efi_error_label.set_visible(false); - } else { - partition_method_manual_efi_error_label.set_label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi."); - partition_method_manual_efi_error_label.set_visible(true); - } - if partition_method_manual_chroot_error_label.get_visible() == false && partition_method_manual_luks_error_label.get_visible() == false && partition_method_manual_boot_error_label.get_visible() == false && partition_method_manual_efi_error_label.get_visible() == false { - partition_method_manual_target_buffer.set_text(&custom_root_mountpoint); - bottom_next_button.set_sensitive(true); - } - })); - - partition_method_manual_luks_password_entry.connect_changed(clone!(@weak bottom_next_button, @weak partition_method_manual_chroot_dir_entry, @weak partition_method_manual_luks_password_entry, @weak partition_method_manual_luks_error_label, @weak partition_method_manual_chroot_error_label, @weak partition_method_manual_boot_error_label, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer, @weak partition_method_manual_efi_error_label, @weak partition_method_manual_target_buffer, @weak partition_method_manual_luks_buffer => move |_| { - bottom_next_button.set_sensitive(false); - let custom_root_mountpoint = partition_method_manual_chroot_dir_entry.text().to_string(); - // Mountpoint Check - if custom_root_mountpoint.is_empty() { - partition_method_manual_chroot_error_label.set_label("No mountpoint specified."); - partition_method_manual_chroot_error_label.set_visible(true); - } else if custom_root_mountpoint.contains("/dev") { - partition_method_manual_chroot_error_label.set_label("This Installer Takes mountpoints not devices."); - partition_method_manual_chroot_error_label.set_visible(true); - } else { - partition_method_manual_chroot_error_label.set_visible(false); - } - // Home partition Check - let home_not_root_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_root") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if home_not_root_cli.status.success() { - // Home encryption Checking - let (luks_manual_is_encrypt_sender, luks_manual_is_encrypt_receiver) = async_channel::unbounded(); - let luks_manual_is_encrypt_sender = luks_manual_is_encrypt_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint => move || { - let check_home_encryption_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_encryption") - .arg(custom_root_mountpoint) - .output() - .expect("failed to execute process"); - if check_home_encryption_cli.status.success() { - luks_manual_is_encrypt_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } else { - luks_manual_is_encrypt_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } - })); - let luks_manual_is_encrypt_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_is_encrypt_main_context.spawn_local(clone!(@weak partition_method_manual_luks_password_entry => async move { - while let Ok(state) = luks_manual_is_encrypt_receiver.recv().await { - partition_method_manual_luks_password_entry.set_sensitive(state); - } - })); - // Luks Password Checking - let luks_passwd = partition_method_manual_luks_password_entry.text().to_string(); - let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); - let luks_manual_password_sender = luks_manual_password_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint, @strong luks_passwd => move || { - let luks_check_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_luks_passwd") - .arg(custom_root_mountpoint) - .arg(luks_passwd) - .output() - .expect("failed to execute process"); - if luks_check_cli.status.success() { - luks_manual_password_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } else { - luks_manual_password_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } - })); - let luks_manual_password_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_password_main_context.spawn_local(clone!(@weak partition_method_manual_luks_error_label, @weak bottom_next_button => async move { - while let Ok(state) = luks_manual_password_receiver.recv().await { - partition_method_manual_luks_error_label.set_visible(state); - bottom_next_button.set_sensitive(!state); - } - })); - } - // Boot partition Checks - let home_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let root_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let boot_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("boot_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - - if home_not_boot_cli.status.success() && root_not_boot_cli.status.success() && boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false) - } else { - if home_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /home and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /boot/efi and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if root_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot."); - partition_method_manual_boot_error_label.set_visible(true); - } - } - // EFI partition Checks - let root_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if root_not_efi_cli.status.success() { - partition_method_manual_efi_error_label.set_visible(false); - } else { - partition_method_manual_efi_error_label.set_label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi."); - partition_method_manual_efi_error_label.set_visible(true); - } - if partition_method_manual_chroot_error_label.get_visible() == false && partition_method_manual_luks_error_label.get_visible() == false && partition_method_manual_boot_error_label.get_visible() == false && partition_method_manual_efi_error_label.get_visible() == false { - partition_method_manual_target_buffer.set_text(&custom_root_mountpoint); - bottom_next_button.set_sensitive(true); - } - })); - - partition_method_manual_gparted_button.connect_clicked(move |_| { - Command::new("gparted") - .spawn() - .expect("gparted failed to start"); - }); /// add all pages to partitioning stack partitioning_stack.add_titled(&partitioning_method_main_box, Some("partition_method_select_page"), "partition_method_select_page"); - partitioning_stack.add_titled(&partition_method_automatic_main_box, Some("partition_method_automatic_page"), "partition_method_automatic_page"); - partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); + let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button); + let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button); // add everything to the main box partitioning_main_box.append(&partitioning_stack); @@ -962,13 +223,13 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); - let partition_method_automatic_target_buffer_clone = partition_method_automatic_target_buffer.clone(); + let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); - let partition_method_automatic_luks_buffer_clone = partition_method_automatic_luks_buffer.clone(); + let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); - let partition_method_manual_target_buffer_clone = partition_method_manual_target_buffer.clone(); + let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); - let partition_method_manual_luks_buffer_clone = partition_method_manual_luks_buffer.clone(); + let partition_method_manual_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone(); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("install_page") @@ -1004,7 +265,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , content_stack.set_visible_child_name("install_page"); } else { fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - partition_method_manual_luks_buffer_clone.set_text(&partition_method_manual_luks_password_entry.text().to_string()); + partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string()); let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string(); if manual_luks_result.is_empty() { // From 5af8f030111ddd69b09126ed36be89d7d6b49eaa Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 11 Feb 2024 17:39:32 +0300 Subject: [PATCH 12/52] RR: Refactor module system --- .../main.rs} | 2 - src/automatic_partitioning/mod.rs | 1 + src/build_ui.rs | 25 +++++-- src/custom_button/imp.rs | 75 +++++++++++++++++++ src/custom_button/mod.rs | 17 +++++ src/{done_page.rs => done_page/main.rs} | 0 src/done_page/mod.rs | 1 + .../main.rs} | 0 src/efi_error_page/mod.rs | 1 + src/{eula_page.rs => eula_page/main.rs} | 0 src/eula_page/mod.rs | 1 + src/{install_page.rs => install_page/main.rs} | 3 +- src/install_page/mod.rs | 1 + .../main.rs} | 0 src/keyboard_page/mod.rs | 1 + .../main.rs} | 2 +- src/language_page/mod.rs | 1 + src/main.rs | 19 +---- .../main.rs} | 36 ++++++++- src/manual_partitioning/mod.rs | 1 + .../main.rs} | 7 +- src/partitioning_page/mod.rs | 1 + .../main.rs} | 2 +- src/save_window_size/mod.rs | 1 + .../main.rs} | 0 src/timezone_page/mod.rs | 1 + src/{welcome_page.rs => welcome_page/main.rs} | 2 +- src/welcome_page/mod.rs | 1 + 28 files changed, 166 insertions(+), 36 deletions(-) rename src/{automatic_paritioning.rs => automatic_partitioning/main.rs} (99%) create mode 100644 src/automatic_partitioning/mod.rs create mode 100644 src/custom_button/imp.rs create mode 100644 src/custom_button/mod.rs rename src/{done_page.rs => done_page/main.rs} (100%) create mode 100644 src/done_page/mod.rs rename src/{efi_error_page.rs => efi_error_page/main.rs} (100%) create mode 100644 src/efi_error_page/mod.rs rename src/{eula_page.rs => eula_page/main.rs} (100%) create mode 100644 src/eula_page/mod.rs rename src/{install_page.rs => install_page/main.rs} (99%) create mode 100644 src/install_page/mod.rs rename src/{keyboard_page.rs => keyboard_page/main.rs} (100%) create mode 100644 src/keyboard_page/mod.rs rename src/{language_page.rs => language_page/main.rs} (99%) create mode 100644 src/language_page/mod.rs rename src/{manual_partitioning.rs => manual_partitioning/main.rs} (96%) create mode 100644 src/manual_partitioning/mod.rs rename src/{partitioning_page.rs => partitioning_page/main.rs} (98%) create mode 100644 src/partitioning_page/mod.rs rename src/{save_window_size.rs => save_window_size/main.rs} (99%) create mode 100644 src/save_window_size/mod.rs rename src/{timezone_page.rs => timezone_page/main.rs} (100%) create mode 100644 src/timezone_page/mod.rs rename src/{welcome_page.rs => welcome_page/main.rs} (99%) create mode 100644 src/welcome_page/mod.rs diff --git a/src/automatic_paritioning.rs b/src/automatic_partitioning/main.rs similarity index 99% rename from src/automatic_paritioning.rs rename to src/automatic_partitioning/main.rs index 4f53cb7..1013cb7 100644 --- a/src/automatic_paritioning.rs +++ b/src/automatic_partitioning/main.rs @@ -22,8 +22,6 @@ use std::time::*; use std::fs; use std::path::Path; - -use crate::install_page; pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) { let partition_method_automatic_main_box = gtk::Box::builder() .orientation(Orientation::Vertical) diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/automatic_partitioning/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/build_ui.rs b/src/build_ui.rs index c91ce68..3453b4f 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -8,17 +8,26 @@ use adw::*; use glib::*; use gdk::Display; use gtk::subclass::layout_child; -use crate::save_window_size; -use crate::welcome_page; -use crate::efi_error_page; -use crate::language_page; -use crate::eula_page; -use crate::timezone_page; -use crate::keyboard_page; -use crate::partitioning_page; + use std::path::Path; +use crate::save_window_size::main::save_window_size; + +use crate::welcome_page::main::welcome_page; + +use crate::efi_error_page::main::efi_error_page; + +use crate::language_page::main::language_page; + +use crate::eula_page::main::eula_page; + +use crate::timezone_page::main::timezone_page; + +use crate::keyboard_page::main::keyboard_page; + +use crate::partitioning_page::main::partitioning_page; + // build ui function linked to app startup above pub fn build_ui(app: &adw::Application) { diff --git a/src/custom_button/imp.rs b/src/custom_button/imp.rs new file mode 100644 index 0000000..891d366 --- /dev/null +++ b/src/custom_button/imp.rs @@ -0,0 +1,75 @@ +use gtk::glib; +use gtk::*; +use gtk::prelude::*; +use gtk::subclass::prelude::*; +use adw::subclass::prelude::*; +use adw::prelude::ActionRowExt; +use std::cell::{Cell, RefCell}; +use glib::ObjectExt; +use gtk::Orientation::Horizontal; +use glib::GString; + +// Object holding the state +#[derive(glib::Properties, Default)] +#[properties(wrapper_type = super::CustomButton)] +pub struct CustomButton { + #[property(get, set)] + filesystem: RefCell, + partition: RefCell, + mountpoint: RefCell, + partition_scroll: gtk::ScrolledWindow +} + +// The central trait for subclassing a GObject +#[glib::object_subclass] +impl ObjectSubclass for CustomButton { + const NAME: &'static str = "MyGtkAppCustomButton"; + type Type = super::CustomButton; + type ParentType = adw::ActionRow; +} + +// Trait shared by all GObjects +// Trait shared by all GObjects +#[glib::derived_properties] +impl ObjectImpl for CustomButton { + fn constructed(&self) { + self.parent_constructed(); + + // Bind label to number + // `SYNC_CREATE` ensures that the label will be immediately set + let obj = self.obj(); + let action_row_content_box = gtk::Box::builder() + .orientation(Horizontal) + .spacing(0) + .build(); + + let partition_row_expander = adw::ExpanderRow::builder() + .title("Partition") + .build(); + + action_row_content_box.append(&partition_row_expander); + + obj.add_prefix(&action_row_content_box) + + //obj.bind_property("number", obj.as_ref(), "label") + // .sync_create() + // .build(); + } +} + +// Trait shared by all widgets +impl WidgetImpl for CustomButton {} + +// Trait shared by all buttons +// Trait shared by all buttons + +impl ListBoxRowImpl for CustomButton {} + +impl PreferencesRowImpl for CustomButton {} + +impl ActionRowImpl for CustomButton { + //fn clicked(&self) { + // let incremented_number = self.obj().number() + 1; + // self.obj().set_number(incremented_number); + //} +} \ No newline at end of file diff --git a/src/custom_button/mod.rs b/src/custom_button/mod.rs new file mode 100644 index 0000000..94275d0 --- /dev/null +++ b/src/custom_button/mod.rs @@ -0,0 +1,17 @@ +mod imp; + +use glib::Object; +use gtk::glib; +use gtk::ListBoxRow; + +glib::wrapper! { + pub struct CustomButton(ObjectSubclass) + @extends adw::ActionRow, gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, + @implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget; +} + +impl CustomButton { + pub fn new() -> Self { + Object::builder().build() + } +} \ No newline at end of file diff --git a/src/done_page.rs b/src/done_page/main.rs similarity index 100% rename from src/done_page.rs rename to src/done_page/main.rs diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/done_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/efi_error_page.rs b/src/efi_error_page/main.rs similarity index 100% rename from src/efi_error_page.rs rename to src/efi_error_page/main.rs diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/efi_error_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/eula_page.rs b/src/eula_page/main.rs similarity index 100% rename from src/eula_page.rs rename to src/eula_page/main.rs diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/eula_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/install_page.rs b/src/install_page/main.rs similarity index 99% rename from src/install_page.rs rename to src/install_page/main.rs index 572d17e..95ead21 100644 --- a/src/install_page.rs +++ b/src/install_page/main.rs @@ -11,6 +11,7 @@ use gtk::subclass::layout_child; use vte::prelude::*; use vte::*; +use crate::done_page::main::done_page; use std::process::Command; use pretty_bytes::converter::convert; @@ -18,8 +19,6 @@ use pretty_bytes::converter::convert; use std::fs; use std::path::Path; -use crate::done_page; - pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { // create the bottom box for next and back buttons diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/install_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/keyboard_page.rs b/src/keyboard_page/main.rs similarity index 100% rename from src/keyboard_page.rs rename to src/keyboard_page/main.rs diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/keyboard_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/language_page.rs b/src/language_page/main.rs similarity index 99% rename from src/language_page.rs rename to src/language_page/main.rs index 3c04124..afed32b 100644 --- a/src/language_page.rs +++ b/src/language_page/main.rs @@ -232,7 +232,7 @@ pub fn language_page(content_stack: >k::Stack) { Command::new("sudo") .arg("localectl") .arg("set-locale") - .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string()) + .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8") .spawn() .expect("locale failed to start"); content_stack.set_visible_child_name("eula_page") diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/language_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5008e17..a0b5442 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,6 @@ use glib::*; use gdk::Display; use gtk::subclass::layout_child; mod build_ui; -use crate::build_ui::build_ui; mod save_window_size; mod welcome_page; mod efi_error_page; @@ -21,21 +20,9 @@ mod keyboard_page; mod partitioning_page; mod install_page; mod done_page; -mod automatic_paritioning; +mod automatic_partitioning; mod manual_partitioning; - -use crate::save_window_size::save_window_size; -use crate::welcome_page::welcome_page; -use crate::efi_error_page::efi_error_page; -use crate::language_page::language_page; -use crate::eula_page::eula_page; -use crate::timezone_page::timezone_page; -use crate::keyboard_page::keyboard_page; -use crate::partitioning_page::partitioning_page; -use crate::automatic_paritioning::automatic_partitioning; -use crate::manual_partitioning::manual_partitioning; -use crate::install_page::install_page; -use crate::done_page::done_page; +mod custom_button; /// main function fn main() { @@ -52,7 +39,7 @@ fn main() { STYLE_PROVIDER_PRIORITY_APPLICATION, ); - app.connect_activate(build_ui); + app.connect_activate(build_ui::build_ui); }); application.run(); } diff --git a/src/manual_partitioning.rs b/src/manual_partitioning/main.rs similarity index 96% rename from src/manual_partitioning.rs rename to src/manual_partitioning/main.rs index ce3e73c..6bfcbfd 100644 --- a/src/manual_partitioning.rs +++ b/src/manual_partitioning/main.rs @@ -22,9 +22,25 @@ use std::time::*; use std::fs; use std::path::Path; +use crate::custom_button::CustomButton; -use crate::install_page; +fn create_mount_row_list_box(device: &str) -> ActionRow { + // Create check button + let check_button = CheckButton::builder() + .valign(Align::Center) + .can_focus(false) + .build(); + // Create row + let row = ActionRow::builder() + .activatable_widget(&check_button) + .title(device) + .build(); + row.add_prefix(&check_button); + + // Return row + row +} pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { let partition_method_manual_main_box = gtk::Box::builder() @@ -207,6 +223,22 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_main_box.append(&partition_method_manual_efi_error_label); partition_method_manual_main_box.append(&partition_method_manual_gparted_button); + let shit_button = CustomButton::new(); + + shit_button.set_title("haggar"); + + let create_mount_row_list_box = gtk::ListBox::builder() + .build(); + + //shit_button.connect_clicked(clone!(@weak create_mount_row_list_box => move |_|{ + // create_mount_row_list_box.append(&create_mount_row("col")) + //})); + + partition_method_manual_main_box.append(&shit_button); + partition_method_manual_main_box.append(&create_mount_row_list_box); + + + // clone partition_method_manual_chroot_dir_file_dialog as rust becuase glib breaks it show function for some reason let partition_method_manual_chroot_dir_file_dialog_clone = partition_method_manual_chroot_dir_file_dialog.clone(); partition_method_manual_chroot_dir_button.connect_clicked(move |_| { @@ -520,4 +552,4 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) -} \ No newline at end of file +} diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/manual_partitioning/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/partitioning_page.rs b/src/partitioning_page/main.rs similarity index 98% rename from src/partitioning_page.rs rename to src/partitioning_page/main.rs index e1ebe59..91337e1 100644 --- a/src/partitioning_page.rs +++ b/src/partitioning_page/main.rs @@ -9,8 +9,9 @@ use glib::*; use gdk::Display; use gtk::subclass::layout_child; -use crate::automatic_paritioning::automatic_partitioning; -use crate::manual_partitioning::manual_partitioning; +use crate::automatic_partitioning::main::automatic_partitioning; +use crate::manual_partitioning::main::manual_partitioning; +use crate::install_page::main::install_page; use std::io::BufRead; use std::io::BufReader; @@ -277,4 +278,4 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , } })); -} \ No newline at end of file +} diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/partitioning_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/save_window_size.rs b/src/save_window_size/main.rs similarity index 99% rename from src/save_window_size.rs rename to src/save_window_size/main.rs index 0e71de1..5ccb439 100644 --- a/src/save_window_size.rs +++ b/src/save_window_size/main.rs @@ -16,4 +16,4 @@ pub fn save_window_size(window: &adw::ApplicationWindow, glib_settings: &gio::Se let _ = glib_settings.set_int("window-width", size.0); let _ = glib_settings.set_int("window-height", size.1); let _ = glib_settings.set_boolean("is-maximized", window.is_maximized()); -} \ No newline at end of file +} diff --git a/src/save_window_size/mod.rs b/src/save_window_size/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/save_window_size/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/timezone_page.rs b/src/timezone_page/main.rs similarity index 100% rename from src/timezone_page.rs rename to src/timezone_page/main.rs diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/timezone_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file diff --git a/src/welcome_page.rs b/src/welcome_page/main.rs similarity index 99% rename from src/welcome_page.rs rename to src/welcome_page/main.rs index 59a0275..7f2cc90 100644 --- a/src/welcome_page.rs +++ b/src/welcome_page/main.rs @@ -166,4 +166,4 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page"))); live_media_button.connect_clicked(clone!(@weak window => move |_| window.close())); -} \ No newline at end of file +} diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs new file mode 100644 index 0000000..5a8f649 --- /dev/null +++ b/src/welcome_page/mod.rs @@ -0,0 +1 @@ +pub mod main; \ No newline at end of file From fea499f9387f684e4601467694274632e6e80a16 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 11 Feb 2024 21:02:16 +0300 Subject: [PATCH 13/52] RR: Create DriveMountPoint Row widget --- src/custom_button/imp.rs | 75 -------- src/drive_mount_row/imp.rs | 179 ++++++++++++++++++ src/{custom_button => drive_mount_row}/mod.rs | 11 +- src/main.rs | 2 +- src/manual_partitioning/main.rs | 19 +- 5 files changed, 204 insertions(+), 82 deletions(-) delete mode 100644 src/custom_button/imp.rs create mode 100644 src/drive_mount_row/imp.rs rename src/{custom_button => drive_mount_row}/mod.rs (63%) diff --git a/src/custom_button/imp.rs b/src/custom_button/imp.rs deleted file mode 100644 index 891d366..0000000 --- a/src/custom_button/imp.rs +++ /dev/null @@ -1,75 +0,0 @@ -use gtk::glib; -use gtk::*; -use gtk::prelude::*; -use gtk::subclass::prelude::*; -use adw::subclass::prelude::*; -use adw::prelude::ActionRowExt; -use std::cell::{Cell, RefCell}; -use glib::ObjectExt; -use gtk::Orientation::Horizontal; -use glib::GString; - -// Object holding the state -#[derive(glib::Properties, Default)] -#[properties(wrapper_type = super::CustomButton)] -pub struct CustomButton { - #[property(get, set)] - filesystem: RefCell, - partition: RefCell, - mountpoint: RefCell, - partition_scroll: gtk::ScrolledWindow -} - -// The central trait for subclassing a GObject -#[glib::object_subclass] -impl ObjectSubclass for CustomButton { - const NAME: &'static str = "MyGtkAppCustomButton"; - type Type = super::CustomButton; - type ParentType = adw::ActionRow; -} - -// Trait shared by all GObjects -// Trait shared by all GObjects -#[glib::derived_properties] -impl ObjectImpl for CustomButton { - fn constructed(&self) { - self.parent_constructed(); - - // Bind label to number - // `SYNC_CREATE` ensures that the label will be immediately set - let obj = self.obj(); - let action_row_content_box = gtk::Box::builder() - .orientation(Horizontal) - .spacing(0) - .build(); - - let partition_row_expander = adw::ExpanderRow::builder() - .title("Partition") - .build(); - - action_row_content_box.append(&partition_row_expander); - - obj.add_prefix(&action_row_content_box) - - //obj.bind_property("number", obj.as_ref(), "label") - // .sync_create() - // .build(); - } -} - -// Trait shared by all widgets -impl WidgetImpl for CustomButton {} - -// Trait shared by all buttons -// Trait shared by all buttons - -impl ListBoxRowImpl for CustomButton {} - -impl PreferencesRowImpl for CustomButton {} - -impl ActionRowImpl for CustomButton { - //fn clicked(&self) { - // let incremented_number = self.obj().number() + 1; - // self.obj().set_number(incremented_number); - //} -} \ No newline at end of file diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs new file mode 100644 index 0000000..5f91d87 --- /dev/null +++ b/src/drive_mount_row/imp.rs @@ -0,0 +1,179 @@ +use std::{ + cell::{ + Cell, + RefCell, + }, + sync::{ + OnceLock, + }, + rc::{ + Rc, + }, +}; + +use glib::{ + Properties, + subclass::Signal, + clone, +}; +use gtk::{ + glib, + prelude::*, + subclass::prelude::*, + *, + Orientation::Horizontal, +}; +use adw::{ + prelude::*, + subclass::prelude::*, + *, +}; + + +// ANCHOR: custom_button +// Object holding the state +#[derive(Properties, Default)] +#[properties(wrapper_type = super::DriveMountRow)] +pub struct DriveMountRow { + #[property(get, set)] + mountopt: RefCell, + #[property(get, set)] + partition: RefCell, + #[property(get, set)] + mountpoint: RefCell, + #[property(get, set)] + partition_scroll: Rc>, +} +// ANCHOR_END: custom_button + +// The central trait for subclassing a GObject +#[glib::object_subclass] +impl ObjectSubclass for DriveMountRow { + const NAME: &'static str = "DriveMountRow"; + type Type = super::DriveMountRow; + type ParentType = adw::ActionRow; +} + +// ANCHOR: object_impl +// Trait shared by all GObjects +#[glib::derived_properties] +impl ObjectImpl for DriveMountRow { + fn signals() -> &'static [Signal] { + static SIGNALS: OnceLock> = OnceLock::new(); + SIGNALS.get_or_init(|| { + vec![Signal::builder("row-deleted") + .build()] + }) + } + fn constructed(&self) { + self.parent_constructed(); + + // Bind label to number + // `SYNC_CREATE` ensures that the label will be immediately set + let obj = self.obj(); + let action_row_content_box = gtk::Box::builder() + .orientation(Horizontal) + .spacing(0) + .build(); + + let partition_row_expander_adw_listbox = gtk::ListBox::builder() + .margin_end(5) + .margin_start(5) + .margin_top(5) + .margin_bottom(5) + .build(); + partition_row_expander_adw_listbox.add_css_class("boxed-list"); + + let partition_row_expander = adw::ExpanderRow::builder() + .subtitle("Partition") + .build(); + + let mountpoint_entry_adw_listbox = gtk::ListBox::builder() + .halign(gtk::Align::Center) + .margin_top(5) + .margin_bottom(5) + .build(); + mountpoint_entry_adw_listbox.add_css_class("boxed-list"); + + let mountpoint_entry_row = adw::EntryRow::builder() + .title("Mountpoint") + .build(); + + let mountopt_entry_adw_listbox = gtk::ListBox::builder() + .margin_top(5) + .margin_bottom(5) + .margin_start(5) + .halign(gtk::Align::Center) + .build(); + mountopt_entry_adw_listbox.add_css_class("boxed-list"); + + let mountopt_entry_row = adw::EntryRow::builder() + .title("Additional Mount Options") + .build(); + + let partition_row_delete_button = gtk::Button::builder() + .margin_end(5) + .margin_start(5) + .margin_top(5) + .margin_bottom(5) + .height_request(60) + .width_request(60) + .icon_name("edit-delete") + .halign(gtk::Align::End) + .build(); + + partition_row_delete_button.connect_clicked(clone!( @weak obj => move |_| { + obj.emit_by_name::<()>("row-deleted", &[]); + })); + + partition_row_expander_adw_listbox.append(&partition_row_expander); + action_row_content_box.append(&partition_row_expander_adw_listbox); + + mountpoint_entry_adw_listbox.append(&mountpoint_entry_row); + action_row_content_box.append(&mountpoint_entry_adw_listbox); + + mountopt_entry_adw_listbox.append(&mountopt_entry_row); + action_row_content_box.append(&mountopt_entry_adw_listbox); + + action_row_content_box.append(&partition_row_delete_button); + + + obj.add_prefix(&action_row_content_box); + + // Bind label to number + // `SYNC_CREATE` ensures that the label will be immediately set + let obj = self.obj(); + obj.bind_property("partition", &partition_row_expander, "title") + .sync_create() + .bidirectional() + .build(); + + obj.bind_property("mountpoint", &mountpoint_entry_row, "text") + .sync_create() + .bidirectional() + .build(); + + obj.bind_property("mountopt", &mountopt_entry_row, "text") + .sync_create() + .bidirectional() + .build(); + + partition_row_expander.add_row(&obj.property::("partition_scroll")); + } +} +// Trait shared by all widgets +impl WidgetImpl for DriveMountRow {} + +// Trait shared by all buttons +// Trait shared by all buttons + +impl ListBoxRowImpl for DriveMountRow {} + +impl PreferencesRowImpl for DriveMountRow {} + +impl ActionRowImpl for DriveMountRow { + //fn clicked(&self) { + // let incremented_number = self.obj().number() + 1; + // self.obj().set_number(incremented_number); + //} +} \ No newline at end of file diff --git a/src/custom_button/mod.rs b/src/drive_mount_row/mod.rs similarity index 63% rename from src/custom_button/mod.rs rename to src/drive_mount_row/mod.rs index 94275d0..ab787e2 100644 --- a/src/custom_button/mod.rs +++ b/src/drive_mount_row/mod.rs @@ -2,16 +2,21 @@ mod imp; use glib::Object; use gtk::glib; -use gtk::ListBoxRow; glib::wrapper! { - pub struct CustomButton(ObjectSubclass) + pub struct DriveMountRow(ObjectSubclass) @extends adw::ActionRow, gtk::Widget, gtk::ListBoxRow, adw::PreferencesRow, @implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget; } -impl CustomButton { +impl DriveMountRow { pub fn new() -> Self { Object::builder().build() } +} + +impl Default for DriveMountRow { + fn default() -> Self { + Self::new() + } } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index a0b5442..cc5bb10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ mod install_page; mod done_page; mod automatic_partitioning; mod manual_partitioning; -mod custom_button; +mod drive_mount_row; /// main function fn main() { diff --git a/src/manual_partitioning/main.rs b/src/manual_partitioning/main.rs index 6bfcbfd..9d4026b 100644 --- a/src/manual_partitioning/main.rs +++ b/src/manual_partitioning/main.rs @@ -22,7 +22,7 @@ use std::time::*; use std::fs; use std::path::Path; -use crate::custom_button::CustomButton; +use crate::drive_mount_row::DriveMountRow; fn create_mount_row_list_box(device: &str) -> ActionRow { // Create check button @@ -223,13 +223,26 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_main_box.append(&partition_method_manual_efi_error_label); partition_method_manual_main_box.append(&partition_method_manual_gparted_button); - let shit_button = CustomButton::new(); + let shit_button = DriveMountRow::new(); - shit_button.set_title("haggar"); + shit_button.set_property("partition", "KAM"); + shit_button.set_property("mountpoint", "KAM"); + shit_button.set_property("mountopt", "KAM"); + shit_button.set_property("partition_scroll", >k::ScrolledWindow::new()); let create_mount_row_list_box = gtk::ListBox::builder() .build(); + let partition_method_manual_main_box_clone = partition_method_manual_main_box.clone(); + + shit_button.connect_closure( + "row-deleted", + false, + closure_local!(move |_shit_button: DriveMountRow| { + partition_method_manual_main_box_clone.remove(&_shit_button) + }), + ); + //shit_button.connect_clicked(clone!(@weak create_mount_row_list_box => move |_|{ // create_mount_row_list_box.append(&create_mount_row("col")) //})); From e2111fc77ba9a60a105b93deec87954cf8165302 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 11 Feb 2024 21:42:48 +0300 Subject: [PATCH 14/52] RR: Begin new manual installer --- src/drive_mount_row/imp.rs | 3 +- src/manual_partitioning/main.rs | 507 +++----------------------------- src/partitioning_page/main.rs | 38 +-- 3 files changed, 66 insertions(+), 482 deletions(-) diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 5f91d87..8a46725 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -116,8 +116,7 @@ impl ObjectImpl for DriveMountRow { .margin_start(5) .margin_top(5) .margin_bottom(5) - .height_request(60) - .width_request(60) + .width_request(40) .icon_name("edit-delete") .halign(gtk::Align::End) .build(); diff --git a/src/manual_partitioning/main.rs b/src/manual_partitioning/main.rs index 9d4026b..de79bdd 100644 --- a/src/manual_partitioning/main.rs +++ b/src/manual_partitioning/main.rs @@ -24,25 +24,26 @@ use std::fs; use std::path::Path; use crate::drive_mount_row::DriveMountRow; -fn create_mount_row_list_box(device: &str) -> ActionRow { - // Create check button - let check_button = CheckButton::builder() - .valign(Align::Center) - .can_focus(false) - .build(); - +fn create_mount_row(listbox: >k::ListBox) -> DriveMountRow { // Create row - let row = ActionRow::builder() - .activatable_widget(&check_button) - .title(device) - .build(); - row.add_prefix(&check_button); + let row = DriveMountRow::new(); + + let listbox_clone = listbox.clone(); + + row.connect_closure( + "row-deleted", + false, + closure_local!(move |_row: DriveMountRow| { + listbox_clone.remove(&_row) + }), + ); // Return row row } -pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { +//pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { +pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) { let partition_method_manual_main_box = gtk::Box::builder() .orientation(Orientation::Vertical) .margin_bottom(15) @@ -83,107 +84,6 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .orientation(Orientation::Vertical) .build(); - let partition_method_manual_selection_text = gtk::Label::builder() - .label(" - Mount your custom root drive somewhere.\n - Mount all your additional mountpoints relative to it.\n - Make sure to have the the following mountpoints:\n (CUSTOM_ROOT)/boot ~ 1000mb ext4\n (CUSTOM_ROOT)/boot/efi ~ 512mb vfat/fat32\n- If (CUSTOM_ROOT)/home has LUKS encryption, make sure to enable it here.\n - Note: This doesn't erase any data automatically, format your drives manually.") - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - partition_method_manual_selection_text.add_css_class("medium_sized_text"); - - let partition_method_manual_chroot_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let partition_method_manual_chroot_listbox = gtk::ListBox::builder() - .build(); - partition_method_manual_chroot_listbox.add_css_class("boxed-list"); - - let partition_method_manual_chroot_dir_file_dialog = gtk::FileChooserNative::new( - Some("Open File"), - gtk::Window::NONE, - gtk::FileChooserAction::SelectFolder, - Some("Open"), - Some("Cancel"), - ); - - partition_method_manual_chroot_dir_file_dialog.set_transient_for(Some(window)); - - let partition_method_manual_chroot_dir_entry = adw::EntryRow::builder() - .title("Custom Root Mountpoint") - .hexpand(true) - .build(); - - let partition_method_manual_chroot_dir_button_content = adw::ButtonContent::builder() - .label("Open") - .icon_name("folder-open") - .build(); - - let partition_method_manual_chroot_dir_button = gtk::Button::builder() - .child(&partition_method_manual_chroot_dir_button_content) - .margin_start(10) - .build(); - - let partition_method_manual_luks_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - let partition_method_manual_luks_listbox = gtk::ListBox::builder() - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - partition_method_manual_luks_listbox.add_css_class("boxed-list"); - - let partition_method_manual_luks_password_entry = adw::PasswordEntryRow::builder() - .title("LUKS Password") - .hexpand(true) - .sensitive(false) - .build(); - - let partition_method_manual_chroot_error_label = gtk::Label::builder() - .label("No mountpoint specified.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .build(); - partition_method_manual_chroot_error_label.add_css_class("small_error_text"); - - let partition_method_manual_boot_error_label = gtk::Label::builder() - .label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_manual_boot_error_label.add_css_class("small_error_text"); - - let partition_method_manual_efi_error_label = gtk::Label::builder() - .label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_manual_efi_error_label.add_css_class("small_error_text"); - - let partition_method_manual_luks_error_label = gtk::Label::builder() - .label("Home partition encrypted, but no LUKS password provided.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_manual_luks_error_label.add_css_class("small_error_text"); - let partition_method_manual_gparted_button_content_box = gtk::Box::builder() .orientation(Orientation::Vertical) .build(); @@ -200,361 +100,42 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: let partition_method_manual_gparted_button = gtk::Button::builder() .child(&partition_method_manual_gparted_button_content_box) .halign(Align::Center) - .valign(Align::End) + .valign(Align::Start) + .build(); + + let drive_mounts_adw_listbox = gtk::ListBox::builder() + .hexpand(true) + .vexpand(true) + .build(); + drive_mounts_adw_listbox.add_css_class("boxed-list"); + + let drive_mounts_viewport = gtk::ScrolledWindow::builder() + .halign(Align::Center) + .valign(Align::Center) + .margin_top(30) + .margin_bottom(30) + .margin_start(30) + .margin_end(30) + .propagate_natural_height(true) + .propagate_natural_width(true) + .hexpand(true) + .vexpand(true) + .child(&drive_mounts_adw_listbox) + .build(); + + let drive_mount_add_button = gtk::Button::builder() + .icon_name("list-add") .build(); - partition_method_manual_luks_listbox.append(&partition_method_manual_luks_password_entry); - partition_method_manual_luks_box.append(&partition_method_manual_luks_listbox); partition_method_manual_header_box.append(&partition_method_manual_header_text); partition_method_manual_header_box.append(&partition_method_manual_header_icon); - partition_method_manual_selection_box.append(&partition_method_manual_selection_text); partition_method_manual_main_box.append(&partition_method_manual_header_box); partition_method_manual_main_box.append(&partition_method_manual_selection_box); - partition_method_manual_chroot_listbox.append(&partition_method_manual_chroot_dir_entry); - partition_method_manual_chroot_box.append(&partition_method_manual_chroot_listbox); - partition_method_manual_chroot_box.append(&partition_method_manual_chroot_dir_button); partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content_text); - partition_method_manual_main_box.append(&partition_method_manual_chroot_box); - partition_method_manual_main_box.append(&partition_method_manual_luks_box); - partition_method_manual_main_box.append(&partition_method_manual_luks_error_label); - partition_method_manual_main_box.append(&partition_method_manual_chroot_error_label); - partition_method_manual_main_box.append(&partition_method_manual_boot_error_label); - partition_method_manual_main_box.append(&partition_method_manual_efi_error_label); partition_method_manual_main_box.append(&partition_method_manual_gparted_button); - - let shit_button = DriveMountRow::new(); - - shit_button.set_property("partition", "KAM"); - shit_button.set_property("mountpoint", "KAM"); - shit_button.set_property("mountopt", "KAM"); - shit_button.set_property("partition_scroll", >k::ScrolledWindow::new()); - - let create_mount_row_list_box = gtk::ListBox::builder() - .build(); - - let partition_method_manual_main_box_clone = partition_method_manual_main_box.clone(); - - shit_button.connect_closure( - "row-deleted", - false, - closure_local!(move |_shit_button: DriveMountRow| { - partition_method_manual_main_box_clone.remove(&_shit_button) - }), - ); - - //shit_button.connect_clicked(clone!(@weak create_mount_row_list_box => move |_|{ - // create_mount_row_list_box.append(&create_mount_row("col")) - //})); - - partition_method_manual_main_box.append(&shit_button); - partition_method_manual_main_box.append(&create_mount_row_list_box); - - - - // clone partition_method_manual_chroot_dir_file_dialog as rust becuase glib breaks it show function for some reason - let partition_method_manual_chroot_dir_file_dialog_clone = partition_method_manual_chroot_dir_file_dialog.clone(); - partition_method_manual_chroot_dir_button.connect_clicked(move |_| { - partition_method_manual_chroot_dir_file_dialog_clone.set_visible(true); - }); - - partition_method_manual_chroot_dir_file_dialog.connect_response(clone!(@weak partition_method_manual_chroot_dir_file_dialog, @weak partition_method_manual_chroot_dir_entry => move |_, response| { - if response == gtk::ResponseType::Accept { - if partition_method_manual_chroot_dir_file_dialog.file().is_some() { - partition_method_manual_chroot_dir_entry.set_text(&partition_method_manual_chroot_dir_file_dialog.file().expect("FILE PATHING FAIL").path().expect("PATH STRINGING FAIL").into_os_string().into_string().unwrap()); - } - } - })); - - let partition_method_manual_target_buffer = gtk::TextBuffer::builder() - .build(); - - let partition_method_manual_luks_buffer = gtk::TextBuffer::builder() - .build(); - - partition_method_manual_chroot_dir_entry.connect_changed(clone!(@weak bottom_next_button, @weak partition_method_manual_luks_password_entry, @weak partition_method_manual_luks_error_label, @weak partition_method_manual_chroot_dir_entry, @weak partition_method_manual_chroot_error_label, @weak partition_method_manual_boot_error_label, @weak partition_method_manual_efi_error_label, @weak partition_method_manual_target_buffer, @weak partition_method_manual_luks_buffer => move |_| { - bottom_next_button.set_sensitive(false); - let custom_root_mountpoint = partition_method_manual_chroot_dir_entry.text().to_string(); - // Mountpoint Check - if custom_root_mountpoint.is_empty() { - partition_method_manual_chroot_error_label.set_label("No mountpoint specified."); - partition_method_manual_chroot_error_label.set_visible(true); - } else if custom_root_mountpoint.contains("/dev") { - partition_method_manual_chroot_error_label.set_label("This Installer Takes mountpoints not devices."); - partition_method_manual_chroot_error_label.set_visible(true); - } else { - partition_method_manual_chroot_error_label.set_visible(false); - } - // Home partition Check - let home_not_root_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_root") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if home_not_root_cli.status.success() { - // Home encryption Checking - let (luks_manual_is_encrypt_sender, luks_manual_is_encrypt_receiver) = async_channel::unbounded(); - let luks_manual_is_encrypt_sender = luks_manual_is_encrypt_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint => move || { - let check_home_encryption_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_encryption") - .arg(custom_root_mountpoint) - .output() - .expect("failed to execute process"); - if check_home_encryption_cli.status.success() { - luks_manual_is_encrypt_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } else { - luks_manual_is_encrypt_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } - })); - let luks_manual_is_encrypt_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_is_encrypt_main_context.spawn_local(clone!(@weak partition_method_manual_luks_password_entry => async move { - while let Ok(state) = luks_manual_is_encrypt_receiver.recv().await { - partition_method_manual_luks_password_entry.set_sensitive(state); - } - })); - // Luks Password Checking - let luks_passwd = partition_method_manual_luks_password_entry.text().to_string(); - let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); - let luks_manual_password_sender = luks_manual_password_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint, @strong luks_passwd, @strong custom_root_mountpoint => move || { - let luks_check_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_luks_passwd") - .arg(custom_root_mountpoint) - .arg(luks_passwd) - .output() - .expect("failed to execute process"); - if luks_check_cli.status.success() { - luks_manual_password_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } else { - luks_manual_password_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } - })); - let luks_manual_password_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_password_main_context.spawn_local(clone!(@weak partition_method_manual_luks_error_label, @weak bottom_next_button => async move { - while let Ok(state) = luks_manual_password_receiver.recv().await { - partition_method_manual_luks_error_label.set_visible(state); - bottom_next_button.set_sensitive(!state); - } - })); - } - // Boot partition Checks - let home_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let root_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let boot_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("boot_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - - if home_not_boot_cli.status.success() && root_not_boot_cli.status.success() && boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false) - } else { - if home_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /home and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /boot/efi and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if root_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot."); - partition_method_manual_boot_error_label.set_visible(true); - } - } - // EFI partition Checks - let root_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if root_not_efi_cli.status.success() { - partition_method_manual_efi_error_label.set_visible(false); - } else { - partition_method_manual_efi_error_label.set_label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi."); - partition_method_manual_efi_error_label.set_visible(true); - } - if partition_method_manual_chroot_error_label.get_visible() == false && partition_method_manual_luks_error_label.get_visible() == false && partition_method_manual_boot_error_label.get_visible() == false && partition_method_manual_efi_error_label.get_visible() == false { - partition_method_manual_target_buffer.set_text(&custom_root_mountpoint); - bottom_next_button.set_sensitive(true); - } - })); - - partition_method_manual_luks_password_entry.connect_changed(clone!(@weak bottom_next_button, @weak partition_method_manual_chroot_dir_entry, @weak partition_method_manual_luks_password_entry, @weak partition_method_manual_luks_error_label, @weak partition_method_manual_chroot_error_label, @weak partition_method_manual_boot_error_label, @weak partition_method_manual_efi_error_label, @weak partition_method_manual_target_buffer, @weak partition_method_manual_luks_buffer => move |_| { - bottom_next_button.set_sensitive(false); - let custom_root_mountpoint = partition_method_manual_chroot_dir_entry.text().to_string(); - // Mountpoint Check - if custom_root_mountpoint.is_empty() { - partition_method_manual_chroot_error_label.set_label("No mountpoint specified."); - partition_method_manual_chroot_error_label.set_visible(true); - } else if custom_root_mountpoint.contains("/dev") { - partition_method_manual_chroot_error_label.set_label("This Installer Takes mountpoints not devices."); - partition_method_manual_chroot_error_label.set_visible(true); - } else { - partition_method_manual_chroot_error_label.set_visible(false); - } - // Home partition Check - let home_not_root_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_root") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if home_not_root_cli.status.success() { - // Home encryption Checking - let (luks_manual_is_encrypt_sender, luks_manual_is_encrypt_receiver) = async_channel::unbounded(); - let luks_manual_is_encrypt_sender = luks_manual_is_encrypt_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint => move || { - let check_home_encryption_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_encryption") - .arg(custom_root_mountpoint) - .output() - .expect("failed to execute process"); - if check_home_encryption_cli.status.success() { - luks_manual_is_encrypt_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } else { - luks_manual_is_encrypt_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } - })); - let luks_manual_is_encrypt_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_is_encrypt_main_context.spawn_local(clone!(@weak partition_method_manual_luks_password_entry => async move { - while let Ok(state) = luks_manual_is_encrypt_receiver.recv().await { - partition_method_manual_luks_password_entry.set_sensitive(state); - } - })); - // Luks Password Checking - let luks_passwd = partition_method_manual_luks_password_entry.text().to_string(); - let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); - let luks_manual_password_sender = luks_manual_password_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(clone!(@strong custom_root_mountpoint, @strong luks_passwd => move || { - let luks_check_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("check_home_luks_passwd") - .arg(custom_root_mountpoint) - .arg(luks_passwd) - .output() - .expect("failed to execute process"); - if luks_check_cli.status.success() { - luks_manual_password_sender - .send_blocking(false) - .expect("The channel needs to be open."); - } else { - luks_manual_password_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } - })); - let luks_manual_password_main_context = MainContext::default(); - // The main loop executes the asynchronous block - luks_manual_password_main_context.spawn_local(clone!(@weak partition_method_manual_luks_error_label, @weak bottom_next_button => async move { - while let Ok(state) = luks_manual_password_receiver.recv().await { - partition_method_manual_luks_error_label.set_visible(state); - bottom_next_button.set_sensitive(!state); - } - })); - } - // Boot partition Checks - let home_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("home_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let root_not_boot_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_boot") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - let boot_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("boot_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - - if home_not_boot_cli.status.success() && root_not_boot_cli.status.success() && boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false) - } else { - if home_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /home and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if boot_not_efi_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("the /boot/efi and /boot partitions are the same."); - partition_method_manual_boot_error_label.set_visible(true); - } - if root_not_boot_cli.status.success() { - partition_method_manual_boot_error_label.set_visible(false); - } else { - partition_method_manual_boot_error_label.set_label("No boot partition found in chroot, mount (CUSTOM_ROOT)/boot."); - partition_method_manual_boot_error_label.set_visible(true); - } - } - // EFI partition Checks - let root_not_efi_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("root_not_efi") - .arg(custom_root_mountpoint.clone()) - .output() - .expect("failed to execute process"); - if root_not_efi_cli.status.success() { - partition_method_manual_efi_error_label.set_visible(false); - } else { - partition_method_manual_efi_error_label.set_label("No EFI partition found in chroot, mount (CUSTOM_ROOT)/boot/efi."); - partition_method_manual_efi_error_label.set_visible(true); - } - if partition_method_manual_chroot_error_label.get_visible() == false && partition_method_manual_luks_error_label.get_visible() == false && partition_method_manual_boot_error_label.get_visible() == false && partition_method_manual_efi_error_label.get_visible() == false { - partition_method_manual_target_buffer.set_text(&custom_root_mountpoint); - bottom_next_button.set_sensitive(true); - } - })); + drive_mounts_adw_listbox.append(&drive_mount_add_button); + partition_method_manual_main_box.append(&drive_mounts_viewport); partition_method_manual_gparted_button.connect_clicked(move |_| { Command::new("gparted") @@ -562,7 +143,11 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .expect("gparted failed to start"); }); + drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox => move |_|{ + drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox)) + })); + partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); - return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) + //return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) } diff --git a/src/partitioning_page/main.rs b/src/partitioning_page/main.rs index 91337e1..020d383 100644 --- a/src/partitioning_page/main.rs +++ b/src/partitioning_page/main.rs @@ -224,13 +224,13 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); - let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); + //let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); - let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); + //let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); - let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); + //let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); - let partition_method_manual_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone(); + //let partition_method_manual_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone(); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("install_page") @@ -255,24 +255,24 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); } if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) { - fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); - if automatic_luks_result.is_empty() { - // - } else { - fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); - } + //fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + //let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); + //if automatic_luks_result.is_empty() { + // // + //} else { + // fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); + //} install_page(&done_main_box, &install_main_box, &content_stack, &window); content_stack.set_visible_child_name("install_page"); } else { - fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string()); - let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string(); - if manual_luks_result.is_empty() { - // - } else { - fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result); - } + //fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + //partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string()); + //let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string(); + //if manual_luks_result.is_empty() { + // // + //} else { + // fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result); + //} install_page(&done_main_box, &install_main_box, &content_stack, &window); content_stack.set_visible_child_name("install_page"); } From 8c904272f0ecab008d4e2ab00c00517acc12bada Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Wed, 14 Feb 2024 18:32:01 +0300 Subject: [PATCH 15/52] RR: Improve dir structure --- Cargo.toml | 1 + src/automatic_partitioning/main.rs | 279 -------------- src/automatic_partitioning/mod.rs | 280 +++++++++++++- src/build_ui.rs | 16 +- src/done_page/main.rs | 242 ------------ src/done_page/mod.rs | 243 +++++++++++- src/drive_mount_row/imp.rs | 4 +- src/efi_error_page/main.rs | 110 ------ src/efi_error_page/mod.rs | 111 +++++- src/eula_page/main.rs | 195 ---------- src/eula_page/mod.rs | 196 +++++++++- src/install_page/main.rs | 597 ---------------------------- src/install_page/mod.rs | 598 ++++++++++++++++++++++++++++- src/keyboard_page/main.rs | 252 ------------ src/keyboard_page/mod.rs | 253 +++++++++++- src/language_page/main.rs | 243 ------------ src/language_page/mod.rs | 244 +++++++++++- src/manual_partitioning/main.rs | 153 -------- src/manual_partitioning/mod.rs | 205 +++++++++- src/partitioning_page/main.rs | 281 -------------- src/partitioning_page/mod.rs | 291 +++++++++++++- src/save_window_size/main.rs | 19 - src/save_window_size/mod.rs | 20 +- src/timezone_page/main.rs | 239 ------------ src/timezone_page/mod.rs | 240 +++++++++++- src/welcome_page/main.rs | 169 -------- src/welcome_page/mod.rs | 170 +++++++- 27 files changed, 2850 insertions(+), 2801 deletions(-) delete mode 100644 src/automatic_partitioning/main.rs delete mode 100644 src/done_page/main.rs delete mode 100644 src/efi_error_page/main.rs delete mode 100644 src/eula_page/main.rs delete mode 100644 src/install_page/main.rs delete mode 100644 src/keyboard_page/main.rs delete mode 100644 src/language_page/main.rs delete mode 100644 src/manual_partitioning/main.rs delete mode 100644 src/partitioning_page/main.rs delete mode 100644 src/save_window_size/main.rs delete mode 100644 src/timezone_page/main.rs delete mode 100644 src/welcome_page/main.rs diff --git a/Cargo.toml b/Cargo.toml index 0b8f791..c0156b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ async-channel = "2.1.1" fragile = "2.0.0" glib = "0.18.5" gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] } +# parted = { version = "0.1.5", package = "libparted" } pretty-bytes = "0.2.2" time = "0.3.31" vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] } diff --git a/src/automatic_partitioning/main.rs b/src/automatic_partitioning/main.rs deleted file mode 100644 index 1013cb7..0000000 --- a/src/automatic_partitioning/main.rs +++ /dev/null @@ -1,279 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use std::io::BufRead; -use std::io::BufReader; -use std::process::Command; -use std::process::Stdio; -use std::time::Instant; -use std::env; -use pretty_bytes::converter::convert; - -use std::thread; -use std::time::*; - -use std::fs; -use std::path::Path; -pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) { - let partition_method_automatic_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_end(15) - .margin_start(15) - .build(); - - let partition_method_automatic_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the partitioning page - let partition_method_automatic_header_text = gtk::Label::builder() - .label("Automatic Partitioning Installer") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - partition_method_automatic_header_text.add_css_class("header_sized_text"); - - // the header icon for the partitioning icon - let partition_method_automatic_header_icon = gtk::Image::builder() - .icon_name("media-playlist-shuffle") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - let partition_method_automatic_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let partition_method_automatic_selection_text = gtk::Label::builder() - .label("Choose the Drive you want to install PikaOS on\nNote: This will erase the entire drive backup your data!") - .justify(Justification::Center) - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - partition_method_automatic_selection_text.add_css_class("medium_sized_text"); - - let devices_selection_expander_row = adw::ExpanderRow::builder() - .title("No disk selected for selection") - .build(); - - let null_checkbutton = gtk::CheckButton::builder() - .build(); - - let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); - - let devices_selection_expander_row_viewport_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - devices_selection_expander_row_viewport.set_child(Some(&devices_selection_expander_row_viewport_box)); - - let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder() - .selection_mode(SelectionMode::None) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - devices_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); - devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row); - - devices_selection_expander_row.add_row(&devices_selection_expander_row_viewport); - - let partition_method_automatic_get_devices_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("get_block_devices") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout")); - - let partition_method_automatic_disk_error_label = gtk::Label::builder() - .label("No Disk specified.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .build(); - partition_method_automatic_disk_error_label.add_css_class("small_error_text"); - - let partition_method_automatic_luks_error_label = gtk::Label::builder() - .label("LUKS Encryption Enabled but no password provided.") - .halign(Align::Start) - .valign(Align::End) - .vexpand(true) - .visible(false) - .build(); - partition_method_automatic_luks_error_label.add_css_class("small_error_text"); - - let partition_method_automatic_luks_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - let partition_method_automatic_luks_checkbutton = gtk::CheckButton::builder() - .label("Enable LUKS2 Disk Encryption") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let partition_method_automatic_luks_listbox = gtk::ListBox::builder() - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - partition_method_automatic_luks_listbox.add_css_class("boxed-list"); - - let partition_method_automatic_luks_password_entry = adw::PasswordEntryRow::builder() - .title("LUKS Password") - .hexpand(true) - .sensitive(false) - .build(); - - let partition_method_automatic_target_buffer = gtk::TextBuffer::builder() - .build(); - - let partition_method_automatic_luks_buffer = gtk::TextBuffer::builder() - .build(); - - for device in partition_method_automatic_get_devices_reader.lines() { - let device = device.unwrap(); - let device_size_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("get_block_size") - .arg(device.clone()) - .output() - .expect("failed to execute process"); - let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); - let device_button = gtk::CheckButton::builder() - .valign(Align::Center) - .can_focus(false) - .build(); - device_button.set_group(Some(&null_checkbutton)); - let device_row = adw::ActionRow::builder() - .activatable_widget(&device_button) - .title(device.clone()) - .subtitle(pretty_bytes::converter::convert(device_size)) - .build(); - device_row.add_prefix(&device_button); - devices_selection_expander_row_viewport_box.append(&device_row); - device_button.connect_toggled(clone!(@weak device_button,@weak partition_method_automatic_luks_password_entry, @weak devices_selection_expander_row, @weak bottom_next_button, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { - if device_button.is_active() == true { - devices_selection_expander_row.set_title(&device); - if device_size > 39000000000.0 { - partition_method_automatic_disk_error_label.set_visible(false); - if partition_method_automatic_luks_checkbutton.is_active() == true { - if partition_method_automatic_luks_error_label.get_visible() { - // - } else { - bottom_next_button.set_sensitive(true); - } - } else { - partition_method_automatic_target_buffer.set_text(&device); - partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); - bottom_next_button.set_sensitive(true); - } - } else { - partition_method_automatic_disk_error_label.set_visible(true); - partition_method_automatic_disk_error_label.set_label("Disk Size too small, PikaOS needs 40GB Disk"); - bottom_next_button.set_sensitive(false); - } - } - })); - } - - partition_method_automatic_luks_checkbutton.connect_toggled(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { - if partition_method_automatic_luks_checkbutton.is_active() == true { - partition_method_automatic_luks_password_entry.set_sensitive(true); - if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { - partition_method_automatic_luks_error_label.set_visible(true); - bottom_next_button.set_sensitive(false); - } else { - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - bottom_next_button.set_sensitive(true); - } - } - } else { - partition_method_automatic_luks_password_entry.set_sensitive(false); - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - bottom_next_button.set_sensitive(true); - } - } - })); - - partition_method_automatic_luks_password_entry.connect_changed(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_luks_buffer => move |_| { - if partition_method_automatic_luks_checkbutton.is_active() == true { - partition_method_automatic_luks_password_entry.set_sensitive(true); - if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { - partition_method_automatic_luks_error_label.set_visible(true); - bottom_next_button.set_sensitive(false); - } else { - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); - bottom_next_button.set_sensitive(true); - } - } - } else { - partition_method_automatic_luks_password_entry.set_sensitive(false); - partition_method_automatic_luks_error_label.set_visible(false); - if partition_method_automatic_disk_error_label.get_visible() { - // - } else { - partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); - bottom_next_button.set_sensitive(true); - } - } - })); - - partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry); - 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_header_box.append(&partition_method_automatic_header_text); - partition_method_automatic_header_box.append(&partition_method_automatic_header_icon); - partition_method_automatic_selection_box.append(&partition_method_automatic_selection_text); - partition_method_automatic_main_box.append(&partition_method_automatic_header_box); - partition_method_automatic_main_box.append(&partition_method_automatic_selection_box); - partition_method_automatic_main_box.append(&devices_selection_expander_row_viewport_listbox); - partition_method_automatic_main_box.append(&partition_method_automatic_luks_box); - partition_method_automatic_main_box.append(&partition_method_automatic_luks_error_label); - partition_method_automatic_main_box.append(&partition_method_automatic_disk_error_label); - - partitioning_stack.add_titled(&partition_method_automatic_main_box, Some("partition_method_automatic_page"), "partition_method_automatic_page"); - - return(partition_method_automatic_target_buffer, partition_method_automatic_luks_buffer) -} \ No newline at end of file diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index 5a8f649..1013cb7 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -1 +1,279 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::env; +use pretty_bytes::converter::convert; + +use std::thread; +use std::time::*; + +use std::fs; +use std::path::Path; +pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) { + let partition_method_automatic_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_end(15) + .margin_start(15) + .build(); + + let partition_method_automatic_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the partitioning page + let partition_method_automatic_header_text = gtk::Label::builder() + .label("Automatic Partitioning Installer") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + partition_method_automatic_header_text.add_css_class("header_sized_text"); + + // the header icon for the partitioning icon + let partition_method_automatic_header_icon = gtk::Image::builder() + .icon_name("media-playlist-shuffle") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + let partition_method_automatic_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let partition_method_automatic_selection_text = gtk::Label::builder() + .label("Choose the Drive you want to install PikaOS on\nNote: This will erase the entire drive backup your data!") + .justify(Justification::Center) + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + partition_method_automatic_selection_text.add_css_class("medium_sized_text"); + + let devices_selection_expander_row = adw::ExpanderRow::builder() + .title("No disk selected for selection") + .build(); + + let null_checkbutton = gtk::CheckButton::builder() + .build(); + + let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder() + .height_request(200) + .build(); + + let devices_selection_expander_row_viewport_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + devices_selection_expander_row_viewport.set_child(Some(&devices_selection_expander_row_viewport_box)); + + let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder() + .selection_mode(SelectionMode::None) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + devices_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); + devices_selection_expander_row_viewport_listbox.append(&devices_selection_expander_row); + + devices_selection_expander_row.add_row(&devices_selection_expander_row_viewport); + + let partition_method_automatic_get_devices_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_devices") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout")); + + let partition_method_automatic_disk_error_label = gtk::Label::builder() + .label("No Disk specified.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .build(); + partition_method_automatic_disk_error_label.add_css_class("small_error_text"); + + let partition_method_automatic_luks_error_label = gtk::Label::builder() + .label("LUKS Encryption Enabled but no password provided.") + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_automatic_luks_error_label.add_css_class("small_error_text"); + + let partition_method_automatic_luks_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + let partition_method_automatic_luks_checkbutton = gtk::CheckButton::builder() + .label("Enable LUKS2 Disk Encryption") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let partition_method_automatic_luks_listbox = gtk::ListBox::builder() + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + partition_method_automatic_luks_listbox.add_css_class("boxed-list"); + + let partition_method_automatic_luks_password_entry = adw::PasswordEntryRow::builder() + .title("LUKS Password") + .hexpand(true) + .sensitive(false) + .build(); + + let partition_method_automatic_target_buffer = gtk::TextBuffer::builder() + .build(); + + let partition_method_automatic_luks_buffer = gtk::TextBuffer::builder() + .build(); + + for device in partition_method_automatic_get_devices_reader.lines() { + let device = device.unwrap(); + let device_size_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_size") + .arg(device.clone()) + .output() + .expect("failed to execute process"); + let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let device_button = gtk::CheckButton::builder() + .valign(Align::Center) + .can_focus(false) + .build(); + device_button.set_group(Some(&null_checkbutton)); + let device_row = adw::ActionRow::builder() + .activatable_widget(&device_button) + .title(device.clone()) + .subtitle(pretty_bytes::converter::convert(device_size)) + .build(); + device_row.add_prefix(&device_button); + devices_selection_expander_row_viewport_box.append(&device_row); + device_button.connect_toggled(clone!(@weak device_button,@weak partition_method_automatic_luks_password_entry, @weak devices_selection_expander_row, @weak bottom_next_button, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { + if device_button.is_active() == true { + devices_selection_expander_row.set_title(&device); + if device_size > 39000000000.0 { + partition_method_automatic_disk_error_label.set_visible(false); + if partition_method_automatic_luks_checkbutton.is_active() == true { + if partition_method_automatic_luks_error_label.get_visible() { + // + } else { + bottom_next_button.set_sensitive(true); + } + } else { + partition_method_automatic_target_buffer.set_text(&device); + partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); + bottom_next_button.set_sensitive(true); + } + } else { + partition_method_automatic_disk_error_label.set_visible(true); + partition_method_automatic_disk_error_label.set_label("Disk Size too small, PikaOS needs 40GB Disk"); + bottom_next_button.set_sensitive(false); + } + } + })); + } + + partition_method_automatic_luks_checkbutton.connect_toggled(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_target_buffer, @weak partition_method_automatic_luks_buffer => move |_| { + if partition_method_automatic_luks_checkbutton.is_active() == true { + partition_method_automatic_luks_password_entry.set_sensitive(true); + if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { + partition_method_automatic_luks_error_label.set_visible(true); + bottom_next_button.set_sensitive(false); + } else { + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + bottom_next_button.set_sensitive(true); + } + } + } else { + partition_method_automatic_luks_password_entry.set_sensitive(false); + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + bottom_next_button.set_sensitive(true); + } + } + })); + + partition_method_automatic_luks_password_entry.connect_changed(clone!(@weak partition_method_automatic_luks_checkbutton, @weak partition_method_automatic_luks_password_entry, @weak partition_method_automatic_disk_error_label, @weak partition_method_automatic_luks_error_label, @weak bottom_next_button, @weak partition_method_automatic_luks_buffer => move |_| { + if partition_method_automatic_luks_checkbutton.is_active() == true { + partition_method_automatic_luks_password_entry.set_sensitive(true); + if partition_method_automatic_luks_password_entry.text().to_string().is_empty() { + partition_method_automatic_luks_error_label.set_visible(true); + bottom_next_button.set_sensitive(false); + } else { + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); + bottom_next_button.set_sensitive(true); + } + } + } else { + partition_method_automatic_luks_password_entry.set_sensitive(false); + partition_method_automatic_luks_error_label.set_visible(false); + if partition_method_automatic_disk_error_label.get_visible() { + // + } else { + partition_method_automatic_luks_buffer.set_text(&partition_method_automatic_luks_password_entry.text().to_string()); + bottom_next_button.set_sensitive(true); + } + } + })); + + partition_method_automatic_luks_listbox.append(&partition_method_automatic_luks_password_entry); + 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_header_box.append(&partition_method_automatic_header_text); + partition_method_automatic_header_box.append(&partition_method_automatic_header_icon); + partition_method_automatic_selection_box.append(&partition_method_automatic_selection_text); + partition_method_automatic_main_box.append(&partition_method_automatic_header_box); + partition_method_automatic_main_box.append(&partition_method_automatic_selection_box); + partition_method_automatic_main_box.append(&devices_selection_expander_row_viewport_listbox); + partition_method_automatic_main_box.append(&partition_method_automatic_luks_box); + partition_method_automatic_main_box.append(&partition_method_automatic_luks_error_label); + partition_method_automatic_main_box.append(&partition_method_automatic_disk_error_label); + + partitioning_stack.add_titled(&partition_method_automatic_main_box, Some("partition_method_automatic_page"), "partition_method_automatic_page"); + + return(partition_method_automatic_target_buffer, partition_method_automatic_luks_buffer) +} \ No newline at end of file diff --git a/src/build_ui.rs b/src/build_ui.rs index 3453b4f..67e9844 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -12,21 +12,21 @@ use gtk::subclass::layout_child; use std::path::Path; -use crate::save_window_size::main::save_window_size; +use crate::save_window_size::save_window_size; -use crate::welcome_page::main::welcome_page; +use crate::welcome_page::welcome_page; -use crate::efi_error_page::main::efi_error_page; +use crate::efi_error_page::efi_error_page; -use crate::language_page::main::language_page; +use crate::language_page::language_page; -use crate::eula_page::main::eula_page; +use crate::eula_page::eula_page; -use crate::timezone_page::main::timezone_page; +use crate::timezone_page::timezone_page; -use crate::keyboard_page::main::keyboard_page; +use crate::keyboard_page::keyboard_page; -use crate::partitioning_page::main::partitioning_page; +use crate::partitioning_page::partitioning_page; // build ui function linked to app startup above pub fn build_ui(app: &adw::Application) { diff --git a/src/done_page/main.rs b/src/done_page/main.rs deleted file mode 100644 index 33285b0..0000000 --- a/src/done_page/main.rs +++ /dev/null @@ -1,242 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use std::fs; -use std::path::Path; -use std::process::Command; - -pub fn done_page(done_main_box: >k::Box, content_stack: >k::Stack, window: &adw::ApplicationWindow) { - // the header box for the installation_successful page - let done_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the installation_successful page - let done_header_text = gtk::Label::builder() - .label("We're done!") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - done_header_text.add_css_class("header_sized_text"); - - // the header icon for the installation_successful icon - let done_header_icon = gtk::Image::builder() - .icon_name("debian-swirl") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - - // Successful install yard - // the header box for the installation_successful page - let installation_successful_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // make installation_successful selection box for choosing installation or live media - let installation_successful_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_start(15) - .margin_end(15) - .build(); - - let installation_successful_big_icon = gtk::Image::builder() - .icon_name("emblem-default") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .pixel_size(256) - .margin_top(0) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let installation_successful_text = gtk::Label::builder() - .label("The installation of PikaOS has been completed sucessfully.") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .build(); - installation_successful_text.add_css_class("header_sized_text"); - - let installation_successful_buttons_line = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .margin_bottom(15) - .margin_top(15) - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .vexpand(true) - .hexpand(true) - .build(); - - let installation_successful_exit_button = gtk::Button::builder() - .label("Exit") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .margin_start(5) - .margin_end(5) - .build(); - - let installation_successful_reboot_button = gtk::Button::builder() - .label("Reboot") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .margin_start(5) - .margin_end(5) - .build(); - - // / installation_successful_selection_box appends - - // / installation_successful_main_box appends - //// Add the installation_successful header to installation_successful main box - installation_successful_main_box.append(&done_header_box); - //// Add the installation_successful selection/page content box to installation_successful main box - installation_successful_main_box.append(&installation_successful_selection_box); - - installation_successful_buttons_line.append(&installation_successful_reboot_button); - installation_successful_buttons_line.append(&installation_successful_exit_button); - - // Start Appending widgets to boxes - - // / installation_successful_selection_box appends - //// add live and install media button to installation_successful page selections - installation_successful_selection_box.append(&installation_successful_big_icon); - installation_successful_selection_box.append(&installation_successful_text); - installation_successful_selection_box.append(&installation_successful_buttons_line); - - // / installation_successful_main_box appends - //// Add the installation_successful selection/page content box to installation_successful main box - installation_successful_main_box.append(&installation_successful_selection_box); - - installation_successful_exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); - installation_successful_reboot_button.connect_clicked(move |_| { - Command::new("reboot") - .spawn() - .expect("reboot failed to start"); - }); - - // Failed install yard - // the header box for the installation_failed page - let installation_failed_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // make installation_failed selection box for choosing installation or live media - let installation_failed_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_start(15) - .margin_end(15) - .build(); - - let installation_failed_big_icon = gtk::Image::builder() - .icon_name("emblem-default") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .pixel_size(256) - .margin_top(0) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let installation_failed_text = gtk::Label::builder() - .label("PikaOS has Failed!\nCheck logs for further info.") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .build(); - installation_failed_text.add_css_class("header_sized_text"); - - let installation_failed_buttons_line = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .margin_bottom(15) - .margin_top(15) - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .vexpand(true) - .hexpand(true) - .build(); - - let installation_failed_exit_button = gtk::Button::builder() - .label("Exit") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .margin_start(5) - .margin_end(5) - .build(); - - let installation_failed_logs_button = gtk::Button::builder() - .label("Logs") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .margin_start(5) - .margin_end(5) - .build(); - - // / installation_failed_selection_box appends - - // / installation_failed_main_box appends - //// Add the installation_failed header to installation_failed main box - installation_failed_main_box.append(&done_header_box); - //// Add the installation_failed selection/page content box to installation_failed main box - installation_failed_main_box.append(&installation_failed_selection_box); - - installation_failed_buttons_line.append(&installation_failed_logs_button); - installation_failed_buttons_line.append(&installation_failed_exit_button); - - // Start Appending widgets to boxes - - // / installation_failed_selection_box appends - //// add live and install media button to installation_failed page selections - installation_failed_selection_box.append(&installation_failed_big_icon); - installation_failed_selection_box.append(&installation_failed_text); - installation_failed_selection_box.append(&installation_failed_buttons_line); - - // / installation_failed_main_box appends - //// Add the installation_failed selection/page content box to installation_failed main box - installation_failed_main_box.append(&installation_failed_selection_box); - - installation_failed_exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); - installation_failed_logs_button.connect_clicked(move |_| { - Command::new("xdg-open") - .arg("/tmp/pika-installer-gtk4-log") - .spawn() - .expect("xdg-open failed to start"); - }); - - // / done_header_box appends - //// Add the installation_successful page header text and icon - done_header_box.append(&done_header_text); - done_header_box.append(&done_header_icon); - - // / done_header_box appends - //// Add the installation_successful page header text and icon - done_header_box.append(&done_header_text); - done_header_box.append(&done_header_icon); - - done_main_box.append(&done_header_box); - if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() { - done_main_box.append(&installation_successful_main_box) - } else { - done_main_box.append(&installation_failed_main_box) - } -} \ No newline at end of file diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index 5a8f649..e944520 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -1 +1,242 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::fs; +use std::path::Path; +use std::process::Command; + +pub fn done_page(done_main_box: >k::Box, content_stack: >k::Stack, window: &adw::ApplicationWindow) { + // the header box for the installation_successful page + let done_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the installation_successful page + let done_header_text = gtk::Label::builder() + .label("We're done!") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + done_header_text.add_css_class("header_sized_text"); + + // the header icon for the installation_successful icon + let done_header_icon = gtk::Image::builder() + .icon_name("debian-swirl") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + + // Successful install yard + // the header box for the installation_successful page + let installation_successful_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // make installation_successful selection box for choosing installation or live media + let installation_successful_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_start(15) + .margin_end(15) + .build(); + + let installation_successful_big_icon = gtk::Image::builder() + .icon_name("emblem-default") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .pixel_size(256) + .margin_top(0) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let installation_successful_text = gtk::Label::builder() + .label("The installation of PikaOS has been completed sucessfully.") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .build(); + installation_successful_text.add_css_class("header_sized_text"); + + let installation_successful_buttons_line = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .margin_bottom(15) + .margin_top(15) + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .vexpand(true) + .hexpand(true) + .build(); + + let installation_successful_exit_button = gtk::Button::builder() + .label("Exit") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .margin_start(5) + .margin_end(5) + .build(); + + let installation_successful_reboot_button = gtk::Button::builder() + .label("Reboot") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .margin_start(5) + .margin_end(5) + .build(); + + // / installation_successful_selection_box appends + + // / installation_successful_main_box appends + //// Add the installation_successful header to installation_successful main box + installation_successful_main_box.append(&done_header_box); + //// Add the installation_successful selection/page content box to installation_successful main box + installation_successful_main_box.append(&installation_successful_selection_box); + + installation_successful_buttons_line.append(&installation_successful_reboot_button); + installation_successful_buttons_line.append(&installation_successful_exit_button); + + // Start Appending widgets to boxes + + // / installation_successful_selection_box appends + //// add live and install media button to installation_successful page selections + installation_successful_selection_box.append(&installation_successful_big_icon); + installation_successful_selection_box.append(&installation_successful_text); + installation_successful_selection_box.append(&installation_successful_buttons_line); + + // / installation_successful_main_box appends + //// Add the installation_successful selection/page content box to installation_successful main box + installation_successful_main_box.append(&installation_successful_selection_box); + + installation_successful_exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); + installation_successful_reboot_button.connect_clicked(move |_| { + Command::new("reboot") + .spawn() + .expect("reboot failed to start"); + }); + + // Failed install yard + // the header box for the installation_failed page + let installation_failed_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // make installation_failed selection box for choosing installation or live media + let installation_failed_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_start(15) + .margin_end(15) + .build(); + + let installation_failed_big_icon = gtk::Image::builder() + .icon_name("emblem-default") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .pixel_size(256) + .margin_top(0) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let installation_failed_text = gtk::Label::builder() + .label("PikaOS has Failed!\nCheck logs for further info.") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .build(); + installation_failed_text.add_css_class("header_sized_text"); + + let installation_failed_buttons_line = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .margin_bottom(15) + .margin_top(15) + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .vexpand(true) + .hexpand(true) + .build(); + + let installation_failed_exit_button = gtk::Button::builder() + .label("Exit") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .margin_start(5) + .margin_end(5) + .build(); + + let installation_failed_logs_button = gtk::Button::builder() + .label("Logs") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .margin_start(5) + .margin_end(5) + .build(); + + // / installation_failed_selection_box appends + + // / installation_failed_main_box appends + //// Add the installation_failed header to installation_failed main box + installation_failed_main_box.append(&done_header_box); + //// Add the installation_failed selection/page content box to installation_failed main box + installation_failed_main_box.append(&installation_failed_selection_box); + + installation_failed_buttons_line.append(&installation_failed_logs_button); + installation_failed_buttons_line.append(&installation_failed_exit_button); + + // Start Appending widgets to boxes + + // / installation_failed_selection_box appends + //// add live and install media button to installation_failed page selections + installation_failed_selection_box.append(&installation_failed_big_icon); + installation_failed_selection_box.append(&installation_failed_text); + installation_failed_selection_box.append(&installation_failed_buttons_line); + + // / installation_failed_main_box appends + //// Add the installation_failed selection/page content box to installation_failed main box + installation_failed_main_box.append(&installation_failed_selection_box); + + installation_failed_exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); + installation_failed_logs_button.connect_clicked(move |_| { + Command::new("xdg-open") + .arg("/tmp/pika-installer-gtk4-log") + .spawn() + .expect("xdg-open failed to start"); + }); + + // / done_header_box appends + //// Add the installation_successful page header text and icon + done_header_box.append(&done_header_text); + done_header_box.append(&done_header_icon); + + // / done_header_box appends + //// Add the installation_successful page header text and icon + done_header_box.append(&done_header_text); + done_header_box.append(&done_header_icon); + + done_main_box.append(&done_header_box); + if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() { + done_main_box.append(&installation_successful_main_box) + } else { + done_main_box.append(&installation_failed_main_box) + } +} \ No newline at end of file diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 8a46725..367fe8d 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -78,7 +78,7 @@ impl ObjectImpl for DriveMountRow { let partition_row_expander_adw_listbox = gtk::ListBox::builder() .margin_end(5) - .margin_start(5) + .margin_start(0) .margin_top(5) .margin_bottom(5) .build(); @@ -112,7 +112,7 @@ impl ObjectImpl for DriveMountRow { .build(); let partition_row_delete_button = gtk::Button::builder() - .margin_end(5) + .margin_end(0) .margin_start(5) .margin_top(5) .margin_bottom(5) diff --git a/src/efi_error_page/main.rs b/src/efi_error_page/main.rs deleted file mode 100644 index cb4436f..0000000 --- a/src/efi_error_page/main.rs +++ /dev/null @@ -1,110 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { - // the header box for the efi_error page - let efi_error_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the efi_error page - let efi_error_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the efi_error page - let efi_error_header_text = gtk::Label::builder() - .label("Unsupported boot platform") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - efi_error_header_text.add_css_class("header_sized_text"); - - // the header icon for the efi_error icon - let efi_error_header_icon = gtk::Image::builder() - .icon_name("emblem-error") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // make efi_error selection box for choosing installation or live media - let efi_error_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_start(15) - .margin_end(15) - .build(); - - - let efi_error_text = gtk::Label::builder() - .vexpand(true) - .hexpand(true) - .label("PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode.") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .build(); - efi_error_text.add_css_class("big_error_text"); - - let kill_me_button = gtk::Button::builder() - .label("Exit") - .vexpand(true) - .hexpand(true) - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .build(); - - // / efi_error_selection_box appends - - // / efi_error_header_box appends - //// Add the efi_error page header text and icon - efi_error_header_box.append(&efi_error_header_text); - efi_error_header_box.append(&efi_error_header_icon); - - // / efi_error_main_box appends - //// Add the efi_error header to efi_error main box - efi_error_main_box.append(&efi_error_header_box); - //// Add the efi_error selection/page content box to efi_error main box - efi_error_main_box.append(&efi_error_selection_box); - - // Start Appending widgets to boxes - - // / efi_error_selection_box appends - //// add live and install media button to efi_error page selections - efi_error_selection_box.append(&efi_error_text); - efi_error_selection_box.append(&kill_me_button); - - // / efi_error_header_box appends - //// Add the efi_error page header text and icon - efi_error_header_box.append(&efi_error_header_text); - efi_error_header_box.append(&efi_error_header_icon); - - // / efi_error_main_box appends - //// Add the efi_error header to efi_error main box - efi_error_main_box.append(&efi_error_header_box); - //// Add the efi_error selection/page content box to efi_error main box - efi_error_main_box.append(&efi_error_selection_box); - - // / Content stack appends - //// Add the efi_error_main_box as page: efi_error_page, Give it nice title - content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome"); - - kill_me_button.connect_clicked(clone!(@weak window => move |_| window.close())); -} \ No newline at end of file diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index 5a8f649..a1828d4 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -1 +1,110 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { + // the header box for the efi_error page + let efi_error_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the efi_error page + let efi_error_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the efi_error page + let efi_error_header_text = gtk::Label::builder() + .label("Unsupported boot platform") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + efi_error_header_text.add_css_class("header_sized_text"); + + // the header icon for the efi_error icon + let efi_error_header_icon = gtk::Image::builder() + .icon_name("emblem-error") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // make efi_error selection box for choosing installation or live media + let efi_error_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_start(15) + .margin_end(15) + .build(); + + + let efi_error_text = gtk::Label::builder() + .vexpand(true) + .hexpand(true) + .label("PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode.") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .build(); + efi_error_text.add_css_class("big_error_text"); + + let kill_me_button = gtk::Button::builder() + .label("Exit") + .vexpand(true) + .hexpand(true) + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .build(); + + // / efi_error_selection_box appends + + // / efi_error_header_box appends + //// Add the efi_error page header text and icon + efi_error_header_box.append(&efi_error_header_text); + efi_error_header_box.append(&efi_error_header_icon); + + // / efi_error_main_box appends + //// Add the efi_error header to efi_error main box + efi_error_main_box.append(&efi_error_header_box); + //// Add the efi_error selection/page content box to efi_error main box + efi_error_main_box.append(&efi_error_selection_box); + + // Start Appending widgets to boxes + + // / efi_error_selection_box appends + //// add live and install media button to efi_error page selections + efi_error_selection_box.append(&efi_error_text); + efi_error_selection_box.append(&kill_me_button); + + // / efi_error_header_box appends + //// Add the efi_error page header text and icon + efi_error_header_box.append(&efi_error_header_text); + efi_error_header_box.append(&efi_error_header_icon); + + // / efi_error_main_box appends + //// Add the efi_error header to efi_error main box + efi_error_main_box.append(&efi_error_header_box); + //// Add the efi_error selection/page content box to efi_error main box + efi_error_main_box.append(&efi_error_selection_box); + + // / Content stack appends + //// Add the efi_error_main_box as page: efi_error_page, Give it nice title + content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome"); + + kill_me_button.connect_clicked(clone!(@weak window => move |_| window.close())); +} \ No newline at end of file diff --git a/src/eula_page/main.rs b/src/eula_page/main.rs deleted file mode 100644 index c168615..0000000 --- a/src/eula_page/main.rs +++ /dev/null @@ -1,195 +0,0 @@ - // Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -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: >k::Stack) { - - // create the bottom box for next and back buttons - let bottom_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .valign(gtk::Align::End) - .vexpand(true) - .build(); - - // Next and back button - let bottom_back_button = gtk::Button::builder() - .label("Back") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::Start) - .hexpand(true) - .build(); - let bottom_next_button = gtk::Button::builder() - .label("Next") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::End) - .hexpand(true) - .sensitive(false) - .build(); - - // Start Applying css classes - bottom_next_button.add_css_class("suggested-action"); - - // / bottom_box appends - //// Add the next and back buttons - bottom_box.append(&bottom_back_button); - bottom_box.append(&bottom_next_button); - - // the header box for the eula page - let eula_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the eula page - let eula_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the eula page - let eula_header_text = gtk::Label::builder() - .label("PikaOS User license Agreement") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - eula_header_text.add_css_class("header_sized_text"); - - // the header icon for the eula icon - let eula_header_icon = gtk::Image::builder() - .icon_name("error-correct") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // make eula selection box for choosing installation or live media - let eula_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // / eula_header_box appends - //// Add the eula page header text and icon - eula_header_box.append(&eula_header_text); - eula_header_box.append(&eula_header_icon); - - // / eula_main_box appends - //// Add the eula header to eula main box - eula_main_box.append(&eula_header_box); - //// Add the eula selection/page content box to eula main box - eula_main_box.append(&eula_selection_box); - - // text above eula selection box - let eula_selection_text = gtk::Label::builder() - .label("Please carefully read and make sure you consent to the following before installing PikaOS:") - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - eula_selection_text.add_css_class("medium_sized_text"); - - let eula_buffer = gtk::TextBuffer::builder() - .text("There are a few things to keep in mind: - 1 - You understand that this distribution is -NOT- to be considered an ‘Ubuntu Flavor’. - 2 - This is a hobby distribution, so we will try our best to provide formal support but it will -NOT- be guaranteed. - 3 - Although PikaOS might provide identical patches and user experience to the Nobara project, we are -NOT- directly a part of them so questions and bug reports should not be sent directly to them (they dont have to deal with it!) - 4 - While the installer is running DO NOT INTERRUPT IT! or you will end up with a corrupted system. - 5 - Try to use pikman instead of apt when using the terminal, it is much faster! - 6 - You understand the xone driver downloads needed binaries locally and does not directly package or distribute any copyrighted firmware or other related data. - 7 - Automatic partitioning will format all partitons on a drive, so if you want to dualboot make a separate EFI partition for PikaOS and use manual partitioning - 8 - In case you need the login info for this session: - - username: pikaos - - password: - MEANING: JUST PRESS ENTER") - .build(); - - let eula_selection_text_view = gtk::TextView::builder() - .hexpand(true) - .vexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .editable(false) - .buffer(&eula_buffer) - .build(); - - let eula_selection_text_scroll = gtk::ScrolledWindow::builder() - .height_request(350) - .child(&eula_selection_text_view) - .build(); - - let eula_accept_checkbutton = gtk::CheckButton::builder() - .label("I Agree and Accept the User license Agreement") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - // / eula_selection_box appends - //// add text and and entry to eula page selections - eula_selection_box.append(&eula_selection_text); - eula_selection_box.append(&eula_selection_text_scroll); - eula_selection_box.append(&eula_accept_checkbutton); - - // / eula_header_box appends - //// Add the eula page header text and icon - eula_header_box.append(&eula_header_text); - eula_header_box.append(&eula_header_icon); - - // / eula_main_box appends - //// Add the eula header to eula main box - eula_main_box.append(&eula_header_box); - //// Add the eula selection/page content box to eula main box - eula_main_box.append(&eula_selection_box); - - eula_main_box.append(&bottom_box); - - // / Content stack appends - //// Add the eula_main_box as page: eula_page, Give it nice title - content_stack.add_titled(&eula_main_box, Some("eula_page"), "EULA"); - - eula_accept_checkbutton.connect_toggled(clone!(@weak eula_accept_checkbutton, @weak bottom_next_button => move |_| { - if eula_accept_checkbutton.is_active() == true { - bottom_next_button.set_sensitive(true); - } else { - bottom_next_button.set_sensitive(false) - } - })); - - bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("timezone_page") - })); - bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("language_page") - })); - -} diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 5a8f649..8d5d834 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -1 +1,195 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +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: >k::Stack) { + + // create the bottom box for next and back buttons + let bottom_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .valign(gtk::Align::End) + .vexpand(true) + .build(); + + // Next and back button + let bottom_back_button = gtk::Button::builder() + .label("Back") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::Start) + .hexpand(true) + .build(); + let bottom_next_button = gtk::Button::builder() + .label("Next") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::End) + .hexpand(true) + .sensitive(false) + .build(); + + // Start Applying css classes + bottom_next_button.add_css_class("suggested-action"); + + // / bottom_box appends + //// Add the next and back buttons + bottom_box.append(&bottom_back_button); + bottom_box.append(&bottom_next_button); + + // the header box for the eula page + let eula_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the eula page + let eula_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the eula page + let eula_header_text = gtk::Label::builder() + .label("PikaOS User license Agreement") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + eula_header_text.add_css_class("header_sized_text"); + + // the header icon for the eula icon + let eula_header_icon = gtk::Image::builder() + .icon_name("error-correct") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // make eula selection box for choosing installation or live media + let eula_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // / eula_header_box appends + //// Add the eula page header text and icon + eula_header_box.append(&eula_header_text); + eula_header_box.append(&eula_header_icon); + + // / eula_main_box appends + //// Add the eula header to eula main box + eula_main_box.append(&eula_header_box); + //// Add the eula selection/page content box to eula main box + eula_main_box.append(&eula_selection_box); + + // text above eula selection box + let eula_selection_text = gtk::Label::builder() + .label("Please carefully read and make sure you consent to the following before installing PikaOS:") + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + eula_selection_text.add_css_class("medium_sized_text"); + + let eula_buffer = gtk::TextBuffer::builder() + .text("There are a few things to keep in mind: + 1 - You understand that this distribution is -NOT- to be considered an ‘Ubuntu Flavor’. + 2 - This is a hobby distribution, so we will try our best to provide formal support but it will -NOT- be guaranteed. + 3 - Although PikaOS might provide identical patches and user experience to the Nobara project, we are -NOT- directly a part of them so questions and bug reports should not be sent directly to them (they dont have to deal with it!) + 4 - While the installer is running DO NOT INTERRUPT IT! or you will end up with a corrupted system. + 5 - Try to use pikman instead of apt when using the terminal, it is much faster! + 6 - You understand the xone driver downloads needed binaries locally and does not directly package or distribute any copyrighted firmware or other related data. + 7 - Automatic partitioning will format all partitons on a drive, so if you want to dualboot make a separate EFI partition for PikaOS and use manual partitioning + 8 - In case you need the login info for this session: + - username: pikaos + - password: + MEANING: JUST PRESS ENTER") + .build(); + + let eula_selection_text_view = gtk::TextView::builder() + .hexpand(true) + .vexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .editable(false) + .buffer(&eula_buffer) + .build(); + + let eula_selection_text_scroll = gtk::ScrolledWindow::builder() + .height_request(350) + .child(&eula_selection_text_view) + .build(); + + let eula_accept_checkbutton = gtk::CheckButton::builder() + .label("I Agree and Accept the User license Agreement") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + // / eula_selection_box appends + //// add text and and entry to eula page selections + eula_selection_box.append(&eula_selection_text); + eula_selection_box.append(&eula_selection_text_scroll); + eula_selection_box.append(&eula_accept_checkbutton); + + // / eula_header_box appends + //// Add the eula page header text and icon + eula_header_box.append(&eula_header_text); + eula_header_box.append(&eula_header_icon); + + // / eula_main_box appends + //// Add the eula header to eula main box + eula_main_box.append(&eula_header_box); + //// Add the eula selection/page content box to eula main box + eula_main_box.append(&eula_selection_box); + + eula_main_box.append(&bottom_box); + + // / Content stack appends + //// Add the eula_main_box as page: eula_page, Give it nice title + content_stack.add_titled(&eula_main_box, Some("eula_page"), "EULA"); + + eula_accept_checkbutton.connect_toggled(clone!(@weak eula_accept_checkbutton, @weak bottom_next_button => move |_| { + if eula_accept_checkbutton.is_active() == true { + bottom_next_button.set_sensitive(true); + } else { + bottom_next_button.set_sensitive(false) + } + })); + + bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { + content_stack.set_visible_child_name("timezone_page") + })); + bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { + content_stack.set_visible_child_name("language_page") + })); + +} diff --git a/src/install_page/main.rs b/src/install_page/main.rs deleted file mode 100644 index 95ead21..0000000 --- a/src/install_page/main.rs +++ /dev/null @@ -1,597 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; -use vte::prelude::*; -use vte::*; - -use crate::done_page::main::done_page; - -use std::process::Command; -use pretty_bytes::converter::convert; - -use std::fs; -use std::path::Path; - -pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { - - // create the bottom box for next and back buttons - let bottom_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .valign(gtk::Align::End) - .vexpand(true) - .build(); - - // Next and back button - let bottom_back_button = gtk::Button::builder() - .label("Back") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::Start) - .hexpand(true) - .build(); - - // / bottom_box appends - //// Add the next and back buttons - bottom_box.append(&bottom_back_button); - - let install_nested_stack = gtk::Stack::builder() - .transition_type(StackTransitionType::SlideLeftRight) - .build(); - - let install_confirm_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the install page - let install_confirm_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the install page - let install_confirm_header_text = gtk::Label::builder() - .label("Sit back, Relax, and watch the show.") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - install_confirm_header_text.add_css_class("header_sized_text"); - - // the header icon for the install icon - let install_confirm_header_icon = gtk::Spinner::builder() - .halign(gtk::Align::Start) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - install_confirm_header_icon.start(); - - // make install selection box for choosing installation or live media - let install_confirm_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .halign(gtk::Align::Fill) - .valign(gtk::Align::Center) - .vexpand(true) - .hexpand(true) - .build(); - - let install_confirm_details_boxed_list = gtk::ListBox::builder() - .margin_top(15) - .margin_bottom(15) - .margin_start(256) - .margin_end(256) - .halign(gtk::Align::Fill) - .valign(gtk::Align::Center) - .hexpand(true) - .build(); - install_confirm_details_boxed_list.add_css_class("boxed-list"); - - let install_confirm_detail_language = adw::ActionRow::builder() - .title("Language:") - .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-lang.txt").expect("Unable to read file")) - .build(); - install_confirm_detail_language.add_css_class("property"); - - let install_confirm_detail_timezone = adw::ActionRow::builder() - .title("Time zone:") - .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-timezone.txt").expect("Unable to read file")) - .build(); - install_confirm_detail_timezone.add_css_class("property"); - - let install_confirm_detail_keyboard = adw::ActionRow::builder() - .title("Keyboard layout:") - .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-keyboard.txt").expect("Unable to read file")) - .build(); - install_confirm_detail_keyboard.add_css_class("property"); - - let install_confirm_detail_target = adw::ActionRow::builder() - .title("Install Target:") - .build(); - - if Path::new("/tmp/pika-installer-gtk4-target-manual.txt").exists() { - install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-manual.txt").expect("Unable to read file")); - } else { - install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file")); - } - install_confirm_detail_target.add_css_class("property"); - - if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { - let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file"); - let target_size_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("get_block_size") - .arg(target_block_device) - .output() - .expect("failed to execute process"); - let target_size = String::from_utf8(target_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); - let mut target_p3_size = 0.0; - if (target_size * 40.0) / 100.0 >= 150000000000.0 { - target_p3_size = 150000000000.0 ; - } else if (target_size * 40.0) / 100.0 <= 36507222016.0 { - target_p3_size = 36507222016.0 ; - } else { - target_p3_size = (target_size * 40.0) / 100.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; - 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(); - if target_block_device.contains("nvme") { - p1_row_text = "512 MB ".to_owned() + target_block_device + "p1" + " as fat32" + " on /boot/efi"; - 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) + " " + target_block_device + "p3" + " as btrfs" + " on /"; - p4_row_text = pretty_bytes::converter::convert(target_p4_size) + " " + target_block_device + "p4" + " as btrfs" + " on /home"; - } else { - 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) + " " + target_block_device + "3" + " as btrfs" + " on /"; - 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(); - // / 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); - install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); - install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); - install_confirm_details_boxed_list.append(&install_confirm_detail_target); - install_confirm_details_boxed_list.append(&install_confirm_p1); - install_confirm_details_boxed_list.append(&install_confirm_p2); - install_confirm_details_boxed_list.append(&install_confirm_p3); - install_confirm_details_boxed_list.append(&install_confirm_p4); - } else { - // / 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); - install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); - install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); - install_confirm_details_boxed_list.append(&install_confirm_detail_target); - } - - let install_confirm_button = gtk::Button::builder() - .label("Confirm & Install PikaOS") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .build(); - install_confirm_button.add_css_class("destructive-action"); - - // / install_confirm_header_box appends - //// Add the install page header text and icon - install_confirm_header_box.append(&install_confirm_header_text); - install_confirm_header_box.append(&install_confirm_header_icon); - - // / install_confirm_box appends - //// Add the install header to install main box - install_confirm_box.append(&install_confirm_header_box); - //// Add the install selection/page content box to install main box - install_confirm_box.append(&install_confirm_selection_box); - - // Start Appending widgets to boxes - - // - install_confirm_selection_box.append(&install_confirm_details_boxed_list); - install_confirm_selection_box.append(&install_confirm_button); - - // / install_confirm_header_box appends - //// Add the install page header text and icon - install_confirm_header_box.append(&install_confirm_header_text); - install_confirm_header_box.append(&install_confirm_header_icon); - - // / install_confirm_box appends - //// Add the install header to install main box - install_confirm_box.append(&install_confirm_header_box); - //// Add the install selection/page content box to install main box - install_confirm_box.append(&install_confirm_selection_box); - - install_main_box.append(&install_nested_stack); - - install_confirm_box.append(&bottom_box); - - /// - - let install_progress_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let install_progress_log_stack = gtk::Stack::builder() - .transition_type(StackTransitionType::SlideUpDown) - .build(); - - let install_progress_log_terminal = vte::Terminal::builder() - .vexpand(true) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .input_enabled(false) - .build(); - - let placeholder_icon = gtk::Image::builder() - .icon_name("debian-swirl") - .halign(gtk::Align::Center) - .valign(gtk::Align::Center) - .hexpand(true) - .vexpand(true) - .pixel_size(512) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let progress_bar_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .margin_start(15) - .margin_end(15) - .build(); - - let install_progress_bar = gtk::ProgressBar::builder() - .hexpand(true) - .margin_start(15) - .margin_end(15) - .margin_top(15) - .margin_bottom(15) - .show_text(true) - .build(); - - let progress_log_button_content = adw::ButtonContent::builder() - .label("View Logs") - .icon_name("terminal") - .build(); - - let progress_log_button = gtk::Button::builder() - .child(&progress_log_button_content) - .margin_start(15) - .margin_end(15) - .margin_top(15) - .margin_bottom(15) - .build(); - - progress_bar_box.append(&install_progress_bar); - progress_bar_box.append(&progress_log_button); - - install_progress_log_stack.add_titled(&placeholder_icon, Some("slideshow_page"), "slideshow_page"); - install_progress_log_stack.add_titled(&install_progress_log_terminal, Some("terminal_log_page"), "terminal_log_page"); - - install_progress_box.append(&install_progress_log_stack); - install_progress_box.append(&progress_bar_box); - - install_nested_stack.add_titled(&install_confirm_box, Some("confirm_page"), "confirm_page"); - install_nested_stack.add_titled(&install_progress_box, Some("progress_page"), "progress_page"); - - // - - // - - install_confirm_button.connect_clicked(clone!(@weak install_nested_stack, @weak install_progress_log_terminal, @weak install_progress_bar, @weak done_main_box, @weak content_stack, @weak window => move |_| { - install_nested_stack.set_visible_child_name("progress_page"); - begin_install(&install_progress_log_terminal, &install_progress_bar, &done_main_box, &content_stack, &window); - })); - - progress_log_button.connect_clicked(clone!(@weak install_progress_log_stack => move |_| { - if install_progress_log_stack.visible_child_name() == Some(GString::from_string_unchecked("slideshow_page".into())) { - install_progress_log_stack.set_visible_child_name("terminal_log_page"); - } else { - install_progress_log_stack.set_visible_child_name("slideshow_page"); - } - })); - - bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak install_main_box, @weak install_nested_stack => move |_| { - content_stack.set_visible_child_name("partitioning_page"); - install_main_box.remove(&install_nested_stack) - })); -} - -fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress_bar: >k::ProgressBar, done_main_box: >k::Box, content_stack: >k::Stack, window: &adw::ApplicationWindow) { - // SPAWN TERMINAL WITH PIKAINSTALL PROCESS - install_progress_log_terminal.spawn_async( - PtyFlags::DEFAULT, - Some(""), - &["/usr/lib/pika/pika-installer-gtk4/scripts/begin-install.sh"], - &[], - SpawnFlags::DEFAULT, - || {}, - -1, - None::<&gio::Cancellable>, - move |result| { - match result { - Ok(_) => { eprintln!("could not spawn terminal")} - Err(err) => { - eprintln!("could not spawn terminal: {}", err); - } - } - }, - ); - // wait till /tmp/pika-installer-gtk4-status-parting.txt to change progressbar - let (parting_status_sender, parting_status_receiver) = async_channel::unbounded(); - let parting_status_sender = parting_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let parting_status = true; - while parting_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-parting.txt").exists() == true { - parting_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let parting_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - parting_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(parting_status_state) = parting_status_receiver.recv().await { - - if parting_status_state == true { - println!("Installation status: Parting"); - install_progress_bar.set_fraction(0.20); - install_progress_bar.set_text(Some("Partitioning The Disk Target.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-image.txt to change progressbar - let (image_status_sender, image_status_receiver) = async_channel::unbounded(); - let image_status_sender = image_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let image_status = true; - while image_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-image.txt").exists() == true { - image_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let image_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - image_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(image_status_state) = image_status_receiver.recv().await { - - if image_status_state == true { - println!("Installation status: Imaging"); - install_progress_bar.set_fraction(0.60); - install_progress_bar.set_text(Some("Writing image to target.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-flag1.txt to change progressbar - let (flag1_status_sender, flag1_status_receiver) = async_channel::unbounded(); - let flag1_status_sender = flag1_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let flag1_status = true; - while flag1_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-flag1.txt").exists() == true { - flag1_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let flag1_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - flag1_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(flag1_status_state) = flag1_status_receiver.recv().await { - - if flag1_status_state == true { - println!("Installation status: Flag1"); - install_progress_bar.set_fraction(0.65); - install_progress_bar.set_text(Some("Enabling bls_boot flag on /boot.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-flag2.txt to change progressbar - let (flag2_status_sender, flag2_status_receiver) = async_channel::unbounded(); - let flag2_status_sender = flag2_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let flag2_status = true; - while flag2_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-flag2.txt").exists() == true { - flag2_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let flag2_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - flag2_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(flag2_status_state) = flag2_status_receiver.recv().await { - - if flag2_status_state == true { - println!("Installation status: Flag2"); - install_progress_bar.set_fraction(0.70); - install_progress_bar.set_text(Some("Enabling efi flag on /boot/efi.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-crypt.txt to change progressbar - let (crypt_status_sender, crypt_status_receiver) = async_channel::unbounded(); - let crypt_status_sender = crypt_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let crypt_status = true; - while crypt_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-crypt.txt").exists() == true { - crypt_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let crypt_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - crypt_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(crypt_status_state) = crypt_status_receiver.recv().await { - - if crypt_status_state == true { - println!("Installation status: Crypttab"); - install_progress_bar.set_fraction(0.75); - install_progress_bar.set_text(Some("Setting up encryption crypttab.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-lang.txt to change progressbar - let (lang_status_sender, lang_status_receiver) = async_channel::unbounded(); - let lang_status_sender = lang_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let lang_status = true; - while lang_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-lang.txt").exists() == true { - lang_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let lang_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - lang_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(lang_status_state) = lang_status_receiver.recv().await { - - if lang_status_state == true { - println!("Installation status: Language"); - install_progress_bar.set_fraction(0.80); - install_progress_bar.set_text(Some("Setting Up Language and Keyboard.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-boot.txt to change progressbar - let (boot_status_sender, boot_status_receiver) = async_channel::unbounded(); - let boot_status_sender = boot_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let boot_status = true; - while boot_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-boot.txt").exists() == true { - boot_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let boot_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - boot_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(boot_status_state) = boot_status_receiver.recv().await { - - if boot_status_state == true { - println!("Installation status: Bootloader"); - install_progress_bar.set_fraction(0.85); - install_progress_bar.set_text(Some("Configuring bootloader.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-status-post.txt to change progressbar - let (post_status_sender, post_status_receiver) = async_channel::unbounded(); - let post_status_sender = post_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let post_status = true; - while post_status == true { - if Path::new("/tmp/pika-installer-gtk4-status-post.txt").exists() == true { - post_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let post_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - post_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { - while let Ok(post_status_state) = post_status_receiver.recv().await { - - if post_status_state == true { - println!("Installation status: Post Install"); - install_progress_bar.set_fraction(0.90); - install_progress_bar.set_text(Some("Running post installation script.")); - } - } - })); - // wait till /tmp/pika-installer-gtk4-successful.txt to change progressbar - let (done_status_sender, done_status_receiver) = async_channel::unbounded(); - let done_status_sender = done_status_sender.clone(); - // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - let done_status = true; - while done_status == true { - if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() == true || Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() == true { - done_status_sender - .send_blocking(true) - .expect("The channel needs to be open."); - break - } - } - }); - let done_status_main_context = MainContext::default(); - // The main loop executes the asynchronous block - done_status_main_context.spawn_local(clone!(@weak done_main_box, @weak content_stack, @weak window => async move { - 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); - content_stack.set_visible_child_name("done_page"); - } - } - })); -} \ No newline at end of file diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 5a8f649..c865e38 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -1 +1,597 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; +use vte::prelude::*; +use vte::*; + +use crate::done_page::done_page; + +use std::process::Command; +use pretty_bytes::converter::convert; + +use std::fs; +use std::path::Path; + +pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { + + // create the bottom box for next and back buttons + let bottom_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .valign(gtk::Align::End) + .vexpand(true) + .build(); + + // Next and back button + let bottom_back_button = gtk::Button::builder() + .label("Back") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::Start) + .hexpand(true) + .build(); + + // / bottom_box appends + //// Add the next and back buttons + bottom_box.append(&bottom_back_button); + + let install_nested_stack = gtk::Stack::builder() + .transition_type(StackTransitionType::SlideLeftRight) + .build(); + + let install_confirm_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the install page + let install_confirm_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the install page + let install_confirm_header_text = gtk::Label::builder() + .label("Sit back, Relax, and watch the show.") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + install_confirm_header_text.add_css_class("header_sized_text"); + + // the header icon for the install icon + let install_confirm_header_icon = gtk::Spinner::builder() + .halign(gtk::Align::Start) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + install_confirm_header_icon.start(); + + // make install selection box for choosing installation or live media + let install_confirm_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .halign(gtk::Align::Fill) + .valign(gtk::Align::Center) + .vexpand(true) + .hexpand(true) + .build(); + + let install_confirm_details_boxed_list = gtk::ListBox::builder() + .margin_top(15) + .margin_bottom(15) + .margin_start(256) + .margin_end(256) + .halign(gtk::Align::Fill) + .valign(gtk::Align::Center) + .hexpand(true) + .build(); + install_confirm_details_boxed_list.add_css_class("boxed-list"); + + let install_confirm_detail_language = adw::ActionRow::builder() + .title("Language:") + .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-lang.txt").expect("Unable to read file")) + .build(); + install_confirm_detail_language.add_css_class("property"); + + let install_confirm_detail_timezone = adw::ActionRow::builder() + .title("Time zone:") + .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-timezone.txt").expect("Unable to read file")) + .build(); + install_confirm_detail_timezone.add_css_class("property"); + + let install_confirm_detail_keyboard = adw::ActionRow::builder() + .title("Keyboard layout:") + .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-keyboard.txt").expect("Unable to read file")) + .build(); + install_confirm_detail_keyboard.add_css_class("property"); + + let install_confirm_detail_target = adw::ActionRow::builder() + .title("Install Target:") + .build(); + + if Path::new("/tmp/pika-installer-gtk4-target-manual.txt").exists() { + install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-manual.txt").expect("Unable to read file")); + } else { + install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file")); + } + install_confirm_detail_target.add_css_class("property"); + + if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { + let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file"); + let target_size_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_block_size") + .arg(target_block_device) + .output() + .expect("failed to execute process"); + let target_size = String::from_utf8(target_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let mut target_p3_size = 0.0; + if (target_size * 40.0) / 100.0 >= 150000000000.0 { + target_p3_size = 150000000000.0 ; + } else if (target_size * 40.0) / 100.0 <= 36507222016.0 { + target_p3_size = 36507222016.0 ; + } else { + target_p3_size = (target_size * 40.0) / 100.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; + 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(); + if target_block_device.contains("nvme") { + p1_row_text = "512 MB ".to_owned() + target_block_device + "p1" + " as fat32" + " on /boot/efi"; + 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) + " " + target_block_device + "p3" + " as btrfs" + " on /"; + p4_row_text = pretty_bytes::converter::convert(target_p4_size) + " " + target_block_device + "p4" + " as btrfs" + " on /home"; + } else { + 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) + " " + target_block_device + "3" + " as btrfs" + " on /"; + 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(); + // / 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); + install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); + install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); + install_confirm_details_boxed_list.append(&install_confirm_detail_target); + install_confirm_details_boxed_list.append(&install_confirm_p1); + install_confirm_details_boxed_list.append(&install_confirm_p2); + install_confirm_details_boxed_list.append(&install_confirm_p3); + install_confirm_details_boxed_list.append(&install_confirm_p4); + } else { + // / 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); + install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); + install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); + install_confirm_details_boxed_list.append(&install_confirm_detail_target); + } + + let install_confirm_button = gtk::Button::builder() + .label("Confirm & Install PikaOS") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .build(); + install_confirm_button.add_css_class("destructive-action"); + + // / install_confirm_header_box appends + //// Add the install page header text and icon + install_confirm_header_box.append(&install_confirm_header_text); + install_confirm_header_box.append(&install_confirm_header_icon); + + // / install_confirm_box appends + //// Add the install header to install main box + install_confirm_box.append(&install_confirm_header_box); + //// Add the install selection/page content box to install main box + install_confirm_box.append(&install_confirm_selection_box); + + // Start Appending widgets to boxes + + // + install_confirm_selection_box.append(&install_confirm_details_boxed_list); + install_confirm_selection_box.append(&install_confirm_button); + + // / install_confirm_header_box appends + //// Add the install page header text and icon + install_confirm_header_box.append(&install_confirm_header_text); + install_confirm_header_box.append(&install_confirm_header_icon); + + // / install_confirm_box appends + //// Add the install header to install main box + install_confirm_box.append(&install_confirm_header_box); + //// Add the install selection/page content box to install main box + install_confirm_box.append(&install_confirm_selection_box); + + install_main_box.append(&install_nested_stack); + + install_confirm_box.append(&bottom_box); + + /// + + let install_progress_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let install_progress_log_stack = gtk::Stack::builder() + .transition_type(StackTransitionType::SlideUpDown) + .build(); + + let install_progress_log_terminal = vte::Terminal::builder() + .vexpand(true) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .input_enabled(false) + .build(); + + let placeholder_icon = gtk::Image::builder() + .icon_name("debian-swirl") + .halign(gtk::Align::Center) + .valign(gtk::Align::Center) + .hexpand(true) + .vexpand(true) + .pixel_size(512) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let progress_bar_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .margin_start(15) + .margin_end(15) + .build(); + + let install_progress_bar = gtk::ProgressBar::builder() + .hexpand(true) + .margin_start(15) + .margin_end(15) + .margin_top(15) + .margin_bottom(15) + .show_text(true) + .build(); + + let progress_log_button_content = adw::ButtonContent::builder() + .label("View Logs") + .icon_name("terminal") + .build(); + + let progress_log_button = gtk::Button::builder() + .child(&progress_log_button_content) + .margin_start(15) + .margin_end(15) + .margin_top(15) + .margin_bottom(15) + .build(); + + progress_bar_box.append(&install_progress_bar); + progress_bar_box.append(&progress_log_button); + + install_progress_log_stack.add_titled(&placeholder_icon, Some("slideshow_page"), "slideshow_page"); + install_progress_log_stack.add_titled(&install_progress_log_terminal, Some("terminal_log_page"), "terminal_log_page"); + + install_progress_box.append(&install_progress_log_stack); + install_progress_box.append(&progress_bar_box); + + install_nested_stack.add_titled(&install_confirm_box, Some("confirm_page"), "confirm_page"); + install_nested_stack.add_titled(&install_progress_box, Some("progress_page"), "progress_page"); + + // + + // + + install_confirm_button.connect_clicked(clone!(@weak install_nested_stack, @weak install_progress_log_terminal, @weak install_progress_bar, @weak done_main_box, @weak content_stack, @weak window => move |_| { + install_nested_stack.set_visible_child_name("progress_page"); + begin_install(&install_progress_log_terminal, &install_progress_bar, &done_main_box, &content_stack, &window); + })); + + progress_log_button.connect_clicked(clone!(@weak install_progress_log_stack => move |_| { + if install_progress_log_stack.visible_child_name() == Some(GString::from_string_unchecked("slideshow_page".into())) { + install_progress_log_stack.set_visible_child_name("terminal_log_page"); + } else { + install_progress_log_stack.set_visible_child_name("slideshow_page"); + } + })); + + bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak install_main_box, @weak install_nested_stack => move |_| { + content_stack.set_visible_child_name("partitioning_page"); + install_main_box.remove(&install_nested_stack) + })); +} + +fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress_bar: >k::ProgressBar, done_main_box: >k::Box, content_stack: >k::Stack, window: &adw::ApplicationWindow) { + // SPAWN TERMINAL WITH PIKAINSTALL PROCESS + install_progress_log_terminal.spawn_async( + PtyFlags::DEFAULT, + Some(""), + &["/usr/lib/pika/pika-installer-gtk4/scripts/begin-install.sh"], + &[], + SpawnFlags::DEFAULT, + || {}, + -1, + None::<&gio::Cancellable>, + move |result| { + match result { + Ok(_) => { eprintln!("could not spawn terminal")} + Err(err) => { + eprintln!("could not spawn terminal: {}", err); + } + } + }, + ); + // wait till /tmp/pika-installer-gtk4-status-parting.txt to change progressbar + let (parting_status_sender, parting_status_receiver) = async_channel::unbounded(); + let parting_status_sender = parting_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let parting_status = true; + while parting_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-parting.txt").exists() == true { + parting_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let parting_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + parting_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(parting_status_state) = parting_status_receiver.recv().await { + + if parting_status_state == true { + println!("Installation status: Parting"); + install_progress_bar.set_fraction(0.20); + install_progress_bar.set_text(Some("Partitioning The Disk Target.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-image.txt to change progressbar + let (image_status_sender, image_status_receiver) = async_channel::unbounded(); + let image_status_sender = image_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let image_status = true; + while image_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-image.txt").exists() == true { + image_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let image_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + image_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(image_status_state) = image_status_receiver.recv().await { + + if image_status_state == true { + println!("Installation status: Imaging"); + install_progress_bar.set_fraction(0.60); + install_progress_bar.set_text(Some("Writing image to target.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-flag1.txt to change progressbar + let (flag1_status_sender, flag1_status_receiver) = async_channel::unbounded(); + let flag1_status_sender = flag1_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let flag1_status = true; + while flag1_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-flag1.txt").exists() == true { + flag1_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let flag1_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + flag1_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(flag1_status_state) = flag1_status_receiver.recv().await { + + if flag1_status_state == true { + println!("Installation status: Flag1"); + install_progress_bar.set_fraction(0.65); + install_progress_bar.set_text(Some("Enabling bls_boot flag on /boot.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-flag2.txt to change progressbar + let (flag2_status_sender, flag2_status_receiver) = async_channel::unbounded(); + let flag2_status_sender = flag2_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let flag2_status = true; + while flag2_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-flag2.txt").exists() == true { + flag2_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let flag2_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + flag2_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(flag2_status_state) = flag2_status_receiver.recv().await { + + if flag2_status_state == true { + println!("Installation status: Flag2"); + install_progress_bar.set_fraction(0.70); + install_progress_bar.set_text(Some("Enabling efi flag on /boot/efi.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-crypt.txt to change progressbar + let (crypt_status_sender, crypt_status_receiver) = async_channel::unbounded(); + let crypt_status_sender = crypt_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let crypt_status = true; + while crypt_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-crypt.txt").exists() == true { + crypt_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let crypt_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + crypt_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(crypt_status_state) = crypt_status_receiver.recv().await { + + if crypt_status_state == true { + println!("Installation status: Crypttab"); + install_progress_bar.set_fraction(0.75); + install_progress_bar.set_text(Some("Setting up encryption crypttab.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-lang.txt to change progressbar + let (lang_status_sender, lang_status_receiver) = async_channel::unbounded(); + let lang_status_sender = lang_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let lang_status = true; + while lang_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-lang.txt").exists() == true { + lang_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let lang_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + lang_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(lang_status_state) = lang_status_receiver.recv().await { + + if lang_status_state == true { + println!("Installation status: Language"); + install_progress_bar.set_fraction(0.80); + install_progress_bar.set_text(Some("Setting Up Language and Keyboard.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-boot.txt to change progressbar + let (boot_status_sender, boot_status_receiver) = async_channel::unbounded(); + let boot_status_sender = boot_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let boot_status = true; + while boot_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-boot.txt").exists() == true { + boot_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let boot_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + boot_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(boot_status_state) = boot_status_receiver.recv().await { + + if boot_status_state == true { + println!("Installation status: Bootloader"); + install_progress_bar.set_fraction(0.85); + install_progress_bar.set_text(Some("Configuring bootloader.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-status-post.txt to change progressbar + let (post_status_sender, post_status_receiver) = async_channel::unbounded(); + let post_status_sender = post_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let post_status = true; + while post_status == true { + if Path::new("/tmp/pika-installer-gtk4-status-post.txt").exists() == true { + post_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let post_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + post_status_main_context.spawn_local(clone!(@weak install_progress_bar => async move { + while let Ok(post_status_state) = post_status_receiver.recv().await { + + if post_status_state == true { + println!("Installation status: Post Install"); + install_progress_bar.set_fraction(0.90); + install_progress_bar.set_text(Some("Running post installation script.")); + } + } + })); + // wait till /tmp/pika-installer-gtk4-successful.txt to change progressbar + let (done_status_sender, done_status_receiver) = async_channel::unbounded(); + let done_status_sender = done_status_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + let done_status = true; + while done_status == true { + if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() == true || Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() == true { + done_status_sender + .send_blocking(true) + .expect("The channel needs to be open."); + break + } + } + }); + let done_status_main_context = MainContext::default(); + // The main loop executes the asynchronous block + done_status_main_context.spawn_local(clone!(@weak done_main_box, @weak content_stack, @weak window => async move { + 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); + content_stack.set_visible_child_name("done_page"); + } + } + })); +} \ No newline at end of file diff --git a/src/keyboard_page/main.rs b/src/keyboard_page/main.rs deleted file mode 100644 index 5d9a403..0000000 --- a/src/keyboard_page/main.rs +++ /dev/null @@ -1,252 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use std::io::BufRead; -use std::io::BufReader; -use std::process::Command; -use std::process::Stdio; -use std::time::Instant; -use std::str; - -use std::fs; -use std::path::Path; - -pub fn keyboard_page(content_stack: >k::Stack) { - - // create the bottom box for next and back buttons - let bottom_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .valign(gtk::Align::End) - .vexpand(true) - .build(); - - // Next and back button - let bottom_back_button = gtk::Button::builder() - .label("Back") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::Start) - .hexpand(true) - .build(); - let bottom_next_button = gtk::Button::builder() - .label("Next") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::End) - .hexpand(true) - .sensitive(false) - .build(); - - // Start Applying css classes - bottom_next_button.add_css_class("suggested-action"); - - // / bottom_box appends - //// Add the next and back buttons - bottom_box.append(&bottom_back_button); - bottom_box.append(&bottom_next_button); - - // the header box for the keyboard page - let keyboard_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the keyboard page - let keyboard_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the keyboard page - let keyboard_header_text = gtk::Label::builder() - .label("Select a keyboard") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - keyboard_header_text.add_css_class("header_sized_text"); - - // the header icon for the keyboard icon - let keyboard_header_icon = gtk::Image::builder() - .icon_name("keyboard") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // make keyboard selection box for choosing installation or live media - let keyboard_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // / keyboard_header_box appends - //// Add the keyboard page header text and icon - keyboard_header_box.append(&keyboard_header_text); - keyboard_header_box.append(&keyboard_header_icon); - - // / keyboard_main_box appends - //// Add the keyboard header to keyboard main box - keyboard_main_box.append(&keyboard_header_box); - //// Add the keyboard selection/page content box to keyboard main box - keyboard_main_box.append(&keyboard_selection_box); - - // text above keyboard selection box - let keyboard_selection_text = gtk::Label::builder() - .label("Please select a Keyboard layout for the system to use") - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - keyboard_selection_text.add_css_class("medium_sized_text"); - - let keyboard_selection_expander_row = adw::ExpanderRow::builder() - .title("No Keyboard Layout selected") - .build(); - - let null_checkbutton = gtk::CheckButton::builder() - .label("No Keyboard Layout selected") - .build(); - - let keyboard_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); - - let keyboard_selection_expander_row_viewport_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let keyboard_selection_expander_row_viewport_listbox = gtk::ListBox::builder() - .selection_mode(SelectionMode::None) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - keyboard_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); - keyboard_selection_expander_row_viewport_listbox.append(&keyboard_selection_expander_row); - - keyboard_selection_expander_row_viewport.set_child(Some(&keyboard_selection_expander_row_viewport_box)); - - keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport); - - let current_keyboard_cli = Command::new("localectl") - .arg("status") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - let current_keyboard_grep = Command::new("grep") - .arg("X11 Layout") - .stdin(Stdio::from(current_keyboard_cli.stdout.unwrap())) // Pipe through. - .stdout(Stdio::piped()) - .spawn() - .unwrap(); - let current_keyboard_cut = Command::new("cut") - .arg("-d:") - .arg("-f2") - .stdin(Stdio::from(current_keyboard_grep.stdout.unwrap())) - .stdout(Stdio::piped()) - .spawn() - .unwrap(); - - let current_keyboard_output = current_keyboard_cut.wait_with_output().unwrap(); - let current_keyboard = str::from_utf8(¤t_keyboard_output.stdout).unwrap().trim(); - - let keyboard_layout_cli = Command::new("localectl") - .arg("list-x11-keymap-layouts") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - - let keyboard_layout_stdout = keyboard_layout_cli.stdout.expect("could not get stdout"); - let keyboard_layout_reader = BufReader::new(keyboard_layout_stdout); - - let keyboard_data_buffer = gtk::TextBuffer::builder() - .build(); - - for keyboard_layout in keyboard_layout_reader.lines() { - let keyboard_layout = keyboard_layout.unwrap(); - let keyboard_layout_clone = keyboard_layout.clone(); - let keyboard_layout_checkbutton = gtk::CheckButton::builder() - .label(keyboard_layout.clone()) - .build(); - keyboard_layout_checkbutton.set_group(Some(&null_checkbutton)); - keyboard_selection_expander_row_viewport_box.append(&keyboard_layout_checkbutton); - keyboard_layout_checkbutton.connect_toggled(clone!(@weak keyboard_layout_checkbutton, @weak keyboard_selection_expander_row, @weak bottom_next_button, @weak keyboard_data_buffer => move |_| { - if keyboard_layout_checkbutton.is_active() == true { - keyboard_selection_expander_row.set_title(&keyboard_layout); - bottom_next_button.set_sensitive(true); - keyboard_data_buffer.set_text(&keyboard_layout); - Command::new("setxkbmap") - .arg("-layout") - .arg(keyboard_layout.clone()) - .spawn() - .expect("keyboard failed to start"); - } - })); - if current_keyboard.contains(&(keyboard_layout_clone)) { - keyboard_layout_checkbutton.set_active(true); - } - } - - // / keyboard_selection_box appends - //// add text and and entry to keyboard page selections - keyboard_selection_box.append(&keyboard_selection_text); - keyboard_selection_box.append(&keyboard_selection_expander_row_viewport_listbox); - - // / keyboard_header_box appends - //// Add the keyboard page header text and icon - keyboard_header_box.append(&keyboard_header_text); - keyboard_header_box.append(&keyboard_header_icon); - - // / keyboard_main_box appends - //// Add the keyboard header to keyboard main box - keyboard_main_box.append(&keyboard_header_box); - //// Add the keyboard selection/page content box to keyboard main box - keyboard_main_box.append(&keyboard_selection_box); - - //// Add the keyboard selection/page content box to keyboard main box - keyboard_main_box.append(>k::Entry::builder().hexpand(true).valign(Align::End).vexpand(false).margin_bottom(15).margin_top(15).margin_end(15).margin_start(15).placeholder_text("Test Your Keyboard here!").build()); - - keyboard_main_box.append(&bottom_box); - - // / Content stack appends - //// Add the keyboard_main_box as page: keyboard_page, Give it nice title - content_stack.add_titled(&keyboard_main_box, Some("keyboard_page"), "Keyboard"); - - let keyboard_data_buffer_clone = keyboard_data_buffer.clone(); - - bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - if Path::new("/tmp/pika-installer-gtk4-keyboard.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-keyboard.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-keyboard.txt"); - } - fs::write("/tmp/pika-installer-gtk4-keyboard.txt", keyboard_data_buffer_clone.text(&keyboard_data_buffer_clone.bounds().0, &keyboard_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - content_stack.set_visible_child_name("partitioning_page") - })); - - bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("timezone_page") - })); - -} diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 5a8f649..0bb283b 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -1 +1,252 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::str; + +use std::fs; +use std::path::Path; + +pub fn keyboard_page(content_stack: >k::Stack) { + + // create the bottom box for next and back buttons + let bottom_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .valign(gtk::Align::End) + .vexpand(true) + .build(); + + // Next and back button + let bottom_back_button = gtk::Button::builder() + .label("Back") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::Start) + .hexpand(true) + .build(); + let bottom_next_button = gtk::Button::builder() + .label("Next") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::End) + .hexpand(true) + .sensitive(false) + .build(); + + // Start Applying css classes + bottom_next_button.add_css_class("suggested-action"); + + // / bottom_box appends + //// Add the next and back buttons + bottom_box.append(&bottom_back_button); + bottom_box.append(&bottom_next_button); + + // the header box for the keyboard page + let keyboard_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the keyboard page + let keyboard_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the keyboard page + let keyboard_header_text = gtk::Label::builder() + .label("Select a keyboard") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + keyboard_header_text.add_css_class("header_sized_text"); + + // the header icon for the keyboard icon + let keyboard_header_icon = gtk::Image::builder() + .icon_name("keyboard") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // make keyboard selection box for choosing installation or live media + let keyboard_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // / keyboard_header_box appends + //// Add the keyboard page header text and icon + keyboard_header_box.append(&keyboard_header_text); + keyboard_header_box.append(&keyboard_header_icon); + + // / keyboard_main_box appends + //// Add the keyboard header to keyboard main box + keyboard_main_box.append(&keyboard_header_box); + //// Add the keyboard selection/page content box to keyboard main box + keyboard_main_box.append(&keyboard_selection_box); + + // text above keyboard selection box + let keyboard_selection_text = gtk::Label::builder() + .label("Please select a Keyboard layout for the system to use") + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + keyboard_selection_text.add_css_class("medium_sized_text"); + + let keyboard_selection_expander_row = adw::ExpanderRow::builder() + .title("No Keyboard Layout selected") + .build(); + + let null_checkbutton = gtk::CheckButton::builder() + .label("No Keyboard Layout selected") + .build(); + + let keyboard_selection_expander_row_viewport = gtk::ScrolledWindow::builder() + .height_request(200) + .build(); + + let keyboard_selection_expander_row_viewport_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let keyboard_selection_expander_row_viewport_listbox = gtk::ListBox::builder() + .selection_mode(SelectionMode::None) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + keyboard_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); + keyboard_selection_expander_row_viewport_listbox.append(&keyboard_selection_expander_row); + + keyboard_selection_expander_row_viewport.set_child(Some(&keyboard_selection_expander_row_viewport_box)); + + keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport); + + let current_keyboard_cli = Command::new("localectl") + .arg("status") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + let current_keyboard_grep = Command::new("grep") + .arg("X11 Layout") + .stdin(Stdio::from(current_keyboard_cli.stdout.unwrap())) // Pipe through. + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + let current_keyboard_cut = Command::new("cut") + .arg("-d:") + .arg("-f2") + .stdin(Stdio::from(current_keyboard_grep.stdout.unwrap())) + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + + let current_keyboard_output = current_keyboard_cut.wait_with_output().unwrap(); + let current_keyboard = str::from_utf8(¤t_keyboard_output.stdout).unwrap().trim(); + + let keyboard_layout_cli = Command::new("localectl") + .arg("list-x11-keymap-layouts") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + + let keyboard_layout_stdout = keyboard_layout_cli.stdout.expect("could not get stdout"); + let keyboard_layout_reader = BufReader::new(keyboard_layout_stdout); + + let keyboard_data_buffer = gtk::TextBuffer::builder() + .build(); + + for keyboard_layout in keyboard_layout_reader.lines() { + let keyboard_layout = keyboard_layout.unwrap(); + let keyboard_layout_clone = keyboard_layout.clone(); + let keyboard_layout_checkbutton = gtk::CheckButton::builder() + .label(keyboard_layout.clone()) + .build(); + keyboard_layout_checkbutton.set_group(Some(&null_checkbutton)); + keyboard_selection_expander_row_viewport_box.append(&keyboard_layout_checkbutton); + keyboard_layout_checkbutton.connect_toggled(clone!(@weak keyboard_layout_checkbutton, @weak keyboard_selection_expander_row, @weak bottom_next_button, @weak keyboard_data_buffer => move |_| { + if keyboard_layout_checkbutton.is_active() == true { + keyboard_selection_expander_row.set_title(&keyboard_layout); + bottom_next_button.set_sensitive(true); + keyboard_data_buffer.set_text(&keyboard_layout); + Command::new("setxkbmap") + .arg("-layout") + .arg(keyboard_layout.clone()) + .spawn() + .expect("keyboard failed to start"); + } + })); + if current_keyboard.contains(&(keyboard_layout_clone)) { + keyboard_layout_checkbutton.set_active(true); + } + } + + // / keyboard_selection_box appends + //// add text and and entry to keyboard page selections + keyboard_selection_box.append(&keyboard_selection_text); + keyboard_selection_box.append(&keyboard_selection_expander_row_viewport_listbox); + + // / keyboard_header_box appends + //// Add the keyboard page header text and icon + keyboard_header_box.append(&keyboard_header_text); + keyboard_header_box.append(&keyboard_header_icon); + + // / keyboard_main_box appends + //// Add the keyboard header to keyboard main box + keyboard_main_box.append(&keyboard_header_box); + //// Add the keyboard selection/page content box to keyboard main box + keyboard_main_box.append(&keyboard_selection_box); + + //// Add the keyboard selection/page content box to keyboard main box + keyboard_main_box.append(>k::Entry::builder().hexpand(true).valign(Align::End).vexpand(false).margin_bottom(15).margin_top(15).margin_end(15).margin_start(15).placeholder_text("Test Your Keyboard here!").build()); + + keyboard_main_box.append(&bottom_box); + + // / Content stack appends + //// Add the keyboard_main_box as page: keyboard_page, Give it nice title + content_stack.add_titled(&keyboard_main_box, Some("keyboard_page"), "Keyboard"); + + let keyboard_data_buffer_clone = keyboard_data_buffer.clone(); + + bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { + if Path::new("/tmp/pika-installer-gtk4-keyboard.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-keyboard.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-keyboard.txt"); + } + fs::write("/tmp/pika-installer-gtk4-keyboard.txt", keyboard_data_buffer_clone.text(&keyboard_data_buffer_clone.bounds().0, &keyboard_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + content_stack.set_visible_child_name("partitioning_page") + })); + + bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { + content_stack.set_visible_child_name("timezone_page") + })); + +} diff --git a/src/language_page/main.rs b/src/language_page/main.rs deleted file mode 100644 index afed32b..0000000 --- a/src/language_page/main.rs +++ /dev/null @@ -1,243 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use std::io::BufRead; -use std::io::BufReader; -use std::process::Command; -use std::process::Stdio; -use std::time::Instant; -use std::env; - -use std::fs; -use std::path::Path; - - -pub fn language_page(content_stack: >k::Stack) { - - // create the bottom box for next and back buttons - let bottom_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .valign(gtk::Align::End) - .vexpand(true) - .build(); - - // Next and back button - let bottom_back_button = gtk::Button::builder() - .label("Back") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::Start) - .hexpand(true) - .build(); - let bottom_next_button = gtk::Button::builder() - .label("Next") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::End) - .hexpand(true) - .sensitive(false) - .build(); - - // Start Applying css classes - bottom_next_button.add_css_class("suggested-action"); - - // / bottom_box appends - //// Add the next and back buttons - bottom_box.append(&bottom_back_button); - bottom_box.append(&bottom_next_button); - - // the header box for the language page - let language_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the language page - let language_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the language page - let language_header_text = gtk::Label::builder() - .label("Select a language") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - language_header_text.add_css_class("header_sized_text"); - - // the header icon for the language icon - let language_header_icon = gtk::Image::builder() - .icon_name("locale") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // make language selection box for choosing installation or live media - let language_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // / language_header_box appends - //// Add the language page header text and icon - language_header_box.append(&language_header_text); - language_header_box.append(&language_header_icon); - - // / language_main_box appends - //// Add the language header to language main box - language_main_box.append(&language_header_box); - //// Add the language selection/page content box to language main box - language_main_box.append(&language_selection_box); - - // text above language selection box - let language_selection_text = gtk::Label::builder() - .label("Please select a locale for the system to use") - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - language_selection_text.add_css_class("medium_sized_text"); - - let language_selection_expander_row = adw::ExpanderRow::builder() - .title("No locale selected") - .build(); - - let null_checkbutton = gtk::CheckButton::builder() - .label("No locale selected") - .build(); - - let language_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); - - let language_selection_expander_row_viewport_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - language_selection_expander_row_viewport.set_child(Some(&language_selection_expander_row_viewport_box)); - - let language_selection_expander_row_viewport_listbox = gtk::ListBox::builder() - .selection_mode(SelectionMode::None) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - language_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); - language_selection_expander_row_viewport_listbox.append(&language_selection_expander_row); - - language_selection_expander_row.add_row(&language_selection_expander_row_viewport); - - let current_locale = match env::var_os("LANG") { - Some(v) => v.into_string().unwrap(), - None => panic!("$LANG is not set") - }; - - let locale_cli = Command::new("locale") - .arg("-a") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - let locale_cli_cut = Command::new("cut") - .arg("-d.") - .arg("-f1") - .stdin(Stdio::from(locale_cli.stdout.unwrap())) // Pipe through. - .stdout(Stdio::piped()) - .spawn() - .unwrap(); - let locale_cli_sort = Command::new("sort") - .arg("-u") - .stdin(Stdio::from(locale_cli_cut.stdout.unwrap())) - .stdout(Stdio::piped()) - .spawn() - .unwrap(); - - let locale_reader = BufReader::new(locale_cli_sort.stdout.expect("could not get stdout")); - - let lang_data_buffer = gtk::TextBuffer::builder() - .build(); - - for locale in locale_reader.lines() { - let locale = locale.unwrap(); - let locale_clone = locale.clone(); - let locale_checkbutton = gtk::CheckButton::builder() - .label(locale.clone()) - .build(); - locale_checkbutton.set_group(Some(&null_checkbutton)); - language_selection_expander_row_viewport_box.append(&locale_checkbutton); - locale_checkbutton.connect_toggled(clone!(@weak locale_checkbutton, @weak language_selection_expander_row, @weak bottom_next_button, @weak lang_data_buffer => move |_| { - if locale_checkbutton.is_active() == true { - language_selection_expander_row.set_title(&locale); - bottom_next_button.set_sensitive(true); - lang_data_buffer.set_text(&locale); - } - })); - if current_locale.contains(&(locale_clone)) { - locale_checkbutton.set_active(true); - } - } - - // / language_selection_box appends - //// add text and and entry to language page selections - language_selection_box.append(&language_selection_text); - language_selection_box.append(&language_selection_expander_row_viewport_listbox); - - // / language_header_box appends - //// Add the language page header text and icon - language_header_box.append(&language_header_text); - language_header_box.append(&language_header_icon); - - // / language_main_box appends - //// Add the language header to language main box - language_main_box.append(&language_header_box); - //// Add the language selection/page content box to language main box - language_main_box.append(&language_selection_box); - - language_main_box.append(&bottom_box); - - // / Content stack appends - //// Add the language_main_box as page: language_page, Give it nice title - content_stack.add_titled(&language_main_box, Some("language_page"), "Language"); - - let lang_data_buffer_clone = lang_data_buffer.clone(); - - bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - if Path::new("/tmp/pika-installer-gtk4-lang.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-lang.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-lang.txt"); - } - fs::write("/tmp/pika-installer-gtk4-lang.txt", lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - Command::new("sudo") - .arg("localectl") - .arg("set-locale") - .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8") - .spawn() - .expect("locale failed to start"); - content_stack.set_visible_child_name("eula_page") - })); - bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("welcome_page") - })); -} diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index 5a8f649..dee5ec4 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -1 +1,243 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::env; + +use std::fs; +use std::path::Path; + + +pub fn language_page(content_stack: >k::Stack) { + + // create the bottom box for next and back buttons + let bottom_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .valign(gtk::Align::End) + .vexpand(true) + .build(); + + // Next and back button + let bottom_back_button = gtk::Button::builder() + .label("Back") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::Start) + .hexpand(true) + .build(); + let bottom_next_button = gtk::Button::builder() + .label("Next") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::End) + .hexpand(true) + .sensitive(false) + .build(); + + // Start Applying css classes + bottom_next_button.add_css_class("suggested-action"); + + // / bottom_box appends + //// Add the next and back buttons + bottom_box.append(&bottom_back_button); + bottom_box.append(&bottom_next_button); + + // the header box for the language page + let language_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the language page + let language_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the language page + let language_header_text = gtk::Label::builder() + .label("Select a language") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + language_header_text.add_css_class("header_sized_text"); + + // the header icon for the language icon + let language_header_icon = gtk::Image::builder() + .icon_name("locale") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // make language selection box for choosing installation or live media + let language_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // / language_header_box appends + //// Add the language page header text and icon + language_header_box.append(&language_header_text); + language_header_box.append(&language_header_icon); + + // / language_main_box appends + //// Add the language header to language main box + language_main_box.append(&language_header_box); + //// Add the language selection/page content box to language main box + language_main_box.append(&language_selection_box); + + // text above language selection box + let language_selection_text = gtk::Label::builder() + .label("Please select a locale for the system to use") + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + language_selection_text.add_css_class("medium_sized_text"); + + let language_selection_expander_row = adw::ExpanderRow::builder() + .title("No locale selected") + .build(); + + let null_checkbutton = gtk::CheckButton::builder() + .label("No locale selected") + .build(); + + let language_selection_expander_row_viewport = gtk::ScrolledWindow::builder() + .height_request(200) + .build(); + + let language_selection_expander_row_viewport_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + language_selection_expander_row_viewport.set_child(Some(&language_selection_expander_row_viewport_box)); + + let language_selection_expander_row_viewport_listbox = gtk::ListBox::builder() + .selection_mode(SelectionMode::None) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + language_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); + language_selection_expander_row_viewport_listbox.append(&language_selection_expander_row); + + language_selection_expander_row.add_row(&language_selection_expander_row_viewport); + + let current_locale = match env::var_os("LANG") { + Some(v) => v.into_string().unwrap(), + None => panic!("$LANG is not set") + }; + + let locale_cli = Command::new("locale") + .arg("-a") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + let locale_cli_cut = Command::new("cut") + .arg("-d.") + .arg("-f1") + .stdin(Stdio::from(locale_cli.stdout.unwrap())) // Pipe through. + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + let locale_cli_sort = Command::new("sort") + .arg("-u") + .stdin(Stdio::from(locale_cli_cut.stdout.unwrap())) + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + + let locale_reader = BufReader::new(locale_cli_sort.stdout.expect("could not get stdout")); + + let lang_data_buffer = gtk::TextBuffer::builder() + .build(); + + for locale in locale_reader.lines() { + let locale = locale.unwrap(); + let locale_clone = locale.clone(); + let locale_checkbutton = gtk::CheckButton::builder() + .label(locale.clone()) + .build(); + locale_checkbutton.set_group(Some(&null_checkbutton)); + language_selection_expander_row_viewport_box.append(&locale_checkbutton); + locale_checkbutton.connect_toggled(clone!(@weak locale_checkbutton, @weak language_selection_expander_row, @weak bottom_next_button, @weak lang_data_buffer => move |_| { + if locale_checkbutton.is_active() == true { + language_selection_expander_row.set_title(&locale); + bottom_next_button.set_sensitive(true); + lang_data_buffer.set_text(&locale); + } + })); + if current_locale.contains(&(locale_clone)) { + locale_checkbutton.set_active(true); + } + } + + // / language_selection_box appends + //// add text and and entry to language page selections + language_selection_box.append(&language_selection_text); + language_selection_box.append(&language_selection_expander_row_viewport_listbox); + + // / language_header_box appends + //// Add the language page header text and icon + language_header_box.append(&language_header_text); + language_header_box.append(&language_header_icon); + + // / language_main_box appends + //// Add the language header to language main box + language_main_box.append(&language_header_box); + //// Add the language selection/page content box to language main box + language_main_box.append(&language_selection_box); + + language_main_box.append(&bottom_box); + + // / Content stack appends + //// Add the language_main_box as page: language_page, Give it nice title + content_stack.add_titled(&language_main_box, Some("language_page"), "Language"); + + let lang_data_buffer_clone = lang_data_buffer.clone(); + + bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { + if Path::new("/tmp/pika-installer-gtk4-lang.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-lang.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-lang.txt"); + } + fs::write("/tmp/pika-installer-gtk4-lang.txt", lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + Command::new("sudo") + .arg("localectl") + .arg("set-locale") + .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8") + .spawn() + .expect("locale failed to start"); + content_stack.set_visible_child_name("eula_page") + })); + bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { + content_stack.set_visible_child_name("welcome_page") + })); +} diff --git a/src/manual_partitioning/main.rs b/src/manual_partitioning/main.rs deleted file mode 100644 index de79bdd..0000000 --- a/src/manual_partitioning/main.rs +++ /dev/null @@ -1,153 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use std::io::BufRead; -use std::io::BufReader; -use std::process::Command; -use std::process::Stdio; -use std::time::Instant; -use std::env; -use pretty_bytes::converter::convert; - -use std::thread; -use std::time::*; - -use std::fs; -use std::path::Path; -use crate::drive_mount_row::DriveMountRow; - -fn create_mount_row(listbox: >k::ListBox) -> DriveMountRow { - // Create row - let row = DriveMountRow::new(); - - let listbox_clone = listbox.clone(); - - row.connect_closure( - "row-deleted", - false, - closure_local!(move |_row: DriveMountRow| { - listbox_clone.remove(&_row) - }), - ); - - // Return row - row -} - -//pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { -pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) { - let partition_method_manual_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_bottom(15) - .margin_top(15) - .margin_end(15) - .margin_start(15) - .build(); - - let partition_method_manual_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the partitioning page - let partition_method_manual_header_text = gtk::Label::builder() - .label("Manual Partitioning Installer") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - partition_method_manual_header_text.add_css_class("header_sized_text"); - - // the header icon for the partitioning icon - let partition_method_manual_header_icon = gtk::Image::builder() - .icon_name("input-tablet") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - let partition_method_manual_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let partition_method_manual_gparted_button_content_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let partition_method_manual_gparted_button_content_text = gtk::Label::builder() - .label("Use this utility to partition/mount/format your drives.") - .build(); - - let partition_method_manual_gparted_button_content = adw::ButtonContent::builder() - .label("Open GPARTED") - .icon_name("gparted") - .build(); - - let partition_method_manual_gparted_button = gtk::Button::builder() - .child(&partition_method_manual_gparted_button_content_box) - .halign(Align::Center) - .valign(Align::Start) - .build(); - - let drive_mounts_adw_listbox = gtk::ListBox::builder() - .hexpand(true) - .vexpand(true) - .build(); - drive_mounts_adw_listbox.add_css_class("boxed-list"); - - let drive_mounts_viewport = gtk::ScrolledWindow::builder() - .halign(Align::Center) - .valign(Align::Center) - .margin_top(30) - .margin_bottom(30) - .margin_start(30) - .margin_end(30) - .propagate_natural_height(true) - .propagate_natural_width(true) - .hexpand(true) - .vexpand(true) - .child(&drive_mounts_adw_listbox) - .build(); - - let drive_mount_add_button = gtk::Button::builder() - .icon_name("list-add") - .build(); - - partition_method_manual_header_box.append(&partition_method_manual_header_text); - partition_method_manual_header_box.append(&partition_method_manual_header_icon); - partition_method_manual_main_box.append(&partition_method_manual_header_box); - partition_method_manual_main_box.append(&partition_method_manual_selection_box); - partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); - partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content_text); - partition_method_manual_main_box.append(&partition_method_manual_gparted_button); - drive_mounts_adw_listbox.append(&drive_mount_add_button); - partition_method_manual_main_box.append(&drive_mounts_viewport); - - partition_method_manual_gparted_button.connect_clicked(move |_| { - Command::new("gparted") - .spawn() - .expect("gparted failed to start"); - }); - - drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox => move |_|{ - drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox)) - })); - - partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); - - //return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) -} diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 5a8f649..4f7ff42 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -1 +1,204 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +//use parted::*; + +use std::cell::RefCell; +use std::rc::Rc; + +use std::{ + hash::{ + Hash, + }, + collections::{ + HashSet + }, + io::{ + BufRead, + BufReader, + }, + process::{ + Command, + Stdio, + }, + time::{ + Instant, + }, + fs, + path::{ + Path, + }, +}; +use std::ops::DerefMut; + +use pretty_bytes::converter::convert; +use crate::drive_mount_row::DriveMountRow; + +fn create_mount_row(listbox: >k::ListBox) -> DriveMountRow { + // Create row + let row = DriveMountRow::new(); + + let listbox_clone = listbox.clone(); + + row.connect_closure( + "row-deleted", + false, + closure_local!(move |_row: DriveMountRow| { + listbox_clone.remove(&_row) + }), + ); + + // Return row + row +} + +fn has_unique_elements(iter: T) -> bool + where + T: IntoIterator, + T::Item: Eq + Hash, +{ + let mut uniq = HashSet::new(); + iter.into_iter().all(move |x| uniq.insert(x)) +} + +//pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { +pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_partition_array: Rc>>, manual_drive_mountpoint_array: Rc>>, manual_drive_mountopt_array: Rc>>) { + let partition_method_manual_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_bottom(15) + .margin_top(15) + .margin_end(15) + .margin_start(15) + .build(); + + let partition_method_manual_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the partitioning page + let partition_method_manual_header_text = gtk::Label::builder() + .label("Manual Partitioning Installer") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + partition_method_manual_header_text.add_css_class("header_sized_text"); + + // the header icon for the partitioning icon + let partition_method_manual_header_icon = gtk::Image::builder() + .icon_name("input-tablet") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + let partition_method_manual_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let partition_method_manual_gparted_button_content_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let partition_method_manual_gparted_button_content_text = gtk::Label::builder() + .label("Use this utility to partition/mount/format your drives.") + .build(); + + let partition_method_manual_gparted_button_content = adw::ButtonContent::builder() + .label("Open GPARTED") + .icon_name("gparted") + .build(); + + let partition_method_manual_gparted_button = gtk::Button::builder() + .child(&partition_method_manual_gparted_button_content_box) + .halign(Align::Center) + .valign(Align::Start) + .build(); + + let drive_mounts_adw_listbox = gtk::ListBox::builder() + .hexpand(true) + .vexpand(true) + .build(); + drive_mounts_adw_listbox.add_css_class("boxed-list"); + + let drive_mounts_viewport = gtk::ScrolledWindow::builder() + .halign(Align::Center) + .valign(Align::Center) + .margin_top(30) + .margin_bottom(30) + .margin_start(30) + .margin_end(30) + .propagate_natural_height(true) + .propagate_natural_width(true) + .hexpand(true) + .vexpand(true) + .child(&drive_mounts_adw_listbox) + .build(); + + let drive_mount_add_button = gtk::Button::builder() + .icon_name("list-add") + .build(); + + partition_method_manual_header_box.append(&partition_method_manual_header_text); + partition_method_manual_header_box.append(&partition_method_manual_header_icon); + partition_method_manual_main_box.append(&partition_method_manual_header_box); + partition_method_manual_main_box.append(&partition_method_manual_selection_box); + partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); + partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content_text); + partition_method_manual_main_box.append(&partition_method_manual_gparted_button); + drive_mounts_adw_listbox.append(&drive_mount_add_button); + partition_method_manual_main_box.append(&drive_mounts_viewport); + + partition_method_manual_gparted_button.connect_clicked(move |_| { + Command::new("gparted") + .spawn() + .expect("gparted failed to start"); + }); + + drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox => move |_|{ + drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox)) + })); + + let debug_button = gtk::Button::builder() + .label("debug") + .build(); + + partition_method_manual_main_box.append(&debug_button); + + debug_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox => move |_| { + let mut counter = drive_mounts_adw_listbox.first_child(); + + // usage of while loop + manual_drive_mountpoint_array.borrow_mut().clear(); + while let Some(row) = counter { + if row.widget_name() == "DriveMountRow" { + manual_drive_mountpoint_array.borrow_mut().push(row.clone().property("mountpoint")) + } + counter = row.next_sibling(); + } + + if !has_unique_elements(manual_drive_mountpoint_array.borrow_mut().deref_mut()) { + println!("FAK") + } + })); + + + partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); + + //return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) +} diff --git a/src/partitioning_page/main.rs b/src/partitioning_page/main.rs deleted file mode 100644 index 020d383..0000000 --- a/src/partitioning_page/main.rs +++ /dev/null @@ -1,281 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use crate::automatic_partitioning::main::automatic_partitioning; -use crate::manual_partitioning::main::manual_partitioning; -use crate::install_page::main::install_page; - -use std::io::BufRead; -use std::io::BufReader; -use std::process::Command; -use std::process::Stdio; -use std::time::Instant; -use std::env; -use pretty_bytes::converter::convert; - -use std::thread; -use std::time::*; - -use std::fs; -use std::path::Path; - -use crate::install_page; - -pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { - - // create the bottom box for next and back buttons - let bottom_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .valign(gtk::Align::End) - .vexpand(true) - .build(); - - // Next and back button - let bottom_back_button = gtk::Button::builder() - .label("Back") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::Start) - .hexpand(true) - .build(); - let bottom_next_button = gtk::Button::builder() - .label("Next") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::End) - .hexpand(true) - .sensitive(false) - .build(); - - // Start Applying css classes - bottom_next_button.add_css_class("suggested-action"); - - // / bottom_box appends - //// Add the next and back buttons - bottom_box.append(&bottom_back_button); - bottom_box.append(&bottom_next_button); - - // the header box for the partitioning page - let partitioning_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the partitioning page - let partitioning_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the partitioning page - let partitioning_header_text = gtk::Label::builder() - .label("Choose an install method") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - partitioning_header_text.add_css_class("header_sized_text"); - - // the header icon for the partitioning icon - let partitioning_header_icon = gtk::Image::builder() - .icon_name("media-floppy") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // a stack for the 2 partitioning methods - let partitioning_stack = gtk::Stack::builder() - .transition_type(StackTransitionType::SlideLeftRight) - .build(); - - let partitioning_method_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // make partitioning selection box for choosing installation or live media - let partitioning_selection_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .spacing(200) - .build(); - - let manual_method_button_content_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_top(30) - .margin_bottom(30) - .build(); - - let manual_method_button_content_image = gtk::Image::builder() - .icon_name("input-tablet") - .pixel_size(128) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let manual_method_button_content_text = gtk::Label::builder() - .label("Manually Partition The Drive") - .margin_top(0) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - manual_method_button_content_text.add_css_class("medium_sized_text"); - - let automatic_method_button_content_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .margin_top(20) - .margin_bottom(20) - .margin_end(15) - .margin_start(15) - .build(); - - let automatic_method_button_content_image = gtk::Image::builder() - .icon_name("media-playlist-shuffle") - .pixel_size(128) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let automatic_method_button_content_text = gtk::Label::builder() - .label("Automatically Partition\nThe Drive") - .margin_top(0) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - automatic_method_button_content_text.add_css_class("medium_sized_text"); - - let manual_method_button = gtk::Button::builder() - .child(&manual_method_button_content_box) - .vexpand(true) - .hexpand(true) - .halign(gtk::Align::End) - .valign(gtk::Align::Center) - .build(); - - - let automatic_method_button = gtk::Button::builder() - .child(&automatic_method_button_content_box) - .vexpand(true) - .hexpand(true) - .halign(gtk::Align::Start) - .valign(gtk::Align::Center) - .build(); - - // / manual_method_button_content_box appends - //// add image and text to the manual_method_button - manual_method_button_content_box.append(&manual_method_button_content_image); - manual_method_button_content_box.append(&manual_method_button_content_text); - - // / automatic_method_button_content_box appends - //// add image and text to the automatic_method_button - automatic_method_button_content_box.append(&automatic_method_button_content_image); - automatic_method_button_content_box.append(&automatic_method_button_content_text); - - // / partitioning_selection_box appends - //// add live and install media button to partitioning page selections - partitioning_selection_box.append(&manual_method_button); - partitioning_selection_box.append(&automatic_method_button); - - // / partitioning_header_box appends - //// Add the partitioning page header text and icon - partitioning_header_box.append(&partitioning_header_text); - partitioning_header_box.append(&partitioning_header_icon); - - partitioning_method_main_box.append(&partitioning_header_box); - partitioning_method_main_box.append(&partitioning_selection_box); - - 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"), "partition_method_select_page"); - let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button); - let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button); - - // add everything to the main box - partitioning_main_box.append(&partitioning_stack); - partitioning_main_box.append(&bottom_box); - - // / Content stack appends - //// Add the partitioning_main_box as page: partitioning_page, Give it nice title - content_stack.add_titled(&partitioning_main_box, Some("partitioning_page"), "Partitioning"); - - automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); - manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); - - //let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); - - //let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); - - //let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); - - //let partition_method_manual_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone(); - - bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("install_page") - })); - bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak partitioning_main_box, @weak bottom_next_button => move |_| { - content_stack.set_visible_child_name("keyboard_page"); - partitioning_stack.set_visible_child_name("partition_method_select_page"); - bottom_next_button.set_sensitive(false); - })); - - bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| { - if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-target-auto.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-auto.txt"); - } - if Path::new("/tmp/pika-installer-gtk4-target-manual.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-target-manual.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); - } - if Path::new("/tmp/pika-installer-gtk4-target-automatic-luks.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-target-automatic-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); - } - if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); - } - if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) { - //fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - //let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); - //if automatic_luks_result.is_empty() { - // // - //} else { - // fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); - //} - install_page(&done_main_box, &install_main_box, &content_stack, &window); - content_stack.set_visible_child_name("install_page"); - } else { - //fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - //partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string()); - //let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string(); - //if manual_luks_result.is_empty() { - // // - //} else { - // fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result); - //} - install_page(&done_main_box, &install_main_box, &content_stack, &window); - content_stack.set_visible_child_name("install_page"); - } - })); - -} diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 5a8f649..41fd4d3 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -1 +1,290 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use crate::automatic_partitioning::automatic_partitioning; +use crate::manual_partitioning::manual_partitioning; +use crate::install_page::install_page; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::env; +use pretty_bytes::converter::convert; + +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; + +pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { + + let manual_drive_partition_array : Rc>> = Default::default(); + let manual_drive_mountpoint_array : Rc>> = Default::default(); + let manual_drive_mountopt_array : Rc>> = Default::default(); + + // create the bottom box for next and back buttons + let bottom_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .valign(gtk::Align::End) + .vexpand(true) + .build(); + + // Next and back button + let bottom_back_button = gtk::Button::builder() + .label("Back") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::Start) + .hexpand(true) + .build(); + let bottom_next_button = gtk::Button::builder() + .label("Next") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::End) + .hexpand(true) + .sensitive(false) + .build(); + + // Start Applying css classes + bottom_next_button.add_css_class("suggested-action"); + + // / bottom_box appends + //// Add the next and back buttons + bottom_box.append(&bottom_back_button); + bottom_box.append(&bottom_next_button); + + // the header box for the partitioning page + let partitioning_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the partitioning page + let partitioning_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the partitioning page + let partitioning_header_text = gtk::Label::builder() + .label("Choose an install method") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + partitioning_header_text.add_css_class("header_sized_text"); + + // the header icon for the partitioning icon + let partitioning_header_icon = gtk::Image::builder() + .icon_name("media-floppy") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // a stack for the 2 partitioning methods + let partitioning_stack = gtk::Stack::builder() + .transition_type(StackTransitionType::SlideLeftRight) + .build(); + + let partitioning_method_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // make partitioning selection box for choosing installation or live media + let partitioning_selection_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .spacing(200) + .build(); + + let manual_method_button_content_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_top(30) + .margin_bottom(30) + .build(); + + let manual_method_button_content_image = gtk::Image::builder() + .icon_name("input-tablet") + .pixel_size(128) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let manual_method_button_content_text = gtk::Label::builder() + .label("Manually Partition The Drive") + .margin_top(0) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + manual_method_button_content_text.add_css_class("medium_sized_text"); + + let automatic_method_button_content_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .margin_top(20) + .margin_bottom(20) + .margin_end(15) + .margin_start(15) + .build(); + + let automatic_method_button_content_image = gtk::Image::builder() + .icon_name("media-playlist-shuffle") + .pixel_size(128) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let automatic_method_button_content_text = gtk::Label::builder() + .label("Automatically Partition\nThe Drive") + .margin_top(0) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + automatic_method_button_content_text.add_css_class("medium_sized_text"); + + let manual_method_button = gtk::Button::builder() + .child(&manual_method_button_content_box) + .vexpand(true) + .hexpand(true) + .halign(gtk::Align::End) + .valign(gtk::Align::Center) + .build(); + + + let automatic_method_button = gtk::Button::builder() + .child(&automatic_method_button_content_box) + .vexpand(true) + .hexpand(true) + .halign(gtk::Align::Start) + .valign(gtk::Align::Center) + .build(); + + // / manual_method_button_content_box appends + //// add image and text to the manual_method_button + manual_method_button_content_box.append(&manual_method_button_content_image); + manual_method_button_content_box.append(&manual_method_button_content_text); + + // / automatic_method_button_content_box appends + //// add image and text to the automatic_method_button + automatic_method_button_content_box.append(&automatic_method_button_content_image); + automatic_method_button_content_box.append(&automatic_method_button_content_text); + + // / partitioning_selection_box appends + //// add live and install media button to partitioning page selections + partitioning_selection_box.append(&manual_method_button); + partitioning_selection_box.append(&automatic_method_button); + + // / partitioning_header_box appends + //// Add the partitioning page header text and icon + partitioning_header_box.append(&partitioning_header_text); + partitioning_header_box.append(&partitioning_header_icon); + + partitioning_method_main_box.append(&partitioning_header_box); + partitioning_method_main_box.append(&partitioning_selection_box); + + manual_method_button_content_box.append(&manual_method_button_content_image); + + /// add all pages to partitioning stack + automatic_method_button.connect_clicked(clone!(@strong manual_drive_mountpoint_array => move |_| println!("{}", manual_drive_mountpoint_array.borrow().deref().into_iter().nth(0).unwrap()))); + partitioning_stack.add_titled(&partitioning_method_main_box, Some("partition_method_select_page"), "partition_method_select_page"); + let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button); + let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, manual_drive_partition_array, manual_drive_mountpoint_array, manual_drive_mountopt_array); + + // add everything to the main box + partitioning_main_box.append(&partitioning_stack); + partitioning_main_box.append(&bottom_box); + + // / Content stack appends + //// Add the partitioning_main_box as page: partitioning_page, Give it nice title + content_stack.add_titled(&partitioning_main_box, Some("partitioning_page"), "Partitioning"); + + //automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); + manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); + + //let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); + + //let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); + + //let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); + + //let partition_method_manual_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone(); + + bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { + content_stack.set_visible_child_name("install_page") + })); + bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak partitioning_main_box, @weak bottom_next_button => move |_| { + content_stack.set_visible_child_name("keyboard_page"); + partitioning_stack.set_visible_child_name("partition_method_select_page"); + bottom_next_button.set_sensitive(false); + })); + + bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| { + if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-target-auto.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-auto.txt"); + } + if Path::new("/tmp/pika-installer-gtk4-target-manual.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-target-manual.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); + } + if Path::new("/tmp/pika-installer-gtk4-target-automatic-luks.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-target-automatic-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); + } + if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); + } + if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) { + //fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + //let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); + //if automatic_luks_result.is_empty() { + // // + //} else { + // fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); + //} + install_page(&done_main_box, &install_main_box, &content_stack, &window); + content_stack.set_visible_child_name("install_page"); + } else { + //fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + //partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string()); + //let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string(); + //if manual_luks_result.is_empty() { + // // + //} else { + // fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result); + //} + install_page(&done_main_box, &install_main_box, &content_stack, &window); + content_stack.set_visible_child_name("install_page"); + } + })); + +} diff --git a/src/save_window_size/main.rs b/src/save_window_size/main.rs deleted file mode 100644 index 5ccb439..0000000 --- a/src/save_window_size/main.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; - -// Save current window size to glib -pub fn save_window_size(window: &adw::ApplicationWindow, glib_settings: &gio::Settings) { - - let size = window.default_size(); - - let _ = glib_settings.set_int("window-width", size.0); - let _ = glib_settings.set_int("window-height", size.1); - let _ = glib_settings.set_boolean("is-maximized", window.is_maximized()); -} diff --git a/src/save_window_size/mod.rs b/src/save_window_size/mod.rs index 5a8f649..b072be5 100644 --- a/src/save_window_size/mod.rs +++ b/src/save_window_size/mod.rs @@ -1 +1,19 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; + +// Save current window size to glib +pub fn save_window_size(window: &adw::ApplicationWindow, glib_settings: &gio::Settings) { + + let size = window.default_size(); + + let _ = glib_settings.set_int("window-width", size.0); + let _ = glib_settings.set_int("window-height", size.1); + let _ = glib_settings.set_boolean("is-maximized", window.is_maximized()); +} diff --git a/src/timezone_page/main.rs b/src/timezone_page/main.rs deleted file mode 100644 index 3941c66..0000000 --- a/src/timezone_page/main.rs +++ /dev/null @@ -1,239 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -use std::io::BufRead; -use std::io::BufReader; -use std::process::Command; -use std::process::Stdio; -use std::time::Instant; -use std::str; - -use std::fs; -use std::path::Path; - -pub fn timezone_page(content_stack: >k::Stack) { - - // create the bottom box for next and back buttons - let bottom_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .valign(gtk::Align::End) - .vexpand(true) - .build(); - - // Next and back button - let bottom_back_button = gtk::Button::builder() - .label("Back") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::Start) - .hexpand(true) - .build(); - let bottom_next_button = gtk::Button::builder() - .label("Next") - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .halign(gtk::Align::End) - .hexpand(true) - .sensitive(false) - .build(); - - // Start Applying css classes - bottom_next_button.add_css_class("suggested-action"); - - // / bottom_box appends - //// Add the next and back buttons - bottom_box.append(&bottom_back_button); - bottom_box.append(&bottom_next_button); - - // the header box for the timezone page - let timezone_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the timezone page - let timezone_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the timezone page - let timezone_header_text = gtk::Label::builder() - .label("Select a timezone") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - timezone_header_text.add_css_class("header_sized_text"); - - // the header icon for the timezone icon - let timezone_header_icon = gtk::Image::builder() - .icon_name("clock") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // make timezone selection box for choosing installation or live media - let timezone_selection_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // / timezone_header_box appends - //// Add the timezone page header text and icon - timezone_header_box.append(&timezone_header_text); - timezone_header_box.append(&timezone_header_icon); - - // / timezone_main_box appends - //// Add the timezone header to timezone main box - timezone_main_box.append(&timezone_header_box); - //// Add the timezone selection/page content box to timezone main box - timezone_main_box.append(&timezone_selection_box); - - // text above timezone selection box - let timezone_selection_text = gtk::Label::builder() - .label("Please select a Time Zone for the system to use") - .halign(gtk::Align::Center) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - timezone_selection_text.add_css_class("medium_sized_text"); - - let timezone_selection_expander_row = adw::ExpanderRow::builder() - .title("No Time Zone selected") - .build(); - - let null_checkbutton = gtk::CheckButton::builder() - .label("No Time Zone selected") - .build(); - - let timezone_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); - - let timezone_selection_expander_row_viewport_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let timezone_selection_expander_row_viewport_listbox = gtk::ListBox::builder() - .selection_mode(SelectionMode::None) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - timezone_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); - timezone_selection_expander_row_viewport_listbox.append(&timezone_selection_expander_row); - - timezone_selection_expander_row_viewport.set_child(Some(&timezone_selection_expander_row_viewport_box)); - - timezone_selection_expander_row.add_row(&timezone_selection_expander_row_viewport); - - let current_timezone_cli = Command::new("timedatectl") - .arg("show") - .arg("--va") - .arg("-p") - .arg("Timezone") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - - let current_timezone_output = current_timezone_cli.wait_with_output().unwrap(); - let current_timezone = str::from_utf8(¤t_timezone_output.stdout).unwrap().trim(); - - let timezone_layout_cli = Command::new("timedatectl") - .arg("list-timezones") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap_or_else(|e| panic!("failed {}", e)); - - let timezone_layout_stdout = timezone_layout_cli.stdout.expect("could not get stdout"); - let timezone_layout_reader = BufReader::new(timezone_layout_stdout); - - let timezone_data_buffer = gtk::TextBuffer::builder() - .build(); - - for timezone_layout in timezone_layout_reader.lines() { - let timezone_layout = timezone_layout.unwrap(); - let timezone_layout_clone = timezone_layout.clone(); - let timezone_layout_checkbutton = gtk::CheckButton::builder() - .label(timezone_layout.clone()) - .build(); - timezone_layout_checkbutton.set_group(Some(&null_checkbutton)); - timezone_selection_expander_row_viewport_box.append(&timezone_layout_checkbutton); - timezone_layout_checkbutton.connect_toggled(clone!(@weak timezone_layout_checkbutton, @weak timezone_selection_expander_row, @weak bottom_next_button, @weak timezone_data_buffer => move |_| { - if timezone_layout_checkbutton.is_active() == true { - timezone_selection_expander_row.set_title(&timezone_layout); - bottom_next_button.set_sensitive(true); - timezone_data_buffer.set_text(&timezone_layout); - } - })); - if current_timezone.contains(&(timezone_layout_clone)) { - timezone_layout_checkbutton.set_active(true); - } - } - - // / timezone_selection_box appends - //// add text and and entry to timezone page selections - timezone_selection_box.append(&timezone_selection_text); - timezone_selection_box.append(&timezone_selection_expander_row_viewport_listbox); - - // / timezone_header_box appends - //// Add the timezone page header text and icon - timezone_header_box.append(&timezone_header_text); - timezone_header_box.append(&timezone_header_icon); - - // / timezone_main_box appends - //// Add the timezone header to timezone main box - timezone_main_box.append(&timezone_header_box); - //// Add the timezone selection/page content box to timezone main box - timezone_main_box.append(&timezone_selection_box); - - timezone_main_box.append(&bottom_box); - - // / Content stack appends - //// Add the timezone_main_box as page: timezone_page, Give it nice title - content_stack.add_titled(&timezone_main_box, Some("timezone_page"), "Time Zone"); - - let timezone_data_buffer_clone = timezone_data_buffer.clone(); - - bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { - if Path::new("/tmp/pika-installer-gtk4-timezone.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-timezone.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-timezone.txt"); - } - fs::write("/tmp/pika-installer-gtk4-timezone.txt", timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - Command::new("sudo") - .arg("timedatectl") - .arg("set-timezone") - .arg(&timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()) - .spawn() - .expect("timezone failed to start"); - content_stack.set_visible_child_name("keyboard_page") - })); - bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { - content_stack.set_visible_child_name("eula_page") - })); - -} diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index 5a8f649..dcf65bc 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -1 +1,239 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +use std::io::BufRead; +use std::io::BufReader; +use std::process::Command; +use std::process::Stdio; +use std::time::Instant; +use std::str; + +use std::fs; +use std::path::Path; + +pub fn timezone_page(content_stack: >k::Stack) { + + // create the bottom box for next and back buttons + let bottom_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .valign(gtk::Align::End) + .vexpand(true) + .build(); + + // Next and back button + let bottom_back_button = gtk::Button::builder() + .label("Back") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::Start) + .hexpand(true) + .build(); + let bottom_next_button = gtk::Button::builder() + .label("Next") + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .halign(gtk::Align::End) + .hexpand(true) + .sensitive(false) + .build(); + + // Start Applying css classes + bottom_next_button.add_css_class("suggested-action"); + + // / bottom_box appends + //// Add the next and back buttons + bottom_box.append(&bottom_back_button); + bottom_box.append(&bottom_next_button); + + // the header box for the timezone page + let timezone_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the timezone page + let timezone_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the timezone page + let timezone_header_text = gtk::Label::builder() + .label("Select a timezone") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + timezone_header_text.add_css_class("header_sized_text"); + + // the header icon for the timezone icon + let timezone_header_icon = gtk::Image::builder() + .icon_name("clock") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // make timezone selection box for choosing installation or live media + let timezone_selection_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // / timezone_header_box appends + //// Add the timezone page header text and icon + timezone_header_box.append(&timezone_header_text); + timezone_header_box.append(&timezone_header_icon); + + // / timezone_main_box appends + //// Add the timezone header to timezone main box + timezone_main_box.append(&timezone_header_box); + //// Add the timezone selection/page content box to timezone main box + timezone_main_box.append(&timezone_selection_box); + + // text above timezone selection box + let timezone_selection_text = gtk::Label::builder() + .label("Please select a Time Zone for the system to use") + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + timezone_selection_text.add_css_class("medium_sized_text"); + + let timezone_selection_expander_row = adw::ExpanderRow::builder() + .title("No Time Zone selected") + .build(); + + let null_checkbutton = gtk::CheckButton::builder() + .label("No Time Zone selected") + .build(); + + let timezone_selection_expander_row_viewport = gtk::ScrolledWindow::builder() + .height_request(200) + .build(); + + let timezone_selection_expander_row_viewport_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let timezone_selection_expander_row_viewport_listbox = gtk::ListBox::builder() + .selection_mode(SelectionMode::None) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + timezone_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); + timezone_selection_expander_row_viewport_listbox.append(&timezone_selection_expander_row); + + timezone_selection_expander_row_viewport.set_child(Some(&timezone_selection_expander_row_viewport_box)); + + timezone_selection_expander_row.add_row(&timezone_selection_expander_row_viewport); + + let current_timezone_cli = Command::new("timedatectl") + .arg("show") + .arg("--va") + .arg("-p") + .arg("Timezone") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + + let current_timezone_output = current_timezone_cli.wait_with_output().unwrap(); + let current_timezone = str::from_utf8(¤t_timezone_output.stdout).unwrap().trim(); + + let timezone_layout_cli = Command::new("timedatectl") + .arg("list-timezones") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap_or_else(|e| panic!("failed {}", e)); + + let timezone_layout_stdout = timezone_layout_cli.stdout.expect("could not get stdout"); + let timezone_layout_reader = BufReader::new(timezone_layout_stdout); + + let timezone_data_buffer = gtk::TextBuffer::builder() + .build(); + + for timezone_layout in timezone_layout_reader.lines() { + let timezone_layout = timezone_layout.unwrap(); + let timezone_layout_clone = timezone_layout.clone(); + let timezone_layout_checkbutton = gtk::CheckButton::builder() + .label(timezone_layout.clone()) + .build(); + timezone_layout_checkbutton.set_group(Some(&null_checkbutton)); + timezone_selection_expander_row_viewport_box.append(&timezone_layout_checkbutton); + timezone_layout_checkbutton.connect_toggled(clone!(@weak timezone_layout_checkbutton, @weak timezone_selection_expander_row, @weak bottom_next_button, @weak timezone_data_buffer => move |_| { + if timezone_layout_checkbutton.is_active() == true { + timezone_selection_expander_row.set_title(&timezone_layout); + bottom_next_button.set_sensitive(true); + timezone_data_buffer.set_text(&timezone_layout); + } + })); + if current_timezone.contains(&(timezone_layout_clone)) { + timezone_layout_checkbutton.set_active(true); + } + } + + // / timezone_selection_box appends + //// add text and and entry to timezone page selections + timezone_selection_box.append(&timezone_selection_text); + timezone_selection_box.append(&timezone_selection_expander_row_viewport_listbox); + + // / timezone_header_box appends + //// Add the timezone page header text and icon + timezone_header_box.append(&timezone_header_text); + timezone_header_box.append(&timezone_header_icon); + + // / timezone_main_box appends + //// Add the timezone header to timezone main box + timezone_main_box.append(&timezone_header_box); + //// Add the timezone selection/page content box to timezone main box + timezone_main_box.append(&timezone_selection_box); + + timezone_main_box.append(&bottom_box); + + // / Content stack appends + //// Add the timezone_main_box as page: timezone_page, Give it nice title + content_stack.add_titled(&timezone_main_box, Some("timezone_page"), "Time Zone"); + + let timezone_data_buffer_clone = timezone_data_buffer.clone(); + + bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { + if Path::new("/tmp/pika-installer-gtk4-timezone.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-timezone.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-timezone.txt"); + } + fs::write("/tmp/pika-installer-gtk4-timezone.txt", timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + Command::new("sudo") + .arg("timedatectl") + .arg("set-timezone") + .arg(&timezone_data_buffer_clone.text(&timezone_data_buffer_clone.bounds().0, &timezone_data_buffer_clone.bounds().1, true).to_string()) + .spawn() + .expect("timezone failed to start"); + content_stack.set_visible_child_name("keyboard_page") + })); + bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { + content_stack.set_visible_child_name("eula_page") + })); + +} diff --git a/src/welcome_page/main.rs b/src/welcome_page/main.rs deleted file mode 100644 index 7f2cc90..0000000 --- a/src/welcome_page/main.rs +++ /dev/null @@ -1,169 +0,0 @@ -// Use libraries -/// Use all gtk4 libraries (gtk4 -> gtk because cargo) -/// Use all libadwaita libraries (libadwaita -> adw because cargo) -use gtk::prelude::*; -use gtk::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; -use gtk::subclass::layout_child; - -pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { - // the header box for the welcome page - let welcome_main_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - // the header box for the welcome page - let welcome_header_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .build(); - - // the header text for the welcome page - let welcome_header_text = gtk::Label::builder() - .label("Welcome to PikaOS") - .halign(gtk::Align::End) - .hexpand(true) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(5) - .build(); - welcome_header_text.add_css_class("header_sized_text"); - - // the header icon for the welcome icon - let welcome_header_icon = gtk::Image::builder() - .icon_name("debian-swirl") - .halign(gtk::Align::Start) - .hexpand(true) - .pixel_size(78) - .margin_top(15) - .margin_bottom(15) - .margin_start(0) - .margin_end(15) - .build(); - - // make welcome selection box for choosing installation or live media - let welcome_selection_box = gtk::Box::builder() - .orientation(Orientation::Horizontal) - .spacing(200) - .build(); - - let live_media_button_content_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let live_media_button_content_image = gtk::Image::builder() - .icon_name("drive-optical") - .pixel_size(128) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let live_media_button_content_text = gtk::Label::builder() - .label("Use PikaOS in Live media") - .margin_top(0) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - live_media_button_content_text.add_css_class("medium_sized_text"); - - let install_media_button_content_box = gtk::Box::builder() - .orientation(Orientation::Vertical) - .build(); - - let install_media_button_content_image = gtk::Image::builder() - .icon_name("drive-harddisk") - .pixel_size(128) - .margin_top(15) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - - let install_media_button_content_text = gtk::Label::builder() - .label("Install Distro to System") - .margin_top(0) - .margin_bottom(15) - .margin_start(15) - .margin_end(15) - .build(); - install_media_button_content_text.add_css_class("medium_sized_text"); - - let live_media_button = gtk::Button::builder() - .child(&live_media_button_content_box) - .vexpand(true) - .hexpand(true) - .halign(gtk::Align::End) - .valign(gtk::Align::Center) - .build(); - - - let install_media_button = gtk::Button::builder() - .child(&install_media_button_content_box) - .vexpand(true) - .hexpand(true) - .halign(gtk::Align::Start) - .valign(gtk::Align::Center) - .build(); - - // / live_media_button_content_box appends - //// add image and text to the live_media_button - live_media_button_content_box.append(&live_media_button_content_image); - live_media_button_content_box.append(&live_media_button_content_text); - - // / install_media_button_content_box appends - //// add image and text to the install_media_button - install_media_button_content_box.append(&install_media_button_content_image); - install_media_button_content_box.append(&install_media_button_content_text); - - // / welcome_selection_box appends - //// add live and install media button to welcome page selections - welcome_selection_box.append(&live_media_button); - welcome_selection_box.append(&install_media_button); - - // / welcome_header_box appends - //// Add the welcome page header text and icon - welcome_header_box.append(&welcome_header_text); - welcome_header_box.append(&welcome_header_icon); - - // / welcome_main_box appends - //// Add the welcome header to welcome main box - welcome_main_box.append(&welcome_header_box); - //// Add the welcome selection/page content box to welcome main box - welcome_main_box.append(&welcome_selection_box); - - // Start Appending widgets to boxes - - // / live_media_button_content_box appends - //// add image and text to the live_media_button - live_media_button_content_box.append(&live_media_button_content_image); - - - // / welcome_selection_box appends - //// add live and install media button to welcome page selections - welcome_selection_box.append(&live_media_button); - welcome_selection_box.append(&install_media_button); - - // / welcome_header_box appends - //// Add the welcome page header text and icon - welcome_header_box.append(&welcome_header_text); - welcome_header_box.append(&welcome_header_icon); - - // / welcome_main_box appends - //// Add the welcome header to welcome main box - welcome_main_box.append(&welcome_header_box); - //// Add the welcome selection/page content box to welcome main box - welcome_main_box.append(&welcome_selection_box); - - // / Content stack appends - //// Add the welcome_main_box as page: welcome_page, Give it nice title - content_stack.add_titled(&welcome_main_box, Some("welcome_page"), "Welcome"); - - install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page"))); - live_media_button.connect_clicked(clone!(@weak window => move |_| window.close())); -} diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index 5a8f649..4209e06 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -1 +1,169 @@ -pub mod main; \ No newline at end of file +// Use libraries +/// Use all gtk4 libraries (gtk4 -> gtk because cargo) +/// Use all libadwaita libraries (libadwaita -> adw because cargo) +use gtk::prelude::*; +use gtk::*; +use adw::prelude::*; +use adw::*; +use glib::*; +use gdk::Display; +use gtk::subclass::layout_child; + +pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { + // the header box for the welcome page + let welcome_main_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + // the header box for the welcome page + let welcome_header_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .build(); + + // the header text for the welcome page + let welcome_header_text = gtk::Label::builder() + .label("Welcome to PikaOS") + .halign(gtk::Align::End) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(5) + .build(); + welcome_header_text.add_css_class("header_sized_text"); + + // the header icon for the welcome icon + let welcome_header_icon = gtk::Image::builder() + .icon_name("debian-swirl") + .halign(gtk::Align::Start) + .hexpand(true) + .pixel_size(78) + .margin_top(15) + .margin_bottom(15) + .margin_start(0) + .margin_end(15) + .build(); + + // make welcome selection box for choosing installation or live media + let welcome_selection_box = gtk::Box::builder() + .orientation(Orientation::Horizontal) + .spacing(200) + .build(); + + let live_media_button_content_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let live_media_button_content_image = gtk::Image::builder() + .icon_name("drive-optical") + .pixel_size(128) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let live_media_button_content_text = gtk::Label::builder() + .label("Use PikaOS in Live media") + .margin_top(0) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + live_media_button_content_text.add_css_class("medium_sized_text"); + + let install_media_button_content_box = gtk::Box::builder() + .orientation(Orientation::Vertical) + .build(); + + let install_media_button_content_image = gtk::Image::builder() + .icon_name("drive-harddisk") + .pixel_size(128) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + + let install_media_button_content_text = gtk::Label::builder() + .label("Install Distro to System") + .margin_top(0) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + install_media_button_content_text.add_css_class("medium_sized_text"); + + let live_media_button = gtk::Button::builder() + .child(&live_media_button_content_box) + .vexpand(true) + .hexpand(true) + .halign(gtk::Align::End) + .valign(gtk::Align::Center) + .build(); + + + let install_media_button = gtk::Button::builder() + .child(&install_media_button_content_box) + .vexpand(true) + .hexpand(true) + .halign(gtk::Align::Start) + .valign(gtk::Align::Center) + .build(); + + // / live_media_button_content_box appends + //// add image and text to the live_media_button + live_media_button_content_box.append(&live_media_button_content_image); + live_media_button_content_box.append(&live_media_button_content_text); + + // / install_media_button_content_box appends + //// add image and text to the install_media_button + install_media_button_content_box.append(&install_media_button_content_image); + install_media_button_content_box.append(&install_media_button_content_text); + + // / welcome_selection_box appends + //// add live and install media button to welcome page selections + welcome_selection_box.append(&live_media_button); + welcome_selection_box.append(&install_media_button); + + // / welcome_header_box appends + //// Add the welcome page header text and icon + welcome_header_box.append(&welcome_header_text); + welcome_header_box.append(&welcome_header_icon); + + // / welcome_main_box appends + //// Add the welcome header to welcome main box + welcome_main_box.append(&welcome_header_box); + //// Add the welcome selection/page content box to welcome main box + welcome_main_box.append(&welcome_selection_box); + + // Start Appending widgets to boxes + + // / live_media_button_content_box appends + //// add image and text to the live_media_button + live_media_button_content_box.append(&live_media_button_content_image); + + + // / welcome_selection_box appends + //// add live and install media button to welcome page selections + welcome_selection_box.append(&live_media_button); + welcome_selection_box.append(&install_media_button); + + // / welcome_header_box appends + //// Add the welcome page header text and icon + welcome_header_box.append(&welcome_header_text); + welcome_header_box.append(&welcome_header_icon); + + // / welcome_main_box appends + //// Add the welcome header to welcome main box + welcome_main_box.append(&welcome_header_box); + //// Add the welcome selection/page content box to welcome main box + welcome_main_box.append(&welcome_selection_box); + + // / Content stack appends + //// Add the welcome_main_box as page: welcome_page, Give it nice title + content_stack.add_titled(&welcome_main_box, Some("welcome_page"), "Welcome"); + + install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page"))); + live_media_button.connect_clicked(clone!(@weak window => move |_| window.close())); +} From 9de25c66ad1dd21eb804d16aa3c51ffb6963cae2 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 16 Feb 2024 10:51:28 +0300 Subject: [PATCH 16/52] RR: Manual Partition UI prototype --- Cargo.lock | 117 ++++++++++++++-- Cargo.toml | 2 +- data/scripts/partition-utility.sh | 30 ++++ src/drive_mount_row/imp.rs | 14 +- src/drive_mount_row/mod.rs | 5 + src/manual_partitioning/mod.rs | 219 ++++++++++++++++++++++++++---- src/partitioning_page/mod.rs | 13 +- src/style.css | 5 + 8 files changed, 355 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00a2c6b..a8d1907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,6 +109,18 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "duct" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c" +dependencies = [ + "libc", + "once_cell", + "os_pipe", + "shared_child", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -525,7 +537,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.4", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -587,6 +599,16 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "os_pipe" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "pango" version = "0.18.3" @@ -623,6 +645,7 @@ name = "pika-installer-gtk4" version = "1.0.0" dependencies = [ "async-channel", + "duct", "fragile", "glib", "gtk4", @@ -772,6 +795,16 @@ dependencies = [ "serde", ] +[[package]] +name = "shared_child" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "slab" version = "0.4.9" @@ -963,7 +996,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -972,13 +1014,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -987,42 +1044,84 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.34" diff --git a/Cargo.toml b/Cargo.toml index c0156b3..30f8539 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,10 +8,10 @@ edition = "2021" [dependencies] adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] } async-channel = "2.1.1" +duct = "0.13.7" fragile = "2.0.0" glib = "0.18.5" gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] } -# parted = { version = "0.1.5", package = "libparted" } pretty-bytes = "0.2.2" time = "0.3.31" vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] } diff --git a/data/scripts/partition-utility.sh b/data/scripts/partition-utility.sh index e7cf815..658bf5c 100755 --- a/data/scripts/partition-utility.sh +++ b/data/scripts/partition-utility.sh @@ -32,6 +32,36 @@ then fi fi +if [[ "$1" = "get_partitions" ]] +then + lsblk -ln -o NAME,TYPE | grep -E "part|crypt|lvm" | awk '{print $1}' | while read i ; do + if lsblk -ln -o NAME,TYPE | grep "$i" | grep "crypt" > /dev/null 2>&1 + then + echo "mapper/$(lsblk -ln -o NAME,TYPE | grep "$i" | awk '{print $1}')" + fi + + if lsblk -ln -o NAME,TYPE | grep "$i" | grep "lvm" > /dev/null 2>&1 + then + echo "mapper/$(lsblk -ln -o NAME,TYPE | grep "$i" | awk '{print $1}')" + fi + + if lsblk -ln -o NAME,TYPE | grep "$i" | grep "part" > /dev/null 2>&1 + then + lsblk -ln -o NAME,TYPE | grep "$i" | awk '{print $1}' + fi + done +fi + +if [[ "$1" = "get_part_fs" ]] +then + lsblk -ln -o NAME,FSTYPE | grep "$2" | awk '{print $2}' +fi + +if [[ "$1" = "get_part_size" ]] +then + lsblk -b --output SIZE -n -d /dev/"$2" +fi + if [[ "$1" = "home_not_boot" ]] then if [[ $(blkid "$(df -P -h -T "$2/boot" | awk 'END{print $1}')" -s UUID -o value) == $(blkid "$(df -P -h -T "$2/home" | awk 'END{print $1}')" -s UUID -o value) ]] diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 367fe8d..9b651da 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -42,7 +42,7 @@ pub struct DriveMountRow { #[property(get, set)] mountpoint: RefCell, #[property(get, set)] - partition_scroll: Rc>, + partitionscroll: Rc>, } // ANCHOR_END: custom_button @@ -78,7 +78,7 @@ impl ObjectImpl for DriveMountRow { let partition_row_expander_adw_listbox = gtk::ListBox::builder() .margin_end(5) - .margin_start(0) + .margin_start(10) .margin_top(5) .margin_bottom(5) .build(); @@ -86,17 +86,20 @@ impl ObjectImpl for DriveMountRow { let partition_row_expander = adw::ExpanderRow::builder() .subtitle("Partition") + .width_request(300) .build(); let mountpoint_entry_adw_listbox = gtk::ListBox::builder() .halign(gtk::Align::Center) .margin_top(5) .margin_bottom(5) + .vexpand(true) .build(); mountpoint_entry_adw_listbox.add_css_class("boxed-list"); let mountpoint_entry_row = adw::EntryRow::builder() .title("Mountpoint") + .vexpand(true) .build(); let mountopt_entry_adw_listbox = gtk::ListBox::builder() @@ -104,11 +107,13 @@ impl ObjectImpl for DriveMountRow { .margin_bottom(5) .margin_start(5) .halign(gtk::Align::Center) + .vexpand(true) .build(); mountopt_entry_adw_listbox.add_css_class("boxed-list"); let mountopt_entry_row = adw::EntryRow::builder() .title("Additional Mount Options") + .vexpand(true) .build(); let partition_row_delete_button = gtk::Button::builder() @@ -117,6 +122,7 @@ impl ObjectImpl for DriveMountRow { .margin_top(5) .margin_bottom(5) .width_request(40) + .vexpand(true) .icon_name("edit-delete") .halign(gtk::Align::End) .build(); @@ -157,7 +163,9 @@ impl ObjectImpl for DriveMountRow { .bidirectional() .build(); - partition_row_expander.add_row(&obj.property::("partition_scroll")); + obj.connect_partitionscroll_notify(clone!(@weak obj => move |_| { + partition_row_expander.add_row(&obj.property::("partitionscroll")); + })); } } // Trait shared by all widgets diff --git a/src/drive_mount_row/mod.rs b/src/drive_mount_row/mod.rs index ab787e2..9397c2c 100644 --- a/src/drive_mount_row/mod.rs +++ b/src/drive_mount_row/mod.rs @@ -10,10 +10,15 @@ glib::wrapper! { } impl DriveMountRow { + pub fn new() -> Self { Object::builder().build() } + pub fn new_with_scroll(partitions_scroll: >k::ScrolledWindow) -> Self { + Object::builder().property("partitionscroll", partitions_scroll).build() + } } +// ANCHOR_END: mod impl Default for DriveMountRow { fn default() -> Self { diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 4f7ff42..f085117 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -1,4 +1,6 @@ // Use libraries +use std::collections::HashMap; +use std::thread; /// Use all gtk4 libraries (gtk4 -> gtk because cargo) /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::prelude::*; @@ -7,13 +9,13 @@ use adw::prelude::*; use adw::*; use glib::*; use gdk::Display; -use gtk::subclass::layout_child; +use gtk::subclass::{layout_child, window}; -//use parted::*; - -use std::cell::RefCell; +use std::cell::{RefCell, RefMut}; use std::rc::Rc; +use duct::*; + use std::{ hash::{ Hash, @@ -31,29 +33,96 @@ use std::{ }, time::{ Instant, + Duration, }, fs, path::{ Path, }, }; -use std::ops::DerefMut; +use std::ops::{Deref, DerefMut}; +use duct::cmd; +use gtk::Orientation::Vertical; use pretty_bytes::converter::convert; use crate::drive_mount_row::DriveMountRow; -fn create_mount_row(listbox: >k::ListBox) -> DriveMountRow { +#[derive(PartialEq)] +#[derive(Debug)] +pub struct DriveMount { + partition: String, + mountpoint: String, + mountopt: String, +} + +fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc>>, check_part_unique: &Rc>) -> DriveMountRow { + let partition_scroll_child = gtk::ListBox::builder() + .build(); + + let partitions_scroll = gtk::ScrolledWindow::builder() + .hexpand(true) + .vexpand(true) + .child(&partition_scroll_child) + .build(); + // Create row - let row = DriveMountRow::new(); + let row = DriveMountRow::new_with_scroll(&partitions_scroll); + + let null_checkbutton = gtk::CheckButton::builder() + .build(); + + let partition_method_manual_emitter = gtk::SignalAction::new("partchg"); + + let partition_method_manual_get_partitions_cmd = cmd!("bash", "-c", "sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions"); + let partition_method_manual_get_partitions_reader = partition_method_manual_get_partitions_cmd.stderr_to_stdout().reader(); + let mut partition_method_manual_get_partitions_lines = BufReader::new(partition_method_manual_get_partitions_reader.unwrap()).lines(); + + for partition in partition_method_manual_get_partitions_lines { + let partition = partition.unwrap(); + let partition_size_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_part_size") + .arg(partition.clone()) + .output() + .expect("failed to execute process"); + let partition_fs_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_part_fs") + .arg(partition.clone().replace("mapper/", "")) + .output() + .expect("failed to execute process"); + let partition_size = String::from_utf8(partition_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let partition_button = gtk::CheckButton::builder() + .valign(Align::Center) + .can_focus(false) + .build(); + partition_button.set_group(Some(&null_checkbutton)); + let partition_row = adw::ActionRow::builder() + .activatable_widget(&partition_button) + .title(partition.clone()) + .name(partition.clone()) + .subtitle(String::from_utf8(partition_fs_cli.stdout).expect("Failed read stdout") + &pretty_bytes::converter::convert(partition_size)) + .build(); + partition_row.add_prefix(&partition_button); + partition_button.connect_toggled(clone!(@weak row, @weak listbox, @weak partition_button, @strong manual_drive_mount_array, @strong partition=> move |_| { + let mut manual_drive_mount_array_ref = RefCell::borrow_mut(&manual_drive_mount_array); + if partition_button.is_active() == true { + row.set_partition(partition.clone()); + } else { + let manual_drive_mount_array_ref_index = manual_drive_mount_array_ref.iter().position(|x| *x.partition == partition.clone()).unwrap(); + manual_drive_mount_array_ref.remove(manual_drive_mount_array_ref_index); + } + })); + partition_scroll_child.append(&partition_row); + } let listbox_clone = listbox.clone(); - row.connect_closure( "row-deleted", false, - closure_local!(move |_row: DriveMountRow| { - listbox_clone.remove(&_row) - }), + closure_local!(@strong row => move |row: DriveMountRow| { + listbox_clone.remove(&row) + }) ); // Return row @@ -70,7 +139,10 @@ fn has_unique_elements(iter: T) -> bool } //pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { -pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_partition_array: Rc>>, manual_drive_mountpoint_array: Rc>>, manual_drive_mountopt_array: Rc>>) { +pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: Rc>>) { + + let check_part_unique = Rc::new(RefCell::new(true)); + let partition_method_manual_main_box = gtk::Box::builder() .orientation(Orientation::Vertical) .margin_bottom(15) @@ -145,6 +217,8 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .margin_end(30) .propagate_natural_height(true) .propagate_natural_width(true) + .min_content_height(200) + .min_content_width(200) .hexpand(true) .vexpand(true) .child(&drive_mounts_adw_listbox) @@ -152,8 +226,26 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: let drive_mount_add_button = gtk::Button::builder() .icon_name("list-add") + .vexpand(true) + .hexpand(true) .build(); + let partition_method_manual_error_label = gtk::Label::builder() + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_manual_error_label.add_css_class("small_error_text"); + + let partition_method_manual_warn_label = gtk::Label::builder() + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .build(); + partition_method_manual_warn_label.add_css_class("small_warn_text"); + partition_method_manual_header_box.append(&partition_method_manual_header_text); partition_method_manual_header_box.append(&partition_method_manual_header_icon); partition_method_manual_main_box.append(&partition_method_manual_header_box); @@ -163,6 +255,8 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_main_box.append(&partition_method_manual_gparted_button); drive_mounts_adw_listbox.append(&drive_mount_add_button); partition_method_manual_main_box.append(&drive_mounts_viewport); + partition_method_manual_main_box.append(&partition_method_manual_error_label); + partition_method_manual_main_box.append(&partition_method_manual_warn_label); partition_method_manual_gparted_button.connect_clicked(move |_| { Command::new("gparted") @@ -170,35 +264,100 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .expect("gparted failed to start"); }); - drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox => move |_|{ - drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox)) + drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong check_part_unique => move |_| { + drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &manual_drive_mount_array, &check_part_unique)) })); - let debug_button = gtk::Button::builder() - .label("debug") - .build(); + let (anti_dup_partition_sender, anti_dup_partition_receiver) = async_channel::unbounded(); + let anti_dup_partition_sender = anti_dup_partition_sender.clone(); + // The long running operation runs now in a separate thread + gio::spawn_blocking(move || { + loop { + thread::sleep(Duration::from_millis(100)); + anti_dup_partition_sender + .send_blocking(true) + .expect("The channel needs to be open."); + } + }); - partition_method_manual_main_box.append(&debug_button); + let anti_dup_partition_loop_context = MainContext::default(); + anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong check_part_unique => async move { + while let Ok(_state) = anti_dup_partition_receiver.recv().await { + let mut counter = drive_mounts_adw_listbox.first_child(); - debug_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox => move |_| { - let mut counter = drive_mounts_adw_listbox.first_child(); + let mut manual_drive_mount_array_ref = manual_drive_mount_array.borrow_mut(); - // usage of while loop - manual_drive_mountpoint_array.borrow_mut().clear(); - while let Some(row) = counter { - if row.widget_name() == "DriveMountRow" { - manual_drive_mountpoint_array.borrow_mut().push(row.clone().property("mountpoint")) + // usage of while loop + manual_drive_mount_array_ref.clear(); + while let Some(row) = counter { + if row.widget_name() == "DriveMountRow" { + let row_mount = DriveMount { + partition: row.clone().property("partition"), + mountpoint: row.clone().property("mountpoint"), + mountopt: row.clone().property("mountopt"), + }; + manual_drive_mount_array_ref.push(row_mount); + } + counter = row.next_sibling(); } - counter = row.next_sibling(); - } - if !has_unique_elements(manual_drive_mountpoint_array.borrow_mut().deref_mut()) { - println!("FAK") + let mut counter = drive_mounts_adw_listbox.first_child(); + while let Some(ref row) = counter { + if row.widget_name() == "DriveMountRow" { + let mut counter_scrw = row.property::("partitionscroll").child().unwrap().first_child().unwrap().first_child(); + while let Some(ref row_scrw) = counter_scrw { + if manual_drive_mount_array_ref.iter().any(|e| { + if !e.partition.is_empty() { + row_scrw.widget_name().contains(&e.partition) + } else { + return false + } + }) { + + if *check_part_unique.borrow_mut() == true { + row_scrw.set_sensitive(false) + } else { + row_scrw.set_sensitive(true) + } + } else { + row_scrw.set_sensitive(true) + } + counter_scrw = row_scrw.next_sibling(); + } + } + counter = row.next_sibling(); + } } })); - partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); //return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) } + + +fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition_method_manual_error_label: >k::Label, manual_drive_mount_array: &Rc>>, check_part_unique: &Rc>) { + let mut manual_drive_mount_array_ref = manual_drive_mount_array.borrow_mut(); + if manual_drive_mount_array_ref.len() - manual_drive_mount_array_ref.iter().map(|x| x.mountpoint.as_str()).collect::>().len() > 0 { + partition_method_manual_error_label.set_label("Multiple drives were mounted to the same mountpoint."); + partition_method_manual_error_label.set_visible(true); + } else { + if partition_method_manual_error_label.label() == "Multiple drives were mounted to the same mountpoint." { + partition_method_manual_error_label.set_visible(false); + } + } + + *check_part_unique.borrow_mut()=true; + for mountopts in manual_drive_mount_array_ref.iter().map(|x| x.mountopt.as_str()).collect::>() { + if mountopts.contains("subvol") { + *check_part_unique.borrow_mut()=false + } + } + + if *check_part_unique.borrow_mut() == false { + partition_method_manual_warn_label.set_label("Partition reuse check will be skipped due to subvol usage."); + partition_method_manual_warn_label.set_visible(true); + } else { + partition_method_manual_warn_label.set_visible(false); + } +} \ No newline at end of file diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 41fd4d3..6b8da62 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -31,13 +31,13 @@ use std::cell::RefCell; use std::ops::Deref; use std::rc::Rc; -use crate::install_page; +use crate::{install_page, manual_partitioning}; + +use manual_partitioning::DriveMount; pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { - let manual_drive_partition_array : Rc>> = Default::default(); - let manual_drive_mountpoint_array : Rc>> = Default::default(); - let manual_drive_mountopt_array : Rc>> = Default::default(); + let manual_drive_mount_array : Rc>> = Default::default(); // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() @@ -217,10 +217,9 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , manual_method_button_content_box.append(&manual_method_button_content_image); /// add all pages to partitioning stack - automatic_method_button.connect_clicked(clone!(@strong manual_drive_mountpoint_array => move |_| println!("{}", manual_drive_mountpoint_array.borrow().deref().into_iter().nth(0).unwrap()))); partitioning_stack.add_titled(&partitioning_method_main_box, Some("partition_method_select_page"), "partition_method_select_page"); let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button); - let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, manual_drive_partition_array, manual_drive_mountpoint_array, manual_drive_mountopt_array); + let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, manual_drive_mount_array); // add everything to the main box partitioning_main_box.append(&partitioning_stack); @@ -230,7 +229,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , //// Add the partitioning_main_box as page: partitioning_page, Give it nice title content_stack.add_titled(&partitioning_main_box, Some("partitioning_page"), "Partitioning"); - //automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); + automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); //let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); diff --git a/src/style.css b/src/style.css index ebda6e8..763254a 100644 --- a/src/style.css +++ b/src/style.css @@ -3,6 +3,11 @@ color: red; } +.small_warn_text { + font-size: 14px; + color: orange; +} + .big_error_text { font-size: 32px; color: red; From debd2b7ee080c0f32a745187781fbbfe4147feb8 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 16 Feb 2024 13:41:51 +0300 Subject: [PATCH 17/52] RR: Add Swap --- src/manual_partitioning/mod.rs | 188 +++++++++++++++++++++++++++++++-- 1 file changed, 181 insertions(+), 7 deletions(-) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index f085117..ee769cd 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -49,6 +49,8 @@ use crate::drive_mount_row::DriveMountRow; #[derive(PartialEq)] #[derive(Debug)] +#[derive(Eq)] +#[derive(Hash)] pub struct DriveMount { partition: String, mountpoint: String, @@ -224,6 +226,17 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .child(&drive_mounts_adw_listbox) .build(); + let partition_method_manual_selection_text = gtk::Label::builder() + .label("\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n ") + .halign(gtk::Align::Center) + .hexpand(true) + .margin_top(15) + .margin_bottom(15) + .margin_start(15) + .margin_end(15) + .build(); + partition_method_manual_selection_text.add_css_class("medium_sized_text"); + let drive_mount_add_button = gtk::Button::builder() .icon_name("list-add") .vexpand(true) @@ -248,6 +261,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_header_box.append(&partition_method_manual_header_text); partition_method_manual_header_box.append(&partition_method_manual_header_icon); + partition_method_manual_selection_box.append(&partition_method_manual_selection_text); partition_method_manual_main_box.append(&partition_method_manual_header_box); partition_method_manual_main_box.append(&partition_method_manual_selection_box); partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); @@ -273,7 +287,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: // The long running operation runs now in a separate thread gio::spawn_blocking(move || { loop { - thread::sleep(Duration::from_millis(100)); + thread::sleep(Duration::from_millis(400)); anti_dup_partition_sender .send_blocking(true) .expect("The channel needs to be open."); @@ -327,6 +341,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: } counter = row.next_sibling(); } + partition_err_check(&partition_method_manual_warn_label, &partition_method_manual_error_label, manual_drive_mount_array_ref, &check_part_unique); } })); @@ -336,13 +351,54 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: } -fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition_method_manual_error_label: >k::Label, manual_drive_mount_array: &Rc>>, check_part_unique: &Rc>) { - let mut manual_drive_mount_array_ref = manual_drive_mount_array.borrow_mut(); - if manual_drive_mount_array_ref.len() - manual_drive_mount_array_ref.iter().map(|x| x.mountpoint.as_str()).collect::>().len() > 0 { - partition_method_manual_error_label.set_label("Multiple drives were mounted to the same mountpoint."); - partition_method_manual_error_label.set_visible(true); +fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition_method_manual_error_label: >k::Label, manual_drive_mount_array_ref: RefMut<'_, Vec>, check_part_unique: &Rc>) { + + let mut empty_mountpoint = false; + for mountpoint in manual_drive_mount_array_ref.iter().map(|x| x.mountpoint.as_str()).collect::>() { + if empty_mountpoint == false { + if mountpoint.is_empty() { + empty_mountpoint = true + } + } + } + + let mut empty_partition = false; + for partition in manual_drive_mount_array_ref.iter().map(|x| x.partition.as_str()).collect::>() { + if empty_partition == false { + if partition.is_empty() { + empty_partition = true + } + } + } + + if empty_mountpoint == false { + if &partition_method_manual_error_label.label() == "Some drives don't have a mountpoint configured." { + partition_method_manual_error_label.set_visible(false); + } + if manual_drive_mount_array_ref.len() - manual_drive_mount_array_ref.iter().map(|x| x.mountpoint.as_str()).collect::>().len() > 0 { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label("Multiple drives were mounted to the same mountpoint."); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label() == "Multiple drives were mounted to the same mountpoint." { + partition_method_manual_error_label.set_visible(false); + } + } + } else { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label("Some drives don't have a mountpoint configured."); + partition_method_manual_error_label.set_visible(true); + } + } + + if empty_partition == true { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label("There's a drive row without a partition."); + partition_method_manual_error_label.set_visible(true); + } } else { - if partition_method_manual_error_label.label() == "Multiple drives were mounted to the same mountpoint." { + if partition_method_manual_error_label.label() == "There's a drive row without a partition." { partition_method_manual_error_label.set_visible(false); } } @@ -354,6 +410,124 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition } } + for drivemounts in manual_drive_mount_array_ref.iter().map(|x| x).collect::>() { + if !drivemounts.partition.is_empty() { + let partition_size_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_part_size") + .arg(drivemounts.partition.clone()) + .output() + .expect("failed to execute process"); + let partition_fs_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("get_part_fs") + .arg(drivemounts.partition.replace("mapper/", "")) + .output() + .expect("failed to execute process"); + let partition_size = String::from_utf8(partition_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let partition_fs = String::from_utf8(partition_fs_cli.stdout).expect("Failed to create string").trim().parse::().unwrap(); + if drivemounts.mountpoint == "/boot/efi" { + if partition_size < 500000000.0 { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Small size: The partition mounted to /boot/efi (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 512MBs")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Small size: The partition mounted to /boot/efi (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + if partition_fs != "vfat" { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to /boot/efi (/dev/".to_owned() + &drivemounts.partition + ") Must at be FAT32/vFAT")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to /boot/efi (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + } + if drivemounts.mountpoint == "/boot" { + if partition_size < 1000000000.0 { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Small size: The partition mounted to /boot (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 1000MBs")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Small size: The partition mounted to /boot (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + if partition_fs == "vfat" { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to /boot (/dev/".to_owned() + &drivemounts.partition + ") Cannot be FAT32/vFAT")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to /boot (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + } + if drivemounts.mountpoint == "/" { + if partition_size < 25000000000.0 { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Small size: The partition mounted to / (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 25GBs")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Small size: The partition mounted to / (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + if partition_fs == "vfat" { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to / (/dev/".to_owned() + &drivemounts.partition + ") Cannot be FAT32/vFAT")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to / (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + } + if drivemounts.mountpoint == "/home" { + if partition_size < 10000000000.0 { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Small size: The partition mounted to /home (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 10GBs")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Small size: The partition mounted to /home (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + if partition_fs == "vfat" { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to /home (/dev/".to_owned() + &drivemounts.partition + ") Cannot be FAT32/vFAT")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to /home (/dev/") { + partition_method_manual_error_label.set_visible(false); + } + } + } + + if empty_mountpoint == false && !drivemounts.mountpoint.starts_with("/") && drivemounts.mountpoint != "[SWAP]" { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Bad Mountpoint: ".to_owned() + &drivemounts.mountpoint + " Is not a valid mountpoint")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains(" Is not a valid mountpoint") { + partition_method_manual_error_label.set_visible(false); + } + } + } + } + if *check_part_unique.borrow_mut() == false { partition_method_manual_warn_label.set_label("Partition reuse check will be skipped due to subvol usage."); partition_method_manual_warn_label.set_visible(true); From c9c2e1f854c513107a65984e1068b0449ef90eb9 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 16 Feb 2024 14:34:45 +0300 Subject: [PATCH 18/52] RR: Hook Button sensitivity of manual installer --- src/manual_partitioning/mod.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index ee769cd..651b9b3 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -51,6 +51,7 @@ use crate::drive_mount_row::DriveMountRow; #[derive(Debug)] #[derive(Eq)] #[derive(Hash)] +#[derive(Clone)] pub struct DriveMount { partition: String, mountpoint: String, @@ -295,7 +296,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: }); let anti_dup_partition_loop_context = MainContext::default(); - anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong check_part_unique => async move { + anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move { while let Ok(_state) = anti_dup_partition_receiver.recv().await { let mut counter = drive_mounts_adw_listbox.first_child(); @@ -341,7 +342,17 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: } counter = row.next_sibling(); } + let manual_drive_mount_array_ref_clone = manual_drive_mount_array_ref.clone(); partition_err_check(&partition_method_manual_warn_label, &partition_method_manual_error_label, manual_drive_mount_array_ref, &check_part_unique); + if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() { + if !bottom_next_button.is_sensitive() { + bottom_next_button.set_sensitive(true); + } + } else { + if bottom_next_button.is_sensitive() { + bottom_next_button.set_sensitive(false); + } + } } })); @@ -514,6 +525,18 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition } } } + if drivemounts.mountpoint == "[SWAP]" { + if partition_fs != "linux-swap" { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label.set_label(&("Bad Filesystem: ".to_owned() + &drivemounts.partition + " Is not a swap partition")); + partition_method_manual_error_label.set_visible(true); + } + } else { + if partition_method_manual_error_label.label().contains(" Is not a swap partition") { + partition_method_manual_error_label.set_visible(false); + } + } + } if empty_mountpoint == false && !drivemounts.mountpoint.starts_with("/") && drivemounts.mountpoint != "[SWAP]" { if !partition_method_manual_error_label.is_visible() { From 663bff897a33bb36c1f7db4192409f59723663de Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 16 Feb 2024 16:25:56 +0300 Subject: [PATCH 19/52] RR: Some minor manual partition gui touch ups --- src/manual_partitioning/mod.rs | 53 +++++++++++++++++++++------------- src/partitioning_page/mod.rs | 18 ++++++------ 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 651b9b3..6bcbef2 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -58,7 +58,7 @@ pub struct DriveMount { mountopt: String, } -fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc>>, check_part_unique: &Rc>) -> DriveMountRow { +fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc>>, part_table_array: &Rc>>, check_part_unique: &Rc>) -> DriveMountRow { let partition_scroll_child = gtk::ListBox::builder() .build(); @@ -76,12 +76,8 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc(iter: T) -> bool - where - T: IntoIterator, - T::Item: Eq + Hash, -{ - let mut uniq = HashSet::new(); - iter.into_iter().all(move |x| uniq.insert(x)) -} - //pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: Rc>>) { + let part_table_array: Rc>> = Default::default(); + let check_part_unique = Rc::new(RefCell::new(true)); let partition_method_manual_main_box = gtk::Box::builder() @@ -228,7 +217,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .build(); let partition_method_manual_selection_text = gtk::Label::builder() - .label("\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n ") + .label("\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n ") .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -238,6 +227,12 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .build(); partition_method_manual_selection_text.add_css_class("medium_sized_text"); + let partition_refresh_button = gtk::Button::builder() + .label("Refresh Partition Table") + .halign(gtk::Align::End) + .build(); + partition_refresh_button.add_css_class("destructive-action"); + let drive_mount_add_button = gtk::Button::builder() .icon_name("list-add") .vexpand(true) @@ -263,6 +258,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_header_box.append(&partition_method_manual_header_text); partition_method_manual_header_box.append(&partition_method_manual_header_icon); partition_method_manual_selection_box.append(&partition_method_manual_selection_text); + partition_method_manual_selection_box.append(&partition_refresh_button); partition_method_manual_main_box.append(&partition_method_manual_header_box); partition_method_manual_main_box.append(&partition_method_manual_selection_box); partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); @@ -273,14 +269,31 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_main_box.append(&partition_method_manual_error_label); partition_method_manual_main_box.append(&partition_method_manual_warn_label); + partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array => move |_| { + let mut counter = drive_mounts_adw_listbox.first_child(); + while let Some(ref row) = counter { + if row.widget_name() == "DriveMountRow" { + drive_mounts_adw_listbox.remove(row); + } + 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 mut part_table_array_ref = part_table_array.borrow_mut(); + part_table_array_ref.clear(); + for partition in partition_method_manual_get_partitions_lines { + part_table_array_ref.push(partition.unwrap()); + } + })); + partition_refresh_button.emit_clicked(); + partition_method_manual_gparted_button.connect_clicked(move |_| { Command::new("gparted") .spawn() .expect("gparted failed to start"); }); - drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong check_part_unique => move |_| { - drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &manual_drive_mount_array, &check_part_unique)) + drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong part_table_array, @strong check_part_unique => move |_| { + drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &manual_drive_mount_array, &part_table_array,&check_part_unique)) })); let (anti_dup_partition_sender, anti_dup_partition_receiver) = async_channel::unbounded(); diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 6b8da62..f18bd2b 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -232,9 +232,9 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); - //let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); + let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); - //let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); + let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); //let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); @@ -263,13 +263,13 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); } if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) { - //fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - //let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); - //if automatic_luks_result.is_empty() { - // // - //} else { - // fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); - //} + fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); + let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); + if automatic_luks_result.is_empty() { + // + } else { + fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); + } install_page(&done_main_box, &install_main_box, &content_stack, &window); content_stack.set_visible_child_name("install_page"); } else { From 948be55a1854f628e3222242b2cc63f2772322bf Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Fri, 16 Feb 2024 18:16:45 +0300 Subject: [PATCH 20/52] RR: hook partition UI to pikainstall linker --- Cargo.lock | 40 ++++++++++++++++++++++++++++++---- Cargo.toml | 3 +++ src/install_page/mod.rs | 38 +++++++++++++++++--------------- src/manual_partitioning/mod.rs | 28 ++++++++++++++---------- src/partitioning_page/mod.rs | 32 +++++++++++++-------------- 5 files changed, 92 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8d1907..3cae989 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -373,6 +373,12 @@ dependencies = [ "system-deps", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "gobject-sys" version = "0.18.0" @@ -540,6 +546,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + [[package]] name = "libadwaita" version = "0.5.3" @@ -648,9 +660,12 @@ dependencies = [ "duct", "fragile", "glib", + "glob", "gtk4", "libadwaita", "pretty-bytes", + "serde", + "serde_json", "time", "zoha-vte4", ] @@ -760,6 +775,12 @@ dependencies = [ "semver", ] +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + [[package]] name = "semver" version = "1.0.21" @@ -768,24 +789,35 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", "syn 2.0.48", ] +[[package]] +name = "serde_json" +version = "1.0.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.5" diff --git a/Cargo.toml b/Cargo.toml index 30f8539..bec32e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,6 @@ gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] } pretty-bytes = "0.2.2" time = "0.3.31" vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] } +glob = "0.3.1" +serde_json = "1.0.113" +serde = { version = "1.0", features = ["derive"] } diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index c865e38..f9178e3 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -1,3 +1,4 @@ +use std::cell::RefCell; // Use libraries /// Use all gtk4 libraries (gtk4 -> gtk because cargo) /// Use all libadwaita libraries (libadwaita -> adw because cargo) @@ -18,8 +19,13 @@ use pretty_bytes::converter::convert; use std::fs; use std::path::Path; +use std::rc::Rc; -pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { +use serde::*; +use serde_json::*; +use crate::manual_partitioning::DriveMount; + +pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow, manual_drive_mount_array: &Rc>>) { // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() @@ -117,18 +123,23 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte .build(); install_confirm_detail_keyboard.add_css_class("property"); - let install_confirm_detail_target = adw::ActionRow::builder() - .title("Install Target:") - .build(); - if Path::new("/tmp/pika-installer-gtk4-target-manual.txt").exists() { - install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-manual.txt").expect("Unable to read file")); + //install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-manual.txt").expect("Unable to read file")); + install_confirm_details_boxed_list.append(&install_confirm_detail_language); + install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); + install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); + for partitions in manual_drive_mount_array.borrow_mut().iter() { + let confirm_row = adw::ActionRow::builder() + .title("/dev/".to_owned() + &partitions.partition + " mounted on " + &partitions.mountpoint) + .build(); + install_confirm_details_boxed_list.append(&confirm_row); + } } else { + let install_confirm_detail_target = adw::ActionRow::builder() + .title("Install Target:") + .build(); install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file")); - } - install_confirm_detail_target.add_css_class("property"); - - if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { + install_confirm_detail_target.add_css_class("property"); let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file"); let target_size_cli = Command::new("sudo") .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") @@ -188,13 +199,6 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte install_confirm_details_boxed_list.append(&install_confirm_p2); install_confirm_details_boxed_list.append(&install_confirm_p3); install_confirm_details_boxed_list.append(&install_confirm_p4); - } else { - // / 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); - install_confirm_details_boxed_list.append(&install_confirm_detail_timezone); - install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); - install_confirm_details_boxed_list.append(&install_confirm_detail_target); } let install_confirm_button = gtk::Button::builder() diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 6bcbef2..2277583 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -46,16 +46,18 @@ use gtk::Orientation::Vertical; use pretty_bytes::converter::convert; use crate::drive_mount_row::DriveMountRow; +use serde::*; #[derive(PartialEq)] #[derive(Debug)] #[derive(Eq)] #[derive(Hash)] #[derive(Clone)] +#[derive(Serialize, Deserialize)] pub struct DriveMount { - partition: String, - mountpoint: String, - mountopt: String, + pub partition: String, + pub mountpoint: String, + pub mountopt: String, } fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc>>, part_table_array: &Rc>>, check_part_unique: &Rc>) -> DriveMountRow { @@ -129,7 +131,7 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { -pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: Rc>>) { +pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: &Rc>>) { let part_table_array: Rc>> = Default::default(); @@ -309,7 +311,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: }); let anti_dup_partition_loop_context = MainContext::default(); - anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move { + anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @weak partitioning_stack, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move { while let Ok(_state) = anti_dup_partition_receiver.recv().await { let mut counter = drive_mounts_adw_listbox.first_child(); @@ -357,13 +359,15 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: } let manual_drive_mount_array_ref_clone = manual_drive_mount_array_ref.clone(); partition_err_check(&partition_method_manual_warn_label, &partition_method_manual_error_label, manual_drive_mount_array_ref, &check_part_unique); - if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() { - if !bottom_next_button.is_sensitive() { - bottom_next_button.set_sensitive(true); - } - } else { - if bottom_next_button.is_sensitive() { - bottom_next_button.set_sensitive(false); + if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_manual_page".into())) { + if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() { + if !bottom_next_button.is_sensitive() { + bottom_next_button.set_sensitive(true); + } + } else { + if bottom_next_button.is_sensitive() { + bottom_next_button.set_sensitive(false); + } } } } diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index f18bd2b..822b29c 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -8,6 +8,7 @@ use adw::*; use glib::*; use gdk::Display; use gtk::subclass::layout_child; +use glob::glob; use crate::automatic_partitioning::automatic_partitioning; use crate::manual_partitioning::manual_partitioning; @@ -219,7 +220,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , /// add all pages to partitioning stack partitioning_stack.add_titled(&partitioning_method_main_box, Some("partition_method_select_page"), "partition_method_select_page"); let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button); - let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, manual_drive_mount_array); + let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, &manual_drive_mount_array); // add everything to the main box partitioning_main_box.append(&partitioning_stack); @@ -236,10 +237,6 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); - //let partition_method_manual_target_buffer_clone = partitioning_page_manual_partitioning.0.clone(); - - //let partition_method_manual_luks_buffer_clone = partitioning_page_manual_partitioning.1.clone(); - bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("install_page") })); @@ -249,7 +246,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , bottom_next_button.set_sensitive(false); })); - bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| { + bottom_next_button.connect_clicked(clone!(@strong manual_drive_mount_array, @weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| { if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-target-auto.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-auto.txt"); } @@ -262,6 +259,10 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); } + for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") { + let partition_file = partition_file.unwrap(); + fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap()); + } if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) { fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); @@ -270,18 +271,17 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , } else { fs::write("/tmp/pika-installer-gtk4-target-automatic-luks.txt", automatic_luks_result); } - install_page(&done_main_box, &install_main_box, &content_stack, &window); + install_page(&done_main_box, &install_main_box, &content_stack, &window, &manual_drive_mount_array); content_stack.set_visible_child_name("install_page"); } else { - //fs::write("/tmp/pika-installer-gtk4-target-manual.txt", partition_method_manual_target_buffer_clone.text(&partition_method_manual_target_buffer_clone.bounds().0, &partition_method_manual_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); - //partition_method_manual_luks_buffer_clone.set_text(&partitioning_page_manual_partitioning.2.text().to_string()); - //let manual_luks_result = partition_method_manual_luks_buffer_clone.text(&partition_method_manual_luks_buffer_clone.bounds().0, &partition_method_manual_luks_buffer_clone.bounds().1, true).to_string(); - //if manual_luks_result.is_empty() { - // // - //} else { - // fs::write("/tmp/pika-installer-gtk4-target-manual-luks.txt", manual_luks_result); - //} - install_page(&done_main_box, &install_main_box, &content_stack, &window); + fs::write("/tmp/pika-installer-gtk4-target-manual.txt", "").expect("Unable to write file"); + let mut iter_count = 0; + iter_count = 0; + for partitions in manual_drive_mount_array.borrow_mut().iter() { + fs::write("/tmp/pika-installer-gtk4-target-manual-p".to_owned() + &iter_count.to_string() + ".json", serde_json::to_string(partitions).unwrap()).expect("Unable to write file"); + iter_count += 1; + } + install_page(&done_main_box, &install_main_box, &content_stack, &window, &manual_drive_mount_array); content_stack.set_visible_child_name("install_page"); } })); From 7aeabf54aa6764fd96e55b9b143a0c5a4ef217e0 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 00:21:09 +0300 Subject: [PATCH 21/52] RR: broken crypt checker --- data/scripts/partition-utility.sh | 10 +- src/automatic_partitioning/mod.rs | 61 +++-- src/build_ui.rs | 37 ++- src/done_page/mod.rs | 25 +- src/drive_mount_row/imp.rs | 42 +--- src/drive_mount_row/mod.rs | 7 +- src/efi_error_page/mod.rs | 13 +- src/eula_page/mod.rs | 28 +-- src/install_page/mod.rs | 349 +++++++++++++++++++++------- src/keyboard_page/mod.rs | 42 ++-- src/language_page/mod.rs | 31 ++- src/main.rs | 40 ++-- src/manual_partitioning/mod.rs | 367 ++++++++++++++++++++---------- src/partitioning_page/mod.rs | 66 +++--- src/save_window_size/mod.rs | 9 +- src/timezone_page/mod.rs | 29 ++- src/welcome_page/mod.rs | 12 +- 17 files changed, 749 insertions(+), 419 deletions(-) diff --git a/data/scripts/partition-utility.sh b/data/scripts/partition-utility.sh index 658bf5c..28b48da 100755 --- a/data/scripts/partition-utility.sh +++ b/data/scripts/partition-utility.sh @@ -12,12 +12,14 @@ then lsblk -b --output SIZE -n -d /dev/"$2" fi -if [[ "$1" = "check_home_encryption" ]] +if [[ "$1" = "has_encryption" ]] then - if blkid -o value -s TYPE $(lsblk -sJp | jq -r --arg dsk "$(df -P -h -T "$2/home" | awk 'END{print $1}')" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name') | grep -i luks > /dev/null 2>&1 + if blkid -o value -s TYPE $(lsblk -sJp | jq -r --arg dsk /dev/"$2" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name') | grep -i luks > /dev/null 2>&1 then + echo "$2 has encryption" exit 0 else + echo "$2 is unencrypted" exit 1 fi fi @@ -113,9 +115,9 @@ then fi fi -if [[ "$1" = "check_home_luks_passwd" ]] +if [[ "$1" = "test_luks_passwd" ]] then - if printf "$3" | cryptsetup luksOpen --test-passphrase UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk "$(df -P -h -T "$2"/home | awk 'END{print $1}')" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" + if printf "$3" | cryptsetup luksOpen --test-passphrase UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$2" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" then exit 0 else diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index 1013cb7..52356bf 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -1,28 +1,31 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; 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::env; -use pretty_bytes::converter::convert; use std::thread; use std::time::*; use std::fs; use std::path::Path; -pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer) { +pub fn automatic_partitioning( + partitioning_stack: >k::Stack, + bottom_next_button: >k::Button, +) -> (gtk::TextBuffer, gtk::TextBuffer) { let partition_method_automatic_main_box = gtk::Box::builder() .orientation(Orientation::Vertical) .margin_bottom(15) @@ -79,18 +82,17 @@ pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_butto .title("No disk selected for selection") .build(); - let null_checkbutton = gtk::CheckButton::builder() - .build(); + let null_checkbutton = gtk::CheckButton::builder().build(); - let devices_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); + let devices_selection_expander_row_viewport = + gtk::ScrolledWindow::builder().height_request(200).build(); let devices_selection_expander_row_viewport_box = gtk::Box::builder() .orientation(Orientation::Vertical) .build(); - devices_selection_expander_row_viewport.set_child(Some(&devices_selection_expander_row_viewport_box)); + devices_selection_expander_row_viewport + .set_child(Some(&devices_selection_expander_row_viewport_box)); let devices_selection_expander_row_viewport_listbox = gtk::ListBox::builder() .selection_mode(SelectionMode::None) @@ -111,7 +113,11 @@ pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_butto .stdout(Stdio::piped()) .spawn() .unwrap_or_else(|e| panic!("failed {}", e)); - let partition_method_automatic_get_devices_reader = BufReader::new(partition_method_automatic_get_devices_cli.stdout.expect("could not get stdout")); + let partition_method_automatic_get_devices_reader = BufReader::new( + partition_method_automatic_get_devices_cli + .stdout + .expect("could not get stdout"), + ); let partition_method_automatic_disk_error_label = gtk::Label::builder() .label("No Disk specified.") @@ -156,11 +162,9 @@ pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_butto .sensitive(false) .build(); - let partition_method_automatic_target_buffer = gtk::TextBuffer::builder() - .build(); + let partition_method_automatic_target_buffer = gtk::TextBuffer::builder().build(); - let partition_method_automatic_luks_buffer = gtk::TextBuffer::builder() - .build(); + let partition_method_automatic_luks_buffer = gtk::TextBuffer::builder().build(); for device in partition_method_automatic_get_devices_reader.lines() { let device = device.unwrap(); @@ -170,7 +174,11 @@ pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_butto .arg(device.clone()) .output() .expect("failed to execute process"); - let device_size = String::from_utf8(device_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let device_size = String::from_utf8(device_size_cli.stdout) + .expect("Failed to create float") + .trim() + .parse::() + .unwrap(); let device_button = gtk::CheckButton::builder() .valign(Align::Center) .can_focus(false) @@ -273,7 +281,14 @@ pub fn automatic_partitioning(partitioning_stack: >k::Stack, bottom_next_butto partition_method_automatic_main_box.append(&partition_method_automatic_luks_error_label); partition_method_automatic_main_box.append(&partition_method_automatic_disk_error_label); - partitioning_stack.add_titled(&partition_method_automatic_main_box, Some("partition_method_automatic_page"), "partition_method_automatic_page"); + partitioning_stack.add_titled( + &partition_method_automatic_main_box, + Some("partition_method_automatic_page"), + "partition_method_automatic_page", + ); - return(partition_method_automatic_target_buffer, partition_method_automatic_luks_buffer) -} \ No newline at end of file + return ( + partition_method_automatic_target_buffer, + partition_method_automatic_luks_buffer, + ); +} diff --git a/src/build_ui.rs b/src/build_ui.rs index 67e9844..4451e18 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -1,14 +1,13 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; - +use gtk::*; use std::path::Path; @@ -30,13 +29,11 @@ use crate::partitioning_page::partitioning_page; // build ui function linked to app startup above pub fn build_ui(app: &adw::Application) { - // setup glib gtk::glib::set_prgname(Some("PikaOS Installer")); glib::set_application_name("PikaOS Installer"); let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4"); - // Widget Bank /// Create A box @@ -44,10 +41,9 @@ pub fn build_ui(app: &adw::Application) { // that puts items vertically .orientation(Orientation::Vertical) .build(); - + /// Add adwaita title box - let window_title_bar = adw::HeaderBar::builder() - .build(); + let window_title_bar = adw::HeaderBar::builder().build(); /// Add page Stack containing all primary contents let content_stack = gtk::Stack::builder() @@ -55,7 +51,7 @@ pub fn build_ui(app: &adw::Application) { .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) @@ -65,17 +61,16 @@ pub fn build_ui(app: &adw::Application) { .margin_end(15) .sensitive(false) .build(); - + // / _main_box appends //// Add the a title bar to the _main_box - _main_box.append(&window_title_bar); + _main_box.append(&window_title_bar); //// Add the step indicator to _main_box _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 @@ -100,16 +95,16 @@ pub fn build_ui(app: &adw::Application) { .startup_id("pika-installer-gtk4") // build the window .build(); - + // Add welcome_page.rs as a page for content_stack if Path::new("/sys/firmware/efi/efivars").exists() { welcome_page(&window, &content_stack); } else { efi_error_page(&window, &content_stack); } - + // bottom_box moved per page - // if content_stack visible child becomes NOT content_stack, show the buttom box + // if content_stack visible child becomes NOT content_stack, show the buttom box //content_stack.connect_visible_child_notify(clone!(@weak bottom_box => move |content_stack| { // let state = content_stack.visible_child_name().as_deref() != Some("welcome_page"); // bottom_box.set_visible(state); @@ -137,7 +132,7 @@ pub fn build_ui(app: &adw::Application) { .build(); // Add partitioning_page.rs as a page for content_stack - partitioning_page(&done_main_box, &install_main_box, &content_stack, &window); + partitioning_page(&done_main_box, &install_main_box, &content_stack, &window); //// Add the install_main_box as page: install_page, Give it nice title content_stack.add_titled(&install_main_box, Some("install_page"), "Installation"); @@ -149,12 +144,12 @@ pub fn build_ui(app: &adw::Application) { if glib_settings.boolean("is-maximized") == true { 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())); diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index e944520..ad80718 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -1,19 +1,23 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; 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: >k::Box, content_stack: >k::Stack, window: &adw::ApplicationWindow) { +pub fn done_page( + done_main_box: >k::Box, + content_stack: >k::Stack, + window: &adw::ApplicationWindow, +) { // the header box for the installation_successful page let done_header_box = gtk::Box::builder() .orientation(Orientation::Horizontal) @@ -43,7 +47,6 @@ pub fn done_page(done_main_box: >k::Box, content_stack: >k::Stack, window: & .margin_end(15) .build(); - // Successful install yard // the header box for the installation_successful page let installation_successful_main_box = gtk::Box::builder() @@ -126,7 +129,8 @@ pub fn done_page(done_main_box: >k::Box, content_stack: >k::Stack, window: & //// Add the installation_successful selection/page content box to installation_successful main box installation_successful_main_box.append(&installation_successful_selection_box); - installation_successful_exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); + installation_successful_exit_button + .connect_clicked(clone!(@weak window => move |_| window.close())); installation_successful_reboot_button.connect_clicked(move |_| { Command::new("reboot") .spawn() @@ -215,7 +219,8 @@ pub fn done_page(done_main_box: >k::Box, content_stack: >k::Stack, window: & //// Add the installation_failed selection/page content box to installation_failed main box installation_failed_main_box.append(&installation_failed_selection_box); - installation_failed_exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); + installation_failed_exit_button + .connect_clicked(clone!(@weak window => move |_| window.close())); installation_failed_logs_button.connect_clicked(move |_| { Command::new("xdg-open") .arg("/tmp/pika-installer-gtk4-log") @@ -239,4 +244,4 @@ pub fn done_page(done_main_box: >k::Box, content_stack: >k::Stack, window: & } else { done_main_box.append(&installation_failed_main_box) } -} \ No newline at end of file +} diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 9b651da..8a4592f 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -1,34 +1,12 @@ use std::{ - cell::{ - Cell, - RefCell, - }, - sync::{ - OnceLock, - }, - rc::{ - Rc, - }, -}; - -use glib::{ - Properties, - subclass::Signal, - clone, -}; -use gtk::{ - glib, - prelude::*, - subclass::prelude::*, - *, - Orientation::Horizontal, -}; -use adw::{ - prelude::*, - subclass::prelude::*, - *, + cell::{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, *}; // ANCHOR: custom_button // Object holding the state @@ -60,10 +38,7 @@ impl ObjectSubclass for DriveMountRow { impl ObjectImpl for DriveMountRow { fn signals() -> &'static [Signal] { static SIGNALS: OnceLock> = OnceLock::new(); - SIGNALS.get_or_init(|| { - vec![Signal::builder("row-deleted") - .build()] - }) + SIGNALS.get_or_init(|| vec![Signal::builder("row-deleted").build()]) } fn constructed(&self) { self.parent_constructed(); @@ -142,7 +117,6 @@ impl ObjectImpl for DriveMountRow { action_row_content_box.append(&partition_row_delete_button); - obj.add_prefix(&action_row_content_box); // Bind label to number @@ -183,4 +157,4 @@ impl ActionRowImpl for DriveMountRow { // let incremented_number = self.obj().number() + 1; // self.obj().set_number(incremented_number); //} -} \ No newline at end of file +} diff --git a/src/drive_mount_row/mod.rs b/src/drive_mount_row/mod.rs index 9397c2c..15a2bec 100644 --- a/src/drive_mount_row/mod.rs +++ b/src/drive_mount_row/mod.rs @@ -10,12 +10,13 @@ glib::wrapper! { } impl DriveMountRow { - pub fn new() -> Self { Object::builder().build() } pub fn new_with_scroll(partitions_scroll: >k::ScrolledWindow) -> Self { - Object::builder().property("partitionscroll", partitions_scroll).build() + Object::builder() + .property("partitionscroll", partitions_scroll) + .build() } } // ANCHOR_END: mod @@ -24,4 +25,4 @@ impl Default for DriveMountRow { fn default() -> Self { Self::new() } -} \ No newline at end of file +} diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index a1828d4..f864b22 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -1,13 +1,13 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; +use gtk::*; pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the efi_error page @@ -53,7 +53,6 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stac .margin_end(15) .build(); - let efi_error_text = gtk::Label::builder() .vexpand(true) .hexpand(true) @@ -107,4 +106,4 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stac content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome"); kill_me_button.connect_clicked(clone!(@weak window => move |_| window.close())); -} \ No newline at end of file +} diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 8d5d834..1f3560e 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -1,13 +1,13 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; +use gtk::*; use std::io::BufRead; use std::io::BufReader; @@ -16,7 +16,6 @@ use std::process::Stdio; use std::time::Instant; pub fn eula_page(content_stack: >k::Stack) { - // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() .orientation(Orientation::Horizontal) @@ -177,13 +176,15 @@ pub fn eula_page(content_stack: >k::Stack) { //// Add the eula_main_box as page: eula_page, Give it nice title content_stack.add_titled(&eula_main_box, Some("eula_page"), "EULA"); - eula_accept_checkbutton.connect_toggled(clone!(@weak eula_accept_checkbutton, @weak bottom_next_button => move |_| { - if eula_accept_checkbutton.is_active() == true { - bottom_next_button.set_sensitive(true); - } else { - bottom_next_button.set_sensitive(false) - } - })); + eula_accept_checkbutton.connect_toggled( + clone!(@weak eula_accept_checkbutton, @weak bottom_next_button => move |_| { + if eula_accept_checkbutton.is_active() == true { + bottom_next_button.set_sensitive(true); + } else { + bottom_next_button.set_sensitive(false) + } + }), + ); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("timezone_page") @@ -191,5 +192,4 @@ pub fn eula_page(content_stack: >k::Stack) { bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("language_page") })); - } diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index f9178e3..7bf5cb4 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -1,31 +1,165 @@ 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; +use gtk::*; use vte::prelude::*; use vte::*; use crate::done_page::done_page; -use std::process::Command; use pretty_bytes::converter::convert; +use std::process::Command; use std::fs; use std::path::Path; use std::rc::Rc; +use crate::manual_partitioning::DriveMount; use serde::*; use serde_json::*; -use crate::manual_partitioning::DriveMount; -pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow, manual_drive_mount_array: &Rc>>) { +#[derive(PartialEq, Debug, Eq, Hash, Clone, Serialize, Deserialize)] +struct CrypttabEntry { + partition: String, + password: String, +} + +pub fn install_page( + done_main_box: >k::Box, + install_main_box: >k::Box, + content_stack: >k::Stack, + window: &adw::ApplicationWindow, + manual_drive_mount_array: &Rc>>, +) { + let mut iter_count = 0; + iter_count = 0; + let mut unlocked_array: Vec = Default::default(); + for partitions in manual_drive_mount_array.borrow_mut().iter() { + let new_crypt = if partitions.mountpoint != "/" + && !unlocked_array.contains(&partitions.partition) + && Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("has_encryption") + .arg(&partitions.partition) + .output() + .expect("failed to execute process") + .status + .success() + { + let crypttab_password_listbox = gtk::ListBox::builder() + .margin_top(10) + .margin_bottom(10) + .margin_start(10) + .margin_end(10) + .build(); + crypttab_password_listbox.add_css_class("boxed-list"); + let crypttab_password = adw::PasswordEntryRow::builder() + .title("LUKS Password for ".to_owned() + &partitions.partition) + .build(); + crypttab_password_listbox.append(&crypttab_password); + let crypttab_dialog = adw::MessageDialog::builder() + .transient_for(window) + .hide_on_close(true) + .extra_child(&crypttab_password_listbox) + .width_request(400) + .height_request(200) + .heading( + "How should ".to_owned() + + &partitions.partition + + " be added to /etc/crypttab?", + ) + .build(); + crypttab_dialog.add_response("crypttab_dialog_boot", "Unlock on boot manually"); + crypttab_dialog + .add_response("crypttab_dialog_auto", "Automatic Unlock with root unlock"); + crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false); + crypttab_password.connect_changed(clone!(@weak crypttab_password, @strong partitions, @weak crypttab_dialog => move |_| { + let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); + let luks_manual_password_sender = luks_manual_password_sender.clone(); + let luks_password = crypttab_password.text(); + + gio::spawn_blocking(clone!(@strong crypttab_password, @strong partitions => move || { + let luks_check_cli = Command::new("sudo") + .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") + .arg("test_luks_passwd") + .arg(&partitions.partition) + .arg(&luks_password) + .output() + .expect("failed to execute process"); + if luks_check_cli.status.success() { + println!("fuck"); + luks_manual_password_sender + .send_blocking(false) + .expect("The channel needs to be open."); + } else { + println!("shit"); + luks_manual_password_sender + .send_blocking(true) + .expect("The channel needs to be open."); + } + })); + let luks_manual_password_main_context = MainContext::default(); + // The main loop executes the asynchronous block + luks_manual_password_main_context.spawn_local(clone!(@weak crypttab_dialog => async move { + while let Ok(state) = luks_manual_password_receiver.recv().await { + crypttab_dialog.set_response_enabled("crypttab_dialog_auto", !state); + } + })); + })); + + let partition_final = partitions.partition.clone(); + let partition_final2 = partitions.partition.clone(); + crypttab_dialog.choose(None::<&gio::Cancellable>, move |choice| { + if choice == "crypttab_dialog_auto" { + let crypttab_entry = CrypttabEntry { + partition: partition_final2, + password: (&crypttab_password.text()).to_string(), + }; + fs::write( + "/tmp/pika-installer-gtk4-target-manual-luks-p".to_owned() + + &iter_count.to_string() + + ".json", + serde_json::to_string(&crypttab_entry).unwrap(), + ) + .expect("Unable to write file"); + } else { + let crypttab_entry = CrypttabEntry { + partition: partition_final2, + password: (&"").to_string(), + }; + fs::write( + "/tmp/pika-installer-gtk4-target-manual-luks-p".to_owned() + + &iter_count.to_string() + + ".json", + serde_json::to_string(&crypttab_entry).unwrap(), + ) + .expect("Unable to write file"); + } + }); + partition_final + } else { + String::from("") + }; + fs::write( + "/tmp/pika-installer-gtk4-target-manual-p".to_owned() + + &iter_count.to_string() + + ".json", + serde_json::to_string(partitions).unwrap(), + ) + .expect("Unable to write file"); + if !new_crypt.is_empty() { + unlocked_array.push(new_crypt); + } + dbg!(&unlocked_array); + iter_count += 1; + } // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() @@ -107,19 +241,27 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte let install_confirm_detail_language = adw::ActionRow::builder() .title("Language:") - .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-lang.txt").expect("Unable to read file")) + .subtitle( + fs::read_to_string("/tmp/pika-installer-gtk4-lang.txt").expect("Unable to read file"), + ) .build(); install_confirm_detail_language.add_css_class("property"); let install_confirm_detail_timezone = adw::ActionRow::builder() .title("Time zone:") - .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-timezone.txt").expect("Unable to read file")) + .subtitle( + fs::read_to_string("/tmp/pika-installer-gtk4-timezone.txt") + .expect("Unable to read file"), + ) .build(); install_confirm_detail_timezone.add_css_class("property"); let install_confirm_detail_keyboard = adw::ActionRow::builder() .title("Keyboard layout:") - .subtitle(fs::read_to_string("/tmp/pika-installer-gtk4-keyboard.txt").expect("Unable to read file")) + .subtitle( + fs::read_to_string("/tmp/pika-installer-gtk4-keyboard.txt") + .expect("Unable to read file"), + ) .build(); install_confirm_detail_keyboard.add_css_class("property"); @@ -130,65 +272,97 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte install_confirm_details_boxed_list.append(&install_confirm_detail_keyboard); for partitions in manual_drive_mount_array.borrow_mut().iter() { let confirm_row = adw::ActionRow::builder() - .title("/dev/".to_owned() + &partitions.partition + " mounted on " + &partitions.mountpoint) + .title( + "/dev/".to_owned() + + &partitions.partition + + " mounted on " + + &partitions.mountpoint, + ) .build(); install_confirm_details_boxed_list.append(&confirm_row); } } else { - let install_confirm_detail_target = adw::ActionRow::builder() - .title("Install Target:") - .build(); - install_confirm_detail_target.set_subtitle(&fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file")); + let install_confirm_detail_target = + adw::ActionRow::builder().title("Install Target:").build(); + install_confirm_detail_target.set_subtitle( + &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt") + .expect("Unable to read file"), + ); install_confirm_detail_target.add_css_class("property"); - let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt").expect("Unable to read file"); + let target_block_device = &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt") + .expect("Unable to read file"); let target_size_cli = Command::new("sudo") .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") .arg("get_block_size") .arg(target_block_device) .output() .expect("failed to execute process"); - let target_size = String::from_utf8(target_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); + let target_size = String::from_utf8(target_size_cli.stdout) + .expect("Failed to create float") + .trim() + .parse::() + .unwrap(); 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); 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"); + 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; - fs::write("/tmp/pika-installer-p3-size.txt", target_p3_sector.to_string()).expect("Unable to write file"); + 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(); if target_block_device.contains("nvme") { - p1_row_text = "512 MB ".to_owned() + target_block_device + "p1" + " as fat32" + " on /boot/efi"; - 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) + " " + target_block_device + "p3" + " as btrfs" + " on /"; - p4_row_text = pretty_bytes::converter::convert(target_p4_size) + " " + target_block_device + "p4" + " as btrfs" + " on /home"; + p1_row_text = + "512 MB ".to_owned() + target_block_device + "p1" + " as fat32" + " on /boot/efi"; + 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) + + " " + + target_block_device + + "p3" + + " as btrfs" + + " on /"; + p4_row_text = pretty_bytes::converter::convert(target_p4_size) + + " " + + target_block_device + + "p4" + + " as btrfs" + + " on /home"; } else { - p1_row_text = "512 MB ".to_owned() + target_block_device + "1" + " as fat32" + " on /boot/efi"; + 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) + " " + target_block_device + "3" + " as btrfs" + " on /"; - p4_row_text = pretty_bytes::converter::convert(target_p4_size) + " " + target_block_device + "4" + " as btrfs" + " on /home"; + 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) + + " " + + 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); @@ -241,7 +415,6 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte install_confirm_box.append(&bottom_box); /// - let install_progress_box = gtk::Box::builder() .orientation(Orientation::Vertical) .build(); @@ -304,14 +477,26 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte progress_bar_box.append(&install_progress_bar); progress_bar_box.append(&progress_log_button); - install_progress_log_stack.add_titled(&placeholder_icon, Some("slideshow_page"), "slideshow_page"); - install_progress_log_stack.add_titled(&install_progress_log_terminal, Some("terminal_log_page"), "terminal_log_page"); + install_progress_log_stack.add_titled( + &placeholder_icon, + Some("slideshow_page"), + "slideshow_page", + ); + install_progress_log_stack.add_titled( + &install_progress_log_terminal, + Some("terminal_log_page"), + "terminal_log_page", + ); install_progress_box.append(&install_progress_log_stack); install_progress_box.append(&progress_bar_box); install_nested_stack.add_titled(&install_confirm_box, Some("confirm_page"), "confirm_page"); - install_nested_stack.add_titled(&install_progress_box, Some("progress_page"), "progress_page"); + install_nested_stack.add_titled( + &install_progress_box, + Some("progress_page"), + "progress_page", + ); // @@ -330,13 +515,21 @@ pub fn install_page(done_main_box: >k::Box, install_main_box: >k::Box ,conte } })); - bottom_back_button.connect_clicked(clone!(@weak content_stack, @weak install_main_box, @weak install_nested_stack => move |_| { - content_stack.set_visible_child_name("partitioning_page"); - install_main_box.remove(&install_nested_stack) - })); + bottom_back_button.connect_clicked( + clone!(@weak content_stack, @weak install_main_box, @weak install_nested_stack => move |_| { + content_stack.set_visible_child_name("partitioning_page"); + install_main_box.remove(&install_nested_stack) + }), + ); } -fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress_bar: >k::ProgressBar, done_main_box: >k::Box, content_stack: >k::Stack, window: &adw::ApplicationWindow) { +fn begin_install( + install_progress_log_terminal: &vte::Terminal, + install_progress_bar: >k::ProgressBar, + done_main_box: >k::Box, + content_stack: >k::Stack, + window: &adw::ApplicationWindow, +) { // SPAWN TERMINAL WITH PIKAINSTALL PROCESS install_progress_log_terminal.spawn_async( PtyFlags::DEFAULT, @@ -347,12 +540,12 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress || {}, -1, None::<&gio::Cancellable>, - move |result| { - match result { - Ok(_) => { eprintln!("could not spawn terminal")} - Err(err) => { - eprintln!("could not spawn terminal: {}", err); - } + move |result| match result { + Ok(_) => { + eprintln!("could not spawn terminal") + } + Err(err) => { + eprintln!("could not spawn terminal: {}", err); } }, ); @@ -367,7 +560,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress parting_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -394,7 +587,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress image_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -421,7 +614,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress flag1_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -448,7 +641,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress flag2_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -475,7 +668,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress crypt_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -502,7 +695,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress lang_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -529,7 +722,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress boot_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -556,7 +749,7 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress post_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); @@ -579,23 +772,27 @@ fn begin_install(install_progress_log_terminal: &vte::Terminal, install_progress gio::spawn_blocking(move || { let done_status = true; while done_status == true { - if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() == true || Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() == true { + if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() == true + || Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() == true + { done_status_sender .send_blocking(true) .expect("The channel needs to be open."); - break + break; } } }); let done_status_main_context = MainContext::default(); // The main loop executes the asynchronous block - done_status_main_context.spawn_local(clone!(@weak done_main_box, @weak content_stack, @weak window => async move { - 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); - content_stack.set_visible_child_name("done_page"); + done_status_main_context.spawn_local( + clone!(@weak done_main_box, @weak content_stack, @weak window => async move { + 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); + content_stack.set_visible_child_name("done_page"); + } } - } - })); -} \ No newline at end of file + }), + ); +} diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 0bb283b..43e68a5 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -1,26 +1,25 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; 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; use std::str; +use std::time::Instant; use std::fs; use std::path::Path; pub fn keyboard_page(content_stack: >k::Stack) { - // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() .orientation(Orientation::Horizontal) @@ -127,9 +126,8 @@ pub fn keyboard_page(content_stack: >k::Stack) { .label("No Keyboard Layout selected") .build(); - let keyboard_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); + let keyboard_selection_expander_row_viewport = + gtk::ScrolledWindow::builder().height_request(200).build(); let keyboard_selection_expander_row_viewport_box = gtk::Box::builder() .orientation(Orientation::Vertical) @@ -145,7 +143,8 @@ pub fn keyboard_page(content_stack: >k::Stack) { keyboard_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); keyboard_selection_expander_row_viewport_listbox.append(&keyboard_selection_expander_row); - keyboard_selection_expander_row_viewport.set_child(Some(&keyboard_selection_expander_row_viewport_box)); + keyboard_selection_expander_row_viewport + .set_child(Some(&keyboard_selection_expander_row_viewport_box)); keyboard_selection_expander_row.add_row(&keyboard_selection_expander_row_viewport); @@ -170,7 +169,9 @@ pub fn keyboard_page(content_stack: >k::Stack) { .unwrap(); let current_keyboard_output = current_keyboard_cut.wait_with_output().unwrap(); - let current_keyboard = str::from_utf8(¤t_keyboard_output.stdout).unwrap().trim(); + let current_keyboard = str::from_utf8(¤t_keyboard_output.stdout) + .unwrap() + .trim(); let keyboard_layout_cli = Command::new("localectl") .arg("list-x11-keymap-layouts") @@ -182,8 +183,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { let keyboard_layout_stdout = keyboard_layout_cli.stdout.expect("could not get stdout"); let keyboard_layout_reader = BufReader::new(keyboard_layout_stdout); - let keyboard_data_buffer = gtk::TextBuffer::builder() - .build(); + let keyboard_data_buffer = gtk::TextBuffer::builder().build(); for keyboard_layout in keyboard_layout_reader.lines() { let keyboard_layout = keyboard_layout.unwrap(); @@ -227,7 +227,18 @@ pub fn keyboard_page(content_stack: >k::Stack) { keyboard_main_box.append(&keyboard_selection_box); //// Add the keyboard selection/page content box to keyboard main box - keyboard_main_box.append(>k::Entry::builder().hexpand(true).valign(Align::End).vexpand(false).margin_bottom(15).margin_top(15).margin_end(15).margin_start(15).placeholder_text("Test Your Keyboard here!").build()); + keyboard_main_box.append( + >k::Entry::builder() + .hexpand(true) + .valign(Align::End) + .vexpand(false) + .margin_bottom(15) + .margin_top(15) + .margin_end(15) + .margin_start(15) + .placeholder_text("Test Your Keyboard here!") + .build(), + ); keyboard_main_box.append(&bottom_box); @@ -248,5 +259,4 @@ pub fn keyboard_page(content_stack: >k::Stack) { bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("timezone_page") })); - } diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index dee5ec4..2cb491f 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -1,27 +1,25 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; +use gtk::*; +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::env; use std::fs; use std::path::Path; - pub fn language_page(content_stack: >k::Stack) { - // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() .orientation(Orientation::Horizontal) @@ -128,15 +126,15 @@ pub fn language_page(content_stack: >k::Stack) { .label("No locale selected") .build(); - let language_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); + let language_selection_expander_row_viewport = + gtk::ScrolledWindow::builder().height_request(200).build(); let language_selection_expander_row_viewport_box = gtk::Box::builder() .orientation(Orientation::Vertical) .build(); - language_selection_expander_row_viewport.set_child(Some(&language_selection_expander_row_viewport_box)); + language_selection_expander_row_viewport + .set_child(Some(&language_selection_expander_row_viewport_box)); let language_selection_expander_row_viewport_listbox = gtk::ListBox::builder() .selection_mode(SelectionMode::None) @@ -152,7 +150,7 @@ pub fn language_page(content_stack: >k::Stack) { let current_locale = match env::var_os("LANG") { Some(v) => v.into_string().unwrap(), - None => panic!("$LANG is not set") + None => panic!("$LANG is not set"), }; let locale_cli = Command::new("locale") @@ -177,15 +175,12 @@ pub fn language_page(content_stack: >k::Stack) { let locale_reader = BufReader::new(locale_cli_sort.stdout.expect("could not get stdout")); - let lang_data_buffer = gtk::TextBuffer::builder() - .build(); + let lang_data_buffer = gtk::TextBuffer::builder().build(); for locale in locale_reader.lines() { let locale = locale.unwrap(); let locale_clone = locale.clone(); - let locale_checkbutton = gtk::CheckButton::builder() - .label(locale.clone()) - .build(); + let locale_checkbutton = gtk::CheckButton::builder().label(locale.clone()).build(); locale_checkbutton.set_group(Some(&null_checkbutton)); language_selection_expander_row_viewport_box.append(&locale_checkbutton); locale_checkbutton.connect_toggled(clone!(@weak locale_checkbutton, @weak language_selection_expander_row, @weak bottom_next_button, @weak lang_data_buffer => move |_| { diff --git a/src/main.rs b/src/main.rs index cc5bb10..ce340de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,32 +1,34 @@ - // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; -mod build_ui; -mod save_window_size; -mod welcome_page; -mod efi_error_page; -mod language_page; -mod eula_page; -mod timezone_page; -mod keyboard_page; -mod partitioning_page; -mod install_page; -mod done_page; +use gtk::*; mod automatic_partitioning; -mod manual_partitioning; +mod build_ui; +mod done_page; mod drive_mount_row; +mod efi_error_page; +mod eula_page; +mod install_page; +mod keyboard_page; +mod language_page; +mod manual_partitioning; +mod partitioning_page; +mod save_window_size; +mod timezone_page; +mod welcome_page; /// main function fn main() { - let application = adw::Application::new(Some("com.github.pikaos-linux.pikainstallergtk4"), Default::default()); + let application = adw::Application::new( + Some("com.github.pikaos-linux.pikainstallergtk4"), + Default::default(), + ); application.connect_startup(|app| { // The CSS "magic" happens here. let provider = CssProvider::new(); diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 2277583..cbaef50 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -1,68 +1,52 @@ // Use libraries -use std::collections::HashMap; -use std::thread; +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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; 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 std::{ - hash::{ - Hash, - }, - collections::{ - HashSet - }, - io::{ - BufRead, - BufReader, - }, - process::{ - Command, - Stdio, - }, - time::{ - Instant, - Duration, - }, - fs, - path::{ - Path, - }, -}; -use std::ops::{Deref, DerefMut}; 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}, +}; -use pretty_bytes::converter::convert; use crate::drive_mount_row::DriveMountRow; +use pretty_bytes::converter::convert; use serde::*; -#[derive(PartialEq)] -#[derive(Debug)] -#[derive(Eq)] -#[derive(Hash)] -#[derive(Clone)] -#[derive(Serialize, Deserialize)] +#[derive(PartialEq, Debug, Eq, Hash, Clone, Serialize, Deserialize)] pub struct DriveMount { pub partition: String, pub mountpoint: String, pub mountopt: String, } -fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc>>, part_table_array: &Rc>>, check_part_unique: &Rc>) -> DriveMountRow { - let partition_scroll_child = gtk::ListBox::builder() - .build(); +fn create_mount_row( + listbox: >k::ListBox, + manual_drive_mount_array: &Rc>>, + part_table_array: &Rc>>, + check_part_unique: &Rc>, +) -> DriveMountRow { + let partition_scroll_child = gtk::ListBox::builder().build(); let partitions_scroll = gtk::ScrolledWindow::builder() .hexpand(true) @@ -73,8 +57,7 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc().unwrap(); + let partition_size = String::from_utf8(partition_size_cli.stdout) + .expect("Failed to create float") + .trim() + .parse::() + .unwrap(); + let partition_fs = String::from_utf8(partition_fs_cli.stdout).expect("Failed read stdout"); let partition_button = gtk::CheckButton::builder() .valign(Align::Center) .can_focus(false) .build(); partition_button.set_group(Some(&null_checkbutton)); - let partition_row = adw::ActionRow::builder() - .activatable_widget(&partition_button) - .title(partition.clone()) - .name(partition.clone()) - .subtitle(String::from_utf8(partition_fs_cli.stdout).expect("Failed read stdout") + &pretty_bytes::converter::convert(partition_size)) - .build(); + let partition_row: adw::ActionRow = + if partition_fs.contains("crypto_LUKS") || partition_fs.contains("lvm") { + let prow = adw::ActionRow::builder() + .activatable_widget(&partition_button) + .title(partition.clone()) + .name(partition.clone()) + .subtitle("This partition needs a mapper!") + .build(); + prow + } else { + let prow = adw::ActionRow::builder() + .activatable_widget(&partition_button) + .title(partition.clone()) + .name(partition.clone()) + .subtitle(partition_fs + &pretty_bytes::converter::convert(partition_size)) + .build(); + prow + }; partition_row.add_prefix(&partition_button); partition_button.connect_toggled(clone!(@weak row, @weak listbox, @weak partition_button, @strong manual_drive_mount_array, @strong partition=> move |_| { let mut manual_drive_mount_array_ref = RefCell::borrow_mut(&manual_drive_mount_array); @@ -123,7 +123,7 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc move |row: DriveMountRow| { listbox_clone.remove(&row) - }) + }), ); // Return row @@ -131,8 +131,12 @@ fn create_mount_row(listbox: >k::ListBox, manual_drive_mount_array: &Rc (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { -pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: &Rc>>) { - +pub fn manual_partitioning( + window: &adw::ApplicationWindow, + partitioning_stack: >k::Stack, + bottom_next_button: >k::Button, + manual_drive_mount_array: &Rc>>, +) { let part_table_array: Rc>> = Default::default(); let check_part_unique = Rc::new(RefCell::new(true)); @@ -196,10 +200,7 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: .valign(Align::Start) .build(); - let drive_mounts_adw_listbox = gtk::ListBox::builder() - .hexpand(true) - .vexpand(true) - .build(); + let drive_mounts_adw_listbox = gtk::ListBox::builder().hexpand(true).vexpand(true).build(); drive_mounts_adw_listbox.add_css_class("boxed-list"); let drive_mounts_viewport = gtk::ScrolledWindow::builder() @@ -263,8 +264,10 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: partition_method_manual_selection_box.append(&partition_refresh_button); partition_method_manual_main_box.append(&partition_method_manual_header_box); partition_method_manual_main_box.append(&partition_method_manual_selection_box); - partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content); - partition_method_manual_gparted_button_content_box.append(&partition_method_manual_gparted_button_content_text); + partition_method_manual_gparted_button_content_box + .append(&partition_method_manual_gparted_button_content); + partition_method_manual_gparted_button_content_box + .append(&partition_method_manual_gparted_button_content_text); partition_method_manual_main_box.append(&partition_method_manual_gparted_button); drive_mounts_adw_listbox.append(&drive_mount_add_button); partition_method_manual_main_box.append(&drive_mounts_viewport); @@ -301,13 +304,11 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: let (anti_dup_partition_sender, anti_dup_partition_receiver) = async_channel::unbounded(); let anti_dup_partition_sender = anti_dup_partition_sender.clone(); // The long running operation runs now in a separate thread - gio::spawn_blocking(move || { - loop { - thread::sleep(Duration::from_millis(400)); - anti_dup_partition_sender - .send_blocking(true) - .expect("The channel needs to be open."); - } + gio::spawn_blocking(move || loop { + thread::sleep(Duration::from_millis(400)); + anti_dup_partition_sender + .send_blocking(true) + .expect("The channel needs to be open."); }); let anti_dup_partition_loop_context = MainContext::default(); @@ -346,9 +347,14 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: if *check_part_unique.borrow_mut() == true { row_scrw.set_sensitive(false) + } else if row_scrw.property::("subtitle").contains("This partition needs a mapper!") { + row_scrw.set_sensitive(false) } else { row_scrw.set_sensitive(true) } + } + else if row_scrw.property::("subtitle").contains("This partition needs a mapper!") { + row_scrw.set_sensitive(false) } else { row_scrw.set_sensitive(true) } @@ -373,16 +379,27 @@ pub fn manual_partitioning(window: &adw::ApplicationWindow, partitioning_stack: } })); - partitioning_stack.add_titled(&partition_method_manual_main_box, Some("partition_method_manual_page"), "partition_method_manual_page"); + partitioning_stack.add_titled( + &partition_method_manual_main_box, + Some("partition_method_manual_page"), + "partition_method_manual_page", + ); //return(partition_method_manual_target_buffer, partition_method_manual_luks_buffer, partition_method_manual_luks_password_entry) } - -fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition_method_manual_error_label: >k::Label, manual_drive_mount_array_ref: RefMut<'_, Vec>, check_part_unique: &Rc>) { - +fn partition_err_check( + partition_method_manual_warn_label: >k::Label, + partition_method_manual_error_label: >k::Label, + manual_drive_mount_array_ref: RefMut<'_, Vec>, + check_part_unique: &Rc>, +) { let mut empty_mountpoint = false; - for mountpoint in manual_drive_mount_array_ref.iter().map(|x| x.mountpoint.as_str()).collect::>() { + for mountpoint in manual_drive_mount_array_ref + .iter() + .map(|x| x.mountpoint.as_str()) + .collect::>() + { if empty_mountpoint == false { if mountpoint.is_empty() { empty_mountpoint = true @@ -391,7 +408,11 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition } let mut empty_partition = false; - for partition in manual_drive_mount_array_ref.iter().map(|x| x.partition.as_str()).collect::>() { + for partition in manual_drive_mount_array_ref + .iter() + .map(|x| x.partition.as_str()) + .collect::>() + { if empty_partition == false { if partition.is_empty() { empty_partition = true @@ -400,45 +421,68 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition } if empty_mountpoint == false { - if &partition_method_manual_error_label.label() == "Some drives don't have a mountpoint configured." { - partition_method_manual_error_label.set_visible(false); - } - if manual_drive_mount_array_ref.len() - manual_drive_mount_array_ref.iter().map(|x| x.mountpoint.as_str()).collect::>().len() > 0 { - if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label("Multiple drives were mounted to the same mountpoint."); - partition_method_manual_error_label.set_visible(true); - } - } else { - if partition_method_manual_error_label.label() == "Multiple drives were mounted to the same mountpoint." { - partition_method_manual_error_label.set_visible(false); - } - } - } else { + if &partition_method_manual_error_label.label() + == "Some drives don't have a mountpoint configured." + { + partition_method_manual_error_label.set_visible(false); + } + if manual_drive_mount_array_ref.len() + - manual_drive_mount_array_ref + .iter() + .map(|x| x.mountpoint.as_str()) + .collect::>() + .len() + > 0 + { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label("Some drives don't have a mountpoint configured."); + partition_method_manual_error_label + .set_label("Multiple drives were mounted to the same mountpoint."); partition_method_manual_error_label.set_visible(true); } - } + } else { + if partition_method_manual_error_label.label() + == "Multiple drives were mounted to the same mountpoint." + { + partition_method_manual_error_label.set_visible(false); + } + } + } else { + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_error_label + .set_label("Some drives don't have a mountpoint configured."); + partition_method_manual_error_label.set_visible(true); + } + } if empty_partition == true { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label("There's a drive row without a partition."); + partition_method_manual_error_label + .set_label("There's a drive row without a partition."); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label() == "There's a drive row without a partition." { + if partition_method_manual_error_label.label() == "There's a drive row without a partition." + { partition_method_manual_error_label.set_visible(false); } } - *check_part_unique.borrow_mut()=true; - for mountopts in manual_drive_mount_array_ref.iter().map(|x| x.mountopt.as_str()).collect::>() { + *check_part_unique.borrow_mut() = true; + for mountopts in manual_drive_mount_array_ref + .iter() + .map(|x| x.mountopt.as_str()) + .collect::>() + { if mountopts.contains("subvol") { - *check_part_unique.borrow_mut()=false + *check_part_unique.borrow_mut() = false } } - for drivemounts in manual_drive_mount_array_ref.iter().map(|x| x).collect::>() { + for drivemounts in manual_drive_mount_array_ref + .iter() + .map(|x| x) + .collect::>() + { if !drivemounts.partition.is_empty() { let partition_size_cli = Command::new("sudo") .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") @@ -452,26 +496,49 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition .arg(drivemounts.partition.replace("mapper/", "")) .output() .expect("failed to execute process"); - let partition_size = String::from_utf8(partition_size_cli.stdout).expect("Failed to create float").trim().parse::().unwrap(); - let partition_fs = String::from_utf8(partition_fs_cli.stdout).expect("Failed to create string").trim().parse::().unwrap(); + let partition_size = String::from_utf8(partition_size_cli.stdout) + .expect("Failed to create float") + .trim() + .parse::() + .unwrap(); + let partition_fs = String::from_utf8(partition_fs_cli.stdout) + .expect("Failed to create string") + .trim() + .parse::() + .unwrap(); if drivemounts.mountpoint == "/boot/efi" { if partition_size < 500000000.0 { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Small size: The partition mounted to /boot/efi (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 512MBs")); + partition_method_manual_error_label.set_label( + &("Small size: The partition mounted to /boot/efi (/dev/".to_owned() + + &drivemounts.partition + + ") Must at least be 512MBs"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Small size: The partition mounted to /boot/efi (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Small size: The partition mounted to /boot/efi (/dev/") + { partition_method_manual_error_label.set_visible(false); } } if partition_fs != "vfat" { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to /boot/efi (/dev/".to_owned() + &drivemounts.partition + ") Must at be FAT32/vFAT")); + partition_method_manual_error_label.set_label( + &("Bad Filesystem: The partition mounted to /boot/efi (/dev/" + .to_owned() + + &drivemounts.partition + + ") Must at be FAT32/vFAT"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to /boot/efi (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Bad Filesystem: The partition mounted to /boot/efi (/dev/") + { partition_method_manual_error_label.set_visible(false); } } @@ -479,21 +546,35 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition if drivemounts.mountpoint == "/boot" { if partition_size < 1000000000.0 { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Small size: The partition mounted to /boot (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 1000MBs")); + partition_method_manual_error_label.set_label( + &("Small size: The partition mounted to /boot (/dev/".to_owned() + + &drivemounts.partition + + ") Must at least be 1000MBs"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Small size: The partition mounted to /boot (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Small size: The partition mounted to /boot (/dev/") + { partition_method_manual_error_label.set_visible(false); } } if partition_fs == "vfat" { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to /boot (/dev/".to_owned() + &drivemounts.partition + ") Cannot be FAT32/vFAT")); + partition_method_manual_error_label.set_label( + &("Bad Filesystem: The partition mounted to /boot (/dev/".to_owned() + + &drivemounts.partition + + ") Cannot be FAT32/vFAT"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to /boot (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Bad Filesystem: The partition mounted to /boot (/dev/") + { partition_method_manual_error_label.set_visible(false); } } @@ -501,21 +582,35 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition if drivemounts.mountpoint == "/" { if partition_size < 25000000000.0 { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Small size: The partition mounted to / (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 25GBs")); + partition_method_manual_error_label.set_label( + &("Small size: The partition mounted to / (/dev/".to_owned() + + &drivemounts.partition + + ") Must at least be 25GBs"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Small size: The partition mounted to / (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Small size: The partition mounted to / (/dev/") + { partition_method_manual_error_label.set_visible(false); } } if partition_fs == "vfat" { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to / (/dev/".to_owned() + &drivemounts.partition + ") Cannot be FAT32/vFAT")); + partition_method_manual_error_label.set_label( + &("Bad Filesystem: The partition mounted to / (/dev/".to_owned() + + &drivemounts.partition + + ") Cannot be FAT32/vFAT"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to / (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Bad Filesystem: The partition mounted to / (/dev/") + { partition_method_manual_error_label.set_visible(false); } } @@ -523,21 +618,35 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition if drivemounts.mountpoint == "/home" { if partition_size < 10000000000.0 { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Small size: The partition mounted to /home (/dev/".to_owned() + &drivemounts.partition + ") Must at least be 10GBs")); + partition_method_manual_error_label.set_label( + &("Small size: The partition mounted to /home (/dev/".to_owned() + + &drivemounts.partition + + ") Must at least be 10GBs"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Small size: The partition mounted to /home (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Small size: The partition mounted to /home (/dev/") + { partition_method_manual_error_label.set_visible(false); } } if partition_fs == "vfat" { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Bad Filesystem: The partition mounted to /home (/dev/".to_owned() + &drivemounts.partition + ") Cannot be FAT32/vFAT")); + partition_method_manual_error_label.set_label( + &("Bad Filesystem: The partition mounted to /home (/dev/".to_owned() + + &drivemounts.partition + + ") Cannot be FAT32/vFAT"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains("Bad Filesystem: The partition mounted to /home (/dev/") { + if partition_method_manual_error_label + .label() + .contains("Bad Filesystem: The partition mounted to /home (/dev/") + { partition_method_manual_error_label.set_visible(false); } } @@ -545,23 +654,40 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition if drivemounts.mountpoint == "[SWAP]" { if partition_fs != "linux-swap" { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Bad Filesystem: ".to_owned() + &drivemounts.partition + " Is not a swap partition")); + partition_method_manual_error_label.set_label( + &("Bad Filesystem: ".to_owned() + + &drivemounts.partition + + " Is not a swap partition"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains(" Is not a swap partition") { + if partition_method_manual_error_label + .label() + .contains(" Is not a swap partition") + { partition_method_manual_error_label.set_visible(false); } } } - if empty_mountpoint == false && !drivemounts.mountpoint.starts_with("/") && drivemounts.mountpoint != "[SWAP]" { + if empty_mountpoint == false + && !drivemounts.mountpoint.starts_with("/") + && drivemounts.mountpoint != "[SWAP]" + { if !partition_method_manual_error_label.is_visible() { - partition_method_manual_error_label.set_label(&("Bad Mountpoint: ".to_owned() + &drivemounts.mountpoint + " Is not a valid mountpoint")); + partition_method_manual_error_label.set_label( + &("Bad Mountpoint: ".to_owned() + + &drivemounts.mountpoint + + " Is not a valid mountpoint"), + ); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label().contains(" Is not a valid mountpoint") { + if partition_method_manual_error_label + .label() + .contains(" Is not a valid mountpoint") + { partition_method_manual_error_label.set_visible(false); } } @@ -569,9 +695,10 @@ fn partition_err_check(partition_method_manual_warn_label: >k::Label,partition } if *check_part_unique.borrow_mut() == false { - partition_method_manual_warn_label.set_label("Partition reuse check will be skipped due to subvol usage."); + partition_method_manual_warn_label + .set_label("Partition reuse check will be skipped due to subvol usage."); partition_method_manual_warn_label.set_visible(true); } else { partition_method_manual_warn_label.set_visible(false); } -} \ No newline at end of file +} diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 822b29c..ad6ee28 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -1,26 +1,26 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; -use glob::glob; +use gtk::*; use crate::automatic_partitioning::automatic_partitioning; -use crate::manual_partitioning::manual_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::env; -use pretty_bytes::converter::convert; use std::thread; use std::time::*; @@ -36,9 +36,13 @@ use crate::{install_page, manual_partitioning}; use manual_partitioning::DriveMount; -pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box ,content_stack: >k::Stack, window: &adw::ApplicationWindow) { - - let manual_drive_mount_array : Rc>> = Default::default(); +pub fn partitioning_page( + done_main_box: >k::Box, + install_main_box: >k::Box, + content_stack: >k::Stack, + window: &adw::ApplicationWindow, +) { + let manual_drive_mount_array: Rc>> = Default::default(); // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() @@ -183,7 +187,6 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , .valign(gtk::Align::Center) .build(); - let automatic_method_button = gtk::Button::builder() .child(&automatic_method_button_content_box) .vexpand(true) @@ -218,9 +221,19 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , 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"), "partition_method_select_page"); - let partitioning_page_automatic_partitioning = automatic_partitioning(&partitioning_stack, &bottom_next_button); - let partitioning_page_manual_partitioning= manual_partitioning(window, &partitioning_stack, &bottom_next_button, &manual_drive_mount_array); + partitioning_stack.add_titled( + &partitioning_method_main_box, + Some("partition_method_select_page"), + "partition_method_select_page", + ); + let partitioning_page_automatic_partitioning = + automatic_partitioning(&partitioning_stack, &bottom_next_button); + let partitioning_page_manual_partitioning = manual_partitioning( + window, + &partitioning_stack, + &bottom_next_button, + &manual_drive_mount_array, + ); // add everything to the main box partitioning_main_box.append(&partitioning_stack); @@ -228,14 +241,20 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , // / Content stack appends //// Add the partitioning_main_box as page: partitioning_page, Give it nice title - content_stack.add_titled(&partitioning_main_box, Some("partitioning_page"), "Partitioning"); + content_stack.add_titled( + &partitioning_main_box, + Some("partitioning_page"), + "Partitioning", + ); automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); manual_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_manual_page"))); - let partition_method_automatic_target_buffer_clone = partitioning_page_automatic_partitioning.0.clone(); + let partition_method_automatic_target_buffer_clone = + partitioning_page_automatic_partitioning.0.clone(); - let partition_method_automatic_luks_buffer_clone = partitioning_page_automatic_partitioning.1.clone(); + let partition_method_automatic_luks_buffer_clone = + partitioning_page_automatic_partitioning.1.clone(); bottom_next_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("install_page") @@ -246,7 +265,7 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , bottom_next_button.set_sensitive(false); })); - bottom_next_button.connect_clicked(clone!(@strong manual_drive_mount_array, @weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| { + bottom_next_button.connect_clicked(clone!(@weak content_stack, @weak partitioning_stack, @weak install_main_box, @weak window, @weak done_main_box => move |_| { if Path::new("/tmp/pika-installer-gtk4-target-auto.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-target-auto.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-auto.txt"); } @@ -275,15 +294,8 @@ pub fn partitioning_page(done_main_box: >k::Box, install_main_box: >k::Box , content_stack.set_visible_child_name("install_page"); } else { fs::write("/tmp/pika-installer-gtk4-target-manual.txt", "").expect("Unable to write file"); - let mut iter_count = 0; - iter_count = 0; - for partitions in manual_drive_mount_array.borrow_mut().iter() { - fs::write("/tmp/pika-installer-gtk4-target-manual-p".to_owned() + &iter_count.to_string() + ".json", serde_json::to_string(partitions).unwrap()).expect("Unable to write file"); - iter_count += 1; - } install_page(&done_main_box, &install_main_box, &content_stack, &window, &manual_drive_mount_array); content_stack.set_visible_child_name("install_page"); } })); - } diff --git a/src/save_window_size/mod.rs b/src/save_window_size/mod.rs index b072be5..bb39228 100644 --- a/src/save_window_size/mod.rs +++ b/src/save_window_size/mod.rs @@ -1,16 +1,15 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; // Save current window size to glib pub fn save_window_size(window: &adw::ApplicationWindow, glib_settings: &gio::Settings) { - let size = window.default_size(); let _ = glib_settings.set_int("window-width", size.0); diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index dcf65bc..96bf857 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -1,26 +1,25 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; 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; use std::str; +use std::time::Instant; use std::fs; use std::path::Path; pub fn timezone_page(content_stack: >k::Stack) { - // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() .orientation(Orientation::Horizontal) @@ -127,9 +126,8 @@ pub fn timezone_page(content_stack: >k::Stack) { .label("No Time Zone selected") .build(); - let timezone_selection_expander_row_viewport = gtk::ScrolledWindow::builder() - .height_request(200) - .build(); + let timezone_selection_expander_row_viewport = + gtk::ScrolledWindow::builder().height_request(200).build(); let timezone_selection_expander_row_viewport_box = gtk::Box::builder() .orientation(Orientation::Vertical) @@ -145,7 +143,8 @@ pub fn timezone_page(content_stack: >k::Stack) { timezone_selection_expander_row_viewport_listbox.add_css_class("boxed-list"); timezone_selection_expander_row_viewport_listbox.append(&timezone_selection_expander_row); - timezone_selection_expander_row_viewport.set_child(Some(&timezone_selection_expander_row_viewport_box)); + timezone_selection_expander_row_viewport + .set_child(Some(&timezone_selection_expander_row_viewport_box)); timezone_selection_expander_row.add_row(&timezone_selection_expander_row_viewport); @@ -160,7 +159,9 @@ pub fn timezone_page(content_stack: >k::Stack) { .unwrap_or_else(|e| panic!("failed {}", e)); let current_timezone_output = current_timezone_cli.wait_with_output().unwrap(); - let current_timezone = str::from_utf8(¤t_timezone_output.stdout).unwrap().trim(); + let current_timezone = str::from_utf8(¤t_timezone_output.stdout) + .unwrap() + .trim(); let timezone_layout_cli = Command::new("timedatectl") .arg("list-timezones") @@ -172,8 +173,7 @@ pub fn timezone_page(content_stack: >k::Stack) { let timezone_layout_stdout = timezone_layout_cli.stdout.expect("could not get stdout"); let timezone_layout_reader = BufReader::new(timezone_layout_stdout); - let timezone_data_buffer = gtk::TextBuffer::builder() - .build(); + let timezone_data_buffer = gtk::TextBuffer::builder().build(); for timezone_layout in timezone_layout_reader.lines() { let timezone_layout = timezone_layout.unwrap(); @@ -235,5 +235,4 @@ pub fn timezone_page(content_stack: >k::Stack) { bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { content_stack.set_visible_child_name("eula_page") })); - } diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index 4209e06..7b78cd8 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -1,13 +1,13 @@ // 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::*; -use adw::prelude::*; -use adw::*; -use glib::*; -use gdk::Display; use gtk::subclass::layout_child; +use gtk::*; pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the welcome page @@ -102,7 +102,6 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) .valign(gtk::Align::Center) .build(); - let install_media_button = gtk::Button::builder() .child(&install_media_button_content_box) .vexpand(true) @@ -143,7 +142,6 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) //// add image and text to the live_media_button live_media_button_content_box.append(&live_media_button_content_image); - // / welcome_selection_box appends //// add live and install media button to welcome page selections welcome_selection_box.append(&live_media_button); From 2f1c3316d5e851b119733b0a8659ebd5d2862f08 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 14:47:32 +0300 Subject: [PATCH 22/52] RR: working crypt checker --- src/drive_mount_row/imp.rs | 13 +++++++++++-- src/install_page/mod.rs | 18 ++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 8a4592f..5ba2e2b 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -49,6 +49,8 @@ impl ObjectImpl for DriveMountRow { let action_row_content_box = gtk::Box::builder() .orientation(Horizontal) .spacing(0) + .vexpand(true) + .hexpand(true) .build(); let partition_row_expander_adw_listbox = gtk::ListBox::builder() @@ -56,39 +58,45 @@ impl ObjectImpl for DriveMountRow { .margin_start(10) .margin_top(5) .margin_bottom(5) + .vexpand(true) + .hexpand(true) .build(); partition_row_expander_adw_listbox.add_css_class("boxed-list"); let partition_row_expander = adw::ExpanderRow::builder() .subtitle("Partition") + .vexpand(true) + .hexpand(true) .width_request(300) .build(); let mountpoint_entry_adw_listbox = gtk::ListBox::builder() - .halign(gtk::Align::Center) .margin_top(5) .margin_bottom(5) .vexpand(true) + .hexpand(true) .build(); mountpoint_entry_adw_listbox.add_css_class("boxed-list"); let mountpoint_entry_row = adw::EntryRow::builder() .title("Mountpoint") .vexpand(true) + .hexpand(true) .build(); let mountopt_entry_adw_listbox = gtk::ListBox::builder() .margin_top(5) .margin_bottom(5) .margin_start(5) - .halign(gtk::Align::Center) .vexpand(true) + .hexpand(true) .build(); mountopt_entry_adw_listbox.add_css_class("boxed-list"); let mountopt_entry_row = adw::EntryRow::builder() .title("Additional Mount Options") .vexpand(true) + .hexpand(true) .build(); let partition_row_delete_button = gtk::Button::builder() @@ -98,6 +106,7 @@ impl ObjectImpl for DriveMountRow { .margin_bottom(5) .width_request(40) .vexpand(true) + .hexpand(true) .icon_name("edit-delete") .halign(gtk::Align::End) .build(); diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 7bf5cb4..51586d4 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -24,6 +24,7 @@ use std::rc::Rc; use crate::manual_partitioning::DriveMount; use serde::*; use serde_json::*; +use duct::*; #[derive(PartialEq, Debug, Eq, Hash, Clone, Serialize, Deserialize)] struct CrypttabEntry { @@ -63,6 +64,7 @@ pub fn install_page( let crypttab_password = adw::PasswordEntryRow::builder() .title("LUKS Password for ".to_owned() + &partitions.partition) .build(); + crypttab_password.set_show_apply_button(true); crypttab_password_listbox.append(&crypttab_password); let crypttab_dialog = adw::MessageDialog::builder() .transient_for(window) @@ -80,26 +82,18 @@ pub fn install_page( crypttab_dialog .add_response("crypttab_dialog_auto", "Automatic Unlock with root unlock"); crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false); - crypttab_password.connect_changed(clone!(@weak crypttab_password, @strong partitions, @weak crypttab_dialog => move |_| { + crypttab_password.connect_apply(clone!(@weak crypttab_password, @strong partitions, @weak crypttab_dialog => move |_| { let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); let luks_manual_password_sender = luks_manual_password_sender.clone(); - let luks_password = crypttab_password.text(); + let luks_password = crypttab_password.text().to_string(); gio::spawn_blocking(clone!(@strong crypttab_password, @strong partitions => move || { - let luks_check_cli = Command::new("sudo") - .arg("/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh") - .arg("test_luks_passwd") - .arg(&partitions.partition) - .arg(&luks_password) - .output() - .expect("failed to execute process"); - if luks_check_cli.status.success() { - println!("fuck"); + let result = cmd!("sudo", "/usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh", "test_luks_passwd", &partitions.partition, luks_password).run(); + if result.is_ok() { luks_manual_password_sender .send_blocking(false) .expect("The channel needs to be open."); } else { - println!("shit"); luks_manual_password_sender .send_blocking(true) .expect("The channel needs to be open."); From 36b0cf35c2c94d3a3253b7c30e304301885a686c Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 16:28:14 +0300 Subject: [PATCH 23/52] RR: prepare for integration with pikainstall --- data/scripts/manual-partition-install.sh | 51 +++++++++++++++++++++--- src/partitioning_page/mod.rs | 4 ++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index 254add8..051c22d 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -2,17 +2,58 @@ set -e -DISK="$(cat "/tmp/pika-installer-gtk4-target-manual.txt")" LOCALE="$(cat "/tmp/pika-installer-gtk4-lang.txt")" KEYBOARD="$(cat "/tmp/pika-installer-gtk4-keyboard.txt")" TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")" touch "/tmp/pika-installer-gtk4-status-parting.txt" -if [[ ! -f "/tmp/pika-installer-gtk4-target-manual-luks.txt" ]] +if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json then - pikainstall -r ${DISK}/ -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 + rm -rf /tmp/pika-installer-gtk4-crypttab + touch /tmp/pika-installer-gtk4-crypttab + + for cryptentry in /tmp/pika-installer-gtk4-target-manual-luks-p*.json; do + if [[ -z $(jq -r .password $cryptentry) ]] + then + LUKS=$(jq -r .partition $cryptentry) + MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-) + UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" + echo "$MAP $UUID none luks,discard" >> /tmp/pika-installer-gtk4-crypttab + else + LUKS=$(jq -r .partition $cryptentry) + MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-) + UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" + LUKS_PASSWD=$(jq -r .password $cryptentry) + echo "$MAP $UUID /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab + touch /keyfile.txt + openssl genrsa > /key-"$MAP".txt + echo $LUKS_PASSWD | cryptsetup luksAddKey UUID=$UUID /key-"$MAP".txt - + fi + done +fi + +for drivemount in /tmp/pika-installer-gtk4-target-manual-p*.json; do + PARTITION="/dev/$(jq -r .partition $drivemount)" + MOUNTPOINT=$(jq -r .mountpoint $drivemount) + MOUNTOPT=$(jq -r .mountopt $drivemount) + if [[ -z $MOUNTOPT ]] + then + mkdir -p /media/pika-install-mount/$MOUNTPOINT + mount $PARTITION $MOUNTPOINT + elif [[ $MOUNTPOINT == "[SWAP]" ]] + then + touch /tmp/pika-installer-gtk4-swaplist + echo $PARTITION > /tmp/pika-installer-gtk4-swaplist + else + mkdir -p /media/pika-install-mount/$MOUNTPOINT + mount -o $MOUNTOPT $PARTITION $MOUNTPOINT + fi +done + +if [[ ! -f "/tmp/pika-installer-gtk4-crypttab" ]] +then + pikainstall -r /media/pika-install-mount/ --manual 1 -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 else - LUKS_KEY="$(cat "/tmp/pika-installer-gtk4-target-manual-luks.txt")" - pikainstall -r ${DISK}/ -c ${LUKS_KEY} -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 + pikainstall -r /media/pika-install-mount/ --manual 2 -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 fi \ No newline at end of file diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index ad6ee28..a30e2fe 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -282,6 +282,10 @@ pub fn partitioning_page( let partition_file = partition_file.unwrap(); fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap()); } + for luks_file in glob("/tmp/pika-installer-gtk4-target-manual-luks-p*").expect("Failed to read glob pattern") { + let luks_file = luks_file.unwrap(); + fs::remove_file(&luks_file).expect(&luks_file.to_str().unwrap()); + } if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) { fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file"); let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string(); From 44b90ff7681dfe2025632c9730040a6d7e213fac Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 16:52:07 +0300 Subject: [PATCH 24/52] RR: Fix all warnings --- src/automatic_partitioning/mod.rs | 11 ------ src/build_ui.rs | 16 +------- src/done_page/mod.rs | 5 --- src/drive_mount_row/imp.rs | 4 +- src/efi_error_page/mod.rs | 3 -- src/eula_page/mod.rs | 9 ----- src/install_page/mod.rs | 64 ++++++++++++++----------------- src/keyboard_page/mod.rs | 4 -- src/language_page/mod.rs | 4 -- src/main.rs | 4 +- src/manual_partitioning/mod.rs | 27 ++++--------- src/partitioning_page/mod.rs | 23 ++--------- src/save_window_size/mod.rs | 4 +- src/timezone_page/mod.rs | 4 -- src/welcome_page/mod.rs | 3 -- 15 files changed, 45 insertions(+), 140 deletions(-) diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index 52356bf..e301a21 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -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: >k::Stack, bottom_next_button: >k::Button, diff --git a/src/build_ui.rs b/src/build_ui.rs index 4451e18..9583138 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -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())); diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index ad80718..cc6bcce 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -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: >k::Box, - content_stack: >k::Stack, window: &adw::ApplicationWindow, ) { // the header box for the installation_successful page diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 5ba2e2b..c7720da 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -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 diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index f864b22..ba552c8 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -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: >k::Stack) { diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 1f3560e..3491a0e 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -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: >k::Stack) { // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 51586d4..3bb94ec 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -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>>, ) { - let mut iter_count = 0; - iter_count = 0; + let mut _iter_count = 0; + _iter_count = 0; let mut unlocked_array: Vec = 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::() .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"); } } diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 43e68a5..9f1082a 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -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; diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index 2cb491f..504bbf4 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -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; diff --git a/src/main.rs b/src/main.rs index ce340de..3c7ee6b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index cbaef50..5199eda 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -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: >k::ListBox, manual_drive_mount_array: &Rc>>, part_table_array: &Rc>>, - check_part_unique: &Rc>, + _check_part_unique: &Rc>, ) -> 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: >k::Stack, bottom_next_button: >k::Button) -> (gtk::TextBuffer, gtk::TextBuffer, adw::PasswordEntryRow) { pub fn manual_partitioning( - window: &adw::ApplicationWindow, partitioning_stack: >k::Stack, bottom_next_button: >k::Button, manual_drive_mount_array: &Rc>>, @@ -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 { diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index a30e2fe..56c2679 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -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"); diff --git a/src/save_window_size/mod.rs b/src/save_window_size/mod.rs index bb39228..f7fc494 100644 --- a/src/save_window_size/mod.rs +++ b/src/save_window_size/mod.rs @@ -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 diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index 96bf857..727f6e8 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -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; diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index 7b78cd8..5ea9433 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -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: >k::Stack) { From 7b83565fe37c342877d26ebf42fc0f9754a3e834 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 18:54:33 +0300 Subject: [PATCH 25/52] RR: Fix manual partitions refresh function --- data/scripts/manual-partition-install.sh | 10 +++++----- debian/changelog | 2 +- src/manual_partitioning/mod.rs | 14 ++++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index 051c22d..fbe7153 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -26,7 +26,7 @@ then UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" LUKS_PASSWD=$(jq -r .password $cryptentry) echo "$MAP $UUID /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab - touch /keyfile.txt + touch /key-"$MAP".txt openssl genrsa > /key-"$MAP".txt echo $LUKS_PASSWD | cryptsetup luksAddKey UUID=$UUID /key-"$MAP".txt - fi @@ -35,18 +35,18 @@ fi for drivemount in /tmp/pika-installer-gtk4-target-manual-p*.json; do PARTITION="/dev/$(jq -r .partition $drivemount)" - MOUNTPOINT=$(jq -r .mountpoint $drivemount) + MOUNTPOINT="/media/pika-install-mount/$(jq -r .mountpoint $drivemount)" MOUNTOPT=$(jq -r .mountopt $drivemount) if [[ -z $MOUNTOPT ]] then - mkdir -p /media/pika-install-mount/$MOUNTPOINT + mkdir -p $MOUNTPOINT mount $PARTITION $MOUNTPOINT elif [[ $MOUNTPOINT == "[SWAP]" ]] then touch /tmp/pika-installer-gtk4-swaplist echo $PARTITION > /tmp/pika-installer-gtk4-swaplist else - mkdir -p /media/pika-install-mount/$MOUNTPOINT + mkdir -p $MOUNTPOINT mount -o $MOUNTOPT $PARTITION $MOUNTPOINT fi done @@ -56,4 +56,4 @@ then pikainstall -r /media/pika-install-mount/ --manual 1 -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 else pikainstall -r /media/pika-install-mount/ --manual 2 -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1 -fi \ No newline at end of file +fi diff --git a/debian/changelog b/debian/changelog index 9f97a96..32f26a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika8) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika9) pikauwu; urgency=low * First release diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 5199eda..ec46dda 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -261,17 +261,19 @@ pub fn manual_partitioning( partition_method_manual_main_box.append(&partition_method_manual_error_label); partition_method_manual_main_box.append(&partition_method_manual_warn_label); - partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array => move |_| { - let mut counter = drive_mounts_adw_listbox.first_child(); - while let Some(ref row) = counter { + partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array, @strong manual_drive_mount_array => move |_| { + while let Some(row) = drive_mounts_adw_listbox.last_child() { if row.widget_name() == "DriveMountRow" { - drive_mounts_adw_listbox.remove(row); - } - counter = row.next_sibling(); + drive_mounts_adw_listbox.remove(&row); + } else { + break } + } 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(); + let mut manual_drive_mount_array_ref = manual_drive_mount_array.borrow_mut(); + manual_drive_mount_array_ref.clear(); for partition in partition_method_manual_get_partitions_lines { part_table_array_ref.push(partition.unwrap()); } From bb977c65c07ce7aa42065da032030dde4ac41016 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 22:05:42 +0300 Subject: [PATCH 26/52] RR: Fix manual partition table order and sorting --- data/scripts/manual-partition-install.sh | 4 +- debian/changelog | 2 +- src/install_page/mod.rs | 1 + src/manual_partitioning/mod.rs | 76 ++++++++++++++++-------- src/partitioning_page/mod.rs | 10 ++++ src/style.css | 12 +++- 6 files changed, 77 insertions(+), 28 deletions(-) diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index fbe7153..71c89c6 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -8,9 +8,11 @@ TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")" touch "/tmp/pika-installer-gtk4-status-parting.txt" +rm -rf /tmp/pika-installer-gtk4-swaplist || true + if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json then - rm -rf /tmp/pika-installer-gtk4-crypttab + rm -rf /tmp/pika-installer-gtk4-crypttab || true touch /tmp/pika-installer-gtk4-crypttab for cryptentry in /tmp/pika-installer-gtk4-target-manual-luks-p*.json; do diff --git a/debian/changelog b/debian/changelog index 32f26a0..9b182e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika9) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika10) pikauwu; urgency=low * First release diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 3bb94ec..d93ac7d 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -37,6 +37,7 @@ pub fn install_page( let mut _iter_count = 0; _iter_count = 0; let mut unlocked_array: Vec = Default::default(); + manual_drive_mount_array.borrow_mut().sort_by_key(|p| p.clone().mountpoint); for partitions in manual_drive_mount_array.borrow_mut().iter() { let new_crypt = if partitions.mountpoint != "/" && !unlocked_array.contains(&partitions.partition) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index ec46dda..51e8130 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -7,7 +7,7 @@ use glib::*; use gtk::*; use std::thread; -use std::cell::{RefCell, RefMut}; +use std::cell::{RefCell}; use std::rc::Rc; @@ -223,6 +223,12 @@ pub fn manual_partitioning( .build(); partition_refresh_button.add_css_class("destructive-action"); + let fstab_valid_check = gtk::Button::builder() + .label("Validate Filesystem Table") + .halign(gtk::Align::Start) + .build(); + fstab_valid_check.add_css_class("valid-action"); + let drive_mount_add_button = gtk::Button::builder() .icon_name("list-add") .vexpand(true) @@ -237,6 +243,15 @@ pub fn manual_partitioning( .build(); partition_method_manual_error_label.add_css_class("small_error_text"); + let partition_method_manual_valid_label = gtk::Label::builder() + .halign(Align::Start) + .valign(Align::End) + .vexpand(true) + .visible(false) + .label("Filesystem Table is valid!") + .build(); + partition_method_manual_valid_label.add_css_class("small_valid_text"); + let partition_method_manual_warn_label = gtk::Label::builder() .halign(Align::Start) .valign(Align::End) @@ -258,9 +273,15 @@ pub fn manual_partitioning( partition_method_manual_main_box.append(&partition_method_manual_gparted_button); drive_mounts_adw_listbox.append(&drive_mount_add_button); partition_method_manual_main_box.append(&drive_mounts_viewport); + partition_method_manual_main_box.append(&fstab_valid_check); partition_method_manual_main_box.append(&partition_method_manual_error_label); + partition_method_manual_main_box.append(&partition_method_manual_valid_label); partition_method_manual_main_box.append(&partition_method_manual_warn_label); + fstab_valid_check.connect_clicked(clone!(@weak partition_method_manual_error_label, @weak partition_method_manual_valid_label, @strong manual_drive_mount_array, @strong check_part_unique => move |_| { + partition_err_check(&partition_method_manual_error_label, &partition_method_manual_valid_label, &manual_drive_mount_array); + })); + partition_refresh_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox,@strong part_table_array, @strong manual_drive_mount_array => move |_| { while let Some(row) = drive_mounts_adw_listbox.last_child() { if row.widget_name() == "DriveMountRow" { @@ -353,9 +374,28 @@ pub fn manual_partitioning( counter = row.next_sibling(); } let manual_drive_mount_array_ref_clone = manual_drive_mount_array_ref.clone(); - partition_err_check(&partition_method_manual_warn_label, &partition_method_manual_error_label, manual_drive_mount_array_ref, &check_part_unique); + + *check_part_unique.borrow_mut() = true; + for mountopts in manual_drive_mount_array_ref + .iter() + .map(|x| x.mountopt.as_str()) + .collect::>() + { + if mountopts.contains("subvol") { + *check_part_unique.borrow_mut() = false + } + } + + if *check_part_unique.borrow_mut() == false { + partition_method_manual_warn_label + .set_label("Partition reuse check will be skipped due to subvol usage."); + partition_method_manual_warn_label.set_visible(true); + } else { + partition_method_manual_warn_label.set_visible(false); + } + if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_manual_page".into())) { - if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() { + if manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot" {return true} else {return false}}) && manual_drive_mount_array_ref_clone.iter().any(|x| {if x.mountpoint == "/boot/efi" {return true} else {return false}}) && !partition_method_manual_error_label.is_visible() && partition_method_manual_valid_label.is_visible() { if !bottom_next_button.is_sensitive() { bottom_next_button.set_sensitive(true); } @@ -378,12 +418,12 @@ pub fn manual_partitioning( } fn partition_err_check( - partition_method_manual_warn_label: >k::Label, partition_method_manual_error_label: >k::Label, - manual_drive_mount_array_ref: RefMut<'_, Vec>, - check_part_unique: &Rc>, + partition_method_manual_valid_label: >k::Label, + manual_drive_mount_array: &Rc>>, ) { let mut empty_mountpoint = false; + let manual_drive_mount_array_ref = manual_drive_mount_array.borrow_mut(); for mountpoint in manual_drive_mount_array_ref .iter() .map(|x| x.mountpoint.as_str()) @@ -456,17 +496,6 @@ fn partition_err_check( } } - *check_part_unique.borrow_mut() = true; - for mountopts in manual_drive_mount_array_ref - .iter() - .map(|x| x.mountopt.as_str()) - .collect::>() - { - if mountopts.contains("subvol") { - *check_part_unique.borrow_mut() = false - } - } - for drivemounts in manual_drive_mount_array_ref .iter() .map(|x| x) @@ -680,14 +709,11 @@ fn partition_err_check( partition_method_manual_error_label.set_visible(false); } } + if !partition_method_manual_error_label.is_visible() { + partition_method_manual_valid_label.set_visible(true) + } else { + partition_method_manual_valid_label.set_visible(false) + } } } - - if *check_part_unique.borrow_mut() == false { - partition_method_manual_warn_label - .set_label("Partition reuse check will be skipped due to subvol usage."); - partition_method_manual_warn_label.set_visible(true); - } else { - partition_method_manual_warn_label.set_visible(false); - } } diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 56c2679..2eb124b 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -261,6 +261,16 @@ pub fn partitioning_page( if Path::new("/tmp/pika-installer-gtk4-target-manual-luks.txt").exists() { fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); } + if Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-fail.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-fail.txt"); + } + if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() { + fs::remove_file("/tmp/pika-installer-gtk4-successful.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-successful.txt"); + } + for status_file in glob("/tmp/pika-installer-gtk4-status*").expect("Failed to read glob pattern") { + let status_file = status_file.unwrap(); + fs::remove_file(&status_file).expect(&status_file.to_str().unwrap()); + } for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") { let partition_file = partition_file.unwrap(); fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap()); diff --git a/src/style.css b/src/style.css index 763254a..003ccce 100644 --- a/src/style.css +++ b/src/style.css @@ -8,6 +8,11 @@ color: orange; } +.small_valid_text { + font-size: 14px; + color: green; +} + .big_error_text { font-size: 32px; color: red; @@ -19,4 +24,9 @@ .medium_sized_text { font-size: 18px; -} \ No newline at end of file +} + +.valid-action { + background-color:green; + color: white; +} From 9e80f3c29f19155197d4271f5b06a1bd849d1d9c Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 22:29:23 +0300 Subject: [PATCH 27/52] RR: Fix swap --- debian/changelog | 2 +- src/manual_partitioning/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9b182e7..c2661bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika10) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika11) pikauwu; urgency=low * First release diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 51e8130..660eb01 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -670,7 +670,7 @@ fn partition_err_check( } } if drivemounts.mountpoint == "[SWAP]" { - if partition_fs != "linux-swap" { + if partition_fs != "swap" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( &("Bad Filesystem: ".to_owned() From 96a1a2a9b231bf6eda0575e4b8670ae38433d26a Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 22:56:52 +0300 Subject: [PATCH 28/52] RR: Fix swap being inproperly mounted --- data/scripts/manual-partition-install.sh | 12 ++++++------ debian/changelog | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index 71c89c6..b4a5ad6 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -39,18 +39,18 @@ for drivemount in /tmp/pika-installer-gtk4-target-manual-p*.json; do PARTITION="/dev/$(jq -r .partition $drivemount)" MOUNTPOINT="/media/pika-install-mount/$(jq -r .mountpoint $drivemount)" MOUNTOPT=$(jq -r .mountopt $drivemount) - if [[ -z $MOUNTOPT ]] + if [[ $MOUNTPOINT = '/media/pika-install-mount/[SWAP]' ]] + then + touch /tmp/pika-installer-gtk4-swaplist + echo $PARTITION > /tmp/pika-installer-gtk4-swaplist + elif [[ -z $MOUNTOPT ]] then mkdir -p $MOUNTPOINT mount $PARTITION $MOUNTPOINT - elif [[ $MOUNTPOINT == "[SWAP]" ]] - then - touch /tmp/pika-installer-gtk4-swaplist - echo $PARTITION > /tmp/pika-installer-gtk4-swaplist else mkdir -p $MOUNTPOINT mount -o $MOUNTOPT $PARTITION $MOUNTPOINT - fi + fi done if [[ ! -f "/tmp/pika-installer-gtk4-crypttab" ]] diff --git a/debian/changelog b/debian/changelog index c2661bf..8a8b2d1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika11) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika12) pikauwu; urgency=low * First release From 776c48fe04ed51188bae6e4a0b051488f412e1f2 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sat, 17 Feb 2024 23:54:33 +0300 Subject: [PATCH 29/52] RR: Fix perm error and disable swaps for automatic target --- data/scripts/automatic-partition-install.sh | 12 ++++++++++-- debian/changelog | 2 +- src/partitioning_page/mod.rs | 9 +++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/data/scripts/automatic-partition-install.sh b/data/scripts/automatic-partition-install.sh index 293cfd8..f5d3c27 100644 --- a/data/scripts/automatic-partition-install.sh +++ b/data/scripts/automatic-partition-install.sh @@ -13,7 +13,11 @@ touch "/tmp/pika-installer-gtk4-status-parting.txt" if [[ ! -f "/tmp/pika-installer-gtk4-target-automatic-luks.txt" ]] then - wipefs -a /dev/${DISK} + for part in $(sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions | grep ${DISK}); do + PARTITION="/dev/$part" + sudo swapoff $PARTITION || true + done + wipefs -af /dev/${DISK} # Partition the drives parted -s -a optimal /dev/${DISK} mklabel gpt \ mkpart "linux-efi" 1MiB 513Mib \ @@ -63,7 +67,11 @@ then fi else LUKS_KEY="$(cat "/tmp/pika-installer-gtk4-target-automatic-luks.txt")" - wipefs -a /dev/${DISK} + for part in $(sudo /usr/lib/pika/pika-installer-gtk4/scripts/partition-utility.sh get_partitions | grep ${DISK}); do + PARTITION="/dev/$part" + sudo swapoff $PARTITION || true + done + wipefs -af /dev/${DISK} # Partition the drives parted -s -a optimal /dev/${DISK} mklabel gpt \ mkpart "linux-efi" 1MiB 513Mib \ diff --git a/debian/changelog b/debian/changelog index 8a8b2d1..f02a4f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika12) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika13) pikauwu; urgency=low * First release diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 2eb124b..7b6136d 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -17,6 +17,8 @@ use std::path::Path; use std::cell::RefCell; use std::rc::Rc; +use duct::*; + use crate::{manual_partitioning}; use manual_partitioning::DriveMount; @@ -262,14 +264,13 @@ pub fn partitioning_page( fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); } if Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-fail.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-fail.txt"); + cmd!("sudo", "rm", "-rf", "/tmp/pika-installer-gtk4-fail.txt").run(); } if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() { - fs::remove_file("/tmp/pika-installer-gtk4-successful.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-successful.txt"); + cmd!("sudo", "rm", "-rf", "/tmp/pika-installer-gtk4-successful.txt").run(); } for status_file in glob("/tmp/pika-installer-gtk4-status*").expect("Failed to read glob pattern") { - let status_file = status_file.unwrap(); - fs::remove_file(&status_file).expect(&status_file.to_str().unwrap()); + cmd!("sudo", "rm", "-rf", "/tmp/pika-installer-gtk4-status*").run(); } for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") { let partition_file = partition_file.unwrap(); From aea05bb610b1f871b27af6a6781ae828450f1fe9 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 00:04:43 +0300 Subject: [PATCH 30/52] fix install_page cmd commands --- debian/changelog | 2 +- src/partitioning_page/mod.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index f02a4f3..d34bb64 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika13) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika14) pikauwu; urgency=low * First release diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 7b6136d..a88835d 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -264,13 +264,13 @@ pub fn partitioning_page( fs::remove_file("/tmp/pika-installer-gtk4-target-manual-luks.txt").expect("Bad permissions on /tmp/pika-installer-gtk4-target-manual.txt"); } if Path::new("/tmp/pika-installer-gtk4-fail.txt").exists() { - cmd!("sudo", "rm", "-rf", "/tmp/pika-installer-gtk4-fail.txt").run(); + let _ = cmd!("bash","-c","sudo rm -rfv /tmp/pika-installer-gtk4-fail.txt").run(); } if Path::new("/tmp/pika-installer-gtk4-successful.txt").exists() { - cmd!("sudo", "rm", "-rf", "/tmp/pika-installer-gtk4-successful.txt").run(); + let _ = cmd!("bash","-c","sudo rm -rfv /tmp/pika-installer-gtk4-successful.txt").run(); } - for status_file in glob("/tmp/pika-installer-gtk4-status*").expect("Failed to read glob pattern") { - cmd!("sudo", "rm", "-rf", "/tmp/pika-installer-gtk4-status*").run(); + for _status_file in glob("/tmp/pika-installer-gtk4-status*").expect("Failed to read glob pattern") { + let _ = cmd!("bash","-c","sudo rm -rfv /tmp/pika-installer-gtk4-status*").run(); } for partition_file in glob("/tmp/pika-installer-gtk4-target-manual-p*").expect("Failed to read glob pattern") { let partition_file = partition_file.unwrap(); From a35c78fb218b7d9656d29808499369d4c9f03aab Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 18:39:04 +0300 Subject: [PATCH 31/52] RR: Fix manual crypttab + add basis for translations + config.rs --- Cargo.lock | 137 +++++++++++++++++++++++ Cargo.toml | 1 + data/scripts/manual-partition-install.sh | 4 +- src/config.rs | 7 ++ src/done_page/mod.rs | 4 +- src/drive_mount_row/imp.rs | 34 ++++-- src/install_page/mod.rs | 3 +- src/main.rs | 21 +++- src/welcome_page/mod.rs | 3 +- 9 files changed, 197 insertions(+), 17 deletions(-) create mode 100644 src/config.rs diff --git a/Cargo.lock b/Cargo.lock index 3cae989..4a02228 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" version = "1.0.79" @@ -50,6 +59,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "cairo-rs" version = "0.18.5" @@ -75,6 +90,15 @@ dependencies = [ "system-deps", ] +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + [[package]] name = "cfg-expr" version = "0.15.6" @@ -294,6 +318,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "gettext-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e49ea8a8fad198aaa1f9655a2524b64b70eb06b2f3ff37da407566c93054f364" +dependencies = [ + "gettext-sys", + "locale_config", +] + +[[package]] +name = "gettext-sys" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c63ce2e00f56a206778276704bbe38564c8695249fdc8f354b4ef71c57c3839d" +dependencies = [ + "cc", + "temp-dir", +] + [[package]] name = "gio" version = "0.18.4" @@ -552,6 +596,12 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libadwaita" version = "0.5.3" @@ -590,6 +640,28 @@ version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +[[package]] +name = "locale_config" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934" +dependencies = [ + "lazy_static", + "objc", + "objc-foundation", + "regex", + "winapi", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + [[package]] name = "memchr" version = "2.7.1" @@ -605,6 +677,35 @@ dependencies = [ "autocfg", ] +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -659,6 +760,7 @@ dependencies = [ "async-channel", "duct", "fragile", + "gettext-rs", "glib", "glob", "gtk4", @@ -766,6 +868,35 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "rustc_version" version = "0.4.0" @@ -893,6 +1024,12 @@ version = "0.12.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" +[[package]] +name = "temp-dir" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd16aa9ffe15fe021c6ee3766772132c6e98dfa395a167e16864f61a9cfb71d6" + [[package]] name = "thiserror" version = "1.0.56" diff --git a/Cargo.toml b/Cargo.toml index bec32e9..96f21e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,5 +16,6 @@ pretty-bytes = "0.2.2" time = "0.3.31" vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] } glob = "0.3.1" +gettext-rs = { version = "0.7", features = ["gettext-system"] } serde_json = "1.0.113" serde = { version = "1.0", features = ["derive"] } diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index b4a5ad6..8055830 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -21,13 +21,13 @@ then LUKS=$(jq -r .partition $cryptentry) MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-) UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" - echo "$MAP $UUID none luks,discard" >> /tmp/pika-installer-gtk4-crypttab + echo "$MAP UUID="$UUID" none luks,discard" >> /tmp/pika-installer-gtk4-crypttab else LUKS=$(jq -r .partition $cryptentry) MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-) UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)" LUKS_PASSWD=$(jq -r .password $cryptentry) - echo "$MAP $UUID /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab + echo "$MAP UUID="$UUID" /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab touch /key-"$MAP".txt openssl genrsa > /key-"$MAP".txt echo $LUKS_PASSWD | cryptsetup luksAddKey UUID=$UUID /key-"$MAP".txt - diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..12be446 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,7 @@ +pub const APP_ID: &str = "com.github.pikaos-linux.pikainstallergtk4"; +pub const GETTEXT_PACKAGE: &str = env!("CARGO_PKG_NAME"); +pub const LOCALEDIR: &str = "/usr/share/locale"; +//pub const PKGDATADIR: &str = " /usr/share"; +//pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); +//pub const VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const DISTRO_ICON: &str = "pika-logo"; diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index cc6bcce..a397e6a 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use crate::config::{DISTRO_ICON}; + use std::path::Path; use std::process::Command; @@ -32,7 +34,7 @@ pub fn done_page( // the header icon for the installation_successful icon let done_header_icon = gtk::Image::builder() - .icon_name("debian-swirl") + .icon_name(DISTRO_ICON) .halign(gtk::Align::Start) .hexpand(true) .pixel_size(78) diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index c7720da..4e0b23b 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -70,33 +70,47 @@ impl ObjectImpl for DriveMountRow { .width_request(300) .build(); + let mountpoint_entry_adw_box = gtk::Box::builder() + .hexpand(true) + .valign(gtk::Align::Start) + .homogeneous(true) + .build(); + let mountpoint_entry_adw_listbox = gtk::ListBox::builder() .margin_top(5) .margin_bottom(5) - .vexpand(true) .hexpand(true) + .valign(gtk::Align::Start) .build(); mountpoint_entry_adw_listbox.add_css_class("boxed-list"); let mountpoint_entry_row = adw::EntryRow::builder() .title("Mountpoint") - .vexpand(true) .hexpand(true) + .valign(gtk::Align::Start) + .width_request(300) + .build(); + + let mountopt_entry_adw_box = gtk::Box::builder() + .hexpand(true) + .valign(gtk::Align::Start) + .homogeneous(true) .build(); let mountopt_entry_adw_listbox = gtk::ListBox::builder() .margin_top(5) .margin_bottom(5) .margin_start(5) - .vexpand(true) .hexpand(true) + .valign(gtk::Align::Start) .build(); mountopt_entry_adw_listbox.add_css_class("boxed-list"); let mountopt_entry_row = adw::EntryRow::builder() .title("Additional Mount Options") - .vexpand(true) .hexpand(true) + .valign(gtk::Align::Start) + .width_request(300) .build(); let partition_row_delete_button = gtk::Button::builder() @@ -104,9 +118,9 @@ impl ObjectImpl for DriveMountRow { .margin_start(5) .margin_top(5) .margin_bottom(5) - .width_request(40) - .vexpand(true) - .hexpand(true) + .width_request(53) + .height_request(53) + .valign(gtk::Align::Start) .icon_name("edit-delete") .halign(gtk::Align::End) .build(); @@ -119,10 +133,12 @@ impl ObjectImpl for DriveMountRow { action_row_content_box.append(&partition_row_expander_adw_listbox); mountpoint_entry_adw_listbox.append(&mountpoint_entry_row); - action_row_content_box.append(&mountpoint_entry_adw_listbox); + mountpoint_entry_adw_box.append(&mountpoint_entry_adw_listbox); + action_row_content_box.append(&mountpoint_entry_adw_box); mountopt_entry_adw_listbox.append(&mountopt_entry_row); - action_row_content_box.append(&mountopt_entry_adw_listbox); + mountopt_entry_adw_box.append(&mountopt_entry_adw_listbox); + action_row_content_box.append(&mountopt_entry_adw_box); action_row_content_box.append(&partition_row_delete_button); diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index d93ac7d..744841c 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -1,3 +1,4 @@ +use crate::config::DISTRO_ICON; use std::cell::RefCell; // Use libraries use adw::prelude::*; @@ -423,7 +424,7 @@ pub fn install_page( .build(); let placeholder_icon = gtk::Image::builder() - .icon_name("debian-swirl") + .icon_name(DISTRO_ICON) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .hexpand(true) diff --git a/src/main.rs b/src/main.rs index 3c7ee6b..b61937c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ // Use libraries +use crate::build_ui::build_ui; use adw::prelude::*; use adw::*; use gdk::Display; @@ -6,6 +7,10 @@ use gdk::Display; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +mod config; +use gettextrs::{gettext, LocaleCategory}; +use config::{GETTEXT_PACKAGE, LOCALEDIR, APP_ID}; + mod automatic_partitioning; mod build_ui; mod done_page; @@ -24,7 +29,7 @@ mod welcome_page; /// main function fn main() { let application = adw::Application::new( - Some("com.github.pikaos-linux.pikainstallergtk4"), + Some(APP_ID), Default::default(), ); application.connect_startup(|app| { @@ -38,8 +43,18 @@ fn main() { &provider, STYLE_PROVIDER_PRIORITY_APPLICATION, ); + // Prepare i18n + gettextrs::setlocale(LocaleCategory::LcAll, ""); + gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); + gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain"); + // Fallback if no translation present + if gettext("first_setup_initial_box_text_title") == "first_setup_initial_box_text_title" { + println!("Warning: Current LANG is not supported, using fallback Locale."); + gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8"); + } - app.connect_activate(build_ui::build_ui); + app.connect_activate(build_ui); }); + application.run(); -} +} \ No newline at end of file diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index 5ea9433..a429f38 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -1,4 +1,5 @@ // Use libraries +use crate::config::DISTRO_ICON; use adw::prelude::*; use adw::*; use glib::*; @@ -31,7 +32,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) // the header icon for the welcome icon let welcome_header_icon = gtk::Image::builder() - .icon_name("debian-swirl") + .icon_name(DISTRO_ICON) .halign(gtk::Align::Start) .hexpand(true) .pixel_size(78) From 11c64b6979f21b01e74727335c0c550a68f5d1ae Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 19:44:00 +0300 Subject: [PATCH 32/52] RR: Fix manual crypttab + add basis for translations + config.rs + improve checks --- src/manual_partitioning/mod.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 660eb01..4d60a02 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -32,6 +32,8 @@ pub struct DriveMount { fn create_mount_row( listbox: >k::ListBox, + partition_method_manual_error_label: >k::Label, + partition_method_manual_valid_label: >k::Label, manual_drive_mount_array: &Rc>>, part_table_array: &Rc>>, _check_part_unique: &Rc>, @@ -109,8 +111,12 @@ fn create_mount_row( row.connect_closure( "row-deleted", false, - closure_local!(@strong row as _row => move |_row: DriveMountRow| { - listbox_clone.remove(&_row) + closure_local!(@strong partition_method_manual_error_label ,@strong partition_method_manual_valid_label, @strong row as _row => move |_row: DriveMountRow| { + listbox_clone.remove(&_row); + partition_method_manual_error_label.set_label(""); + partition_method_manual_error_label.set_visible(false); + partition_method_manual_valid_label.set_label(""); + partition_method_manual_valid_label.set_visible(false); }), ); @@ -307,8 +313,8 @@ pub fn manual_partitioning( .expect("gparted failed to start"); }); - drive_mount_add_button.connect_clicked(clone!(@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong part_table_array, @strong check_part_unique => move |_| { - drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &manual_drive_mount_array, &part_table_array,&check_part_unique)) + drive_mount_add_button.connect_clicked(clone!(@weak partition_method_manual_error_label, @weak partition_method_manual_valid_label ,@weak drive_mounts_adw_listbox, @strong manual_drive_mount_array, @strong part_table_array, @strong check_part_unique => move |_| { + drive_mounts_adw_listbox.append(&create_mount_row(&drive_mounts_adw_listbox, &partition_method_manual_error_label, &partition_method_manual_valid_label, &manual_drive_mount_array, &part_table_array,&check_part_unique)) })); let (anti_dup_partition_sender, anti_dup_partition_receiver) = async_channel::unbounded(); @@ -322,7 +328,7 @@ pub fn manual_partitioning( }); let anti_dup_partition_loop_context = MainContext::default(); - anti_dup_partition_loop_context.spawn_local(clone!(@weak drive_mounts_adw_listbox, @weak partitioning_stack, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move { + anti_dup_partition_loop_context.spawn_local(clone!(@weak partition_method_manual_error_label, @weak partition_method_manual_valid_label ,@weak drive_mounts_adw_listbox, @weak partitioning_stack, @strong manual_drive_mount_array,@weak bottom_next_button, @strong check_part_unique => async move { while let Ok(_state) = anti_dup_partition_receiver.recv().await { let mut counter = drive_mounts_adw_listbox.first_child(); @@ -615,12 +621,12 @@ fn partition_err_check( partition_method_manual_error_label.set_visible(false); } } - if partition_fs == "vfat" { + if partition_fs == "vfat" || partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( &("Bad Filesystem: The partition mounted to / (/dev/".to_owned() + &drivemounts.partition - + ") Cannot be FAT32/vFAT"), + + ") Has an Invalid Filesystem"), ); partition_method_manual_error_label.set_visible(true); } From cfcebe2d7b15d2c0d2a7c9c7d4964f248a49ff91 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 20:28:14 +0300 Subject: [PATCH 33/52] RR: Begin Translation Process --- Makefile | 3 +++ makepot | 9 +++++++++ po/en_US.po | 16 ++++++++++++++++ src/automatic_partitioning/mod.rs | 2 ++ src/build_ui.rs | 4 +++- src/done_page/mod.rs | 1 + src/drive_mount_row/imp.rs | 2 ++ src/efi_error_page/mod.rs | 2 ++ src/eula_page/mod.rs | 2 ++ src/install_page/mod.rs | 2 ++ src/keyboard_page/mod.rs | 2 ++ src/language_page/mod.rs | 7 +++++++ src/main.rs | 2 +- src/manual_partitioning/mod.rs | 2 ++ src/partitioning_page/mod.rs | 2 ++ src/timezone_page/mod.rs | 2 ++ src/welcome_page/mod.rs | 2 ++ 17 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 makepot create mode 100644 po/en_US.po diff --git a/Makefile b/Makefile index 2c2aa5d..3555e84 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +export PATH := $(PWD):$(PATH) + all: true @@ -19,3 +21,4 @@ install: mkdir -p $(DESTDIR)/usr/share/icons/hicolor/scalable/apps #cp -vf data/pika-drivers.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/ #cp -vf data/com.pika.drivers.desktop $(DESTDIR)/usr/share/applications/ + makepot $(DESTDIR)/usr/share/locale diff --git a/makepot b/makepot new file mode 100755 index 0000000..0a75270 --- /dev/null +++ b/makepot @@ -0,0 +1,9 @@ +#! /bin/bash + +set -e + +for i in po/*.po +do + mkdir -p "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES + msgfmt -v $i -o "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES/pika-first-setup-gtk4.mo +done \ No newline at end of file diff --git a/po/en_US.po b/po/en_US.po new file mode 100644 index 0000000..f7fb881 --- /dev/null +++ b/po/en_US.po @@ -0,0 +1,16 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2024-02-09 17:48+0300\n" +"PO-Revision-Date: 2024-02-09 17:55+0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.4\n" +"X-Poedit-Basepath: .\n" + +msgid "pikaos_installer" +msgstr "PikaOS Installer" \ No newline at end of file diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index e301a21..61468eb 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; diff --git a/src/build_ui.rs b/src/build_ui.rs index 9583138..64fa83a 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::path::Path; use crate::save_window_size::save_window_size; @@ -27,7 +29,7 @@ use crate::partitioning_page::partitioning_page; // build ui function linked to app startup above pub fn build_ui(app: &adw::Application) { // setup glib - gtk::glib::set_prgname(Some("PikaOS Installer")); + gtk::glib::set_prgname(Some(gettext("pikaos_installer"))); glib::set_application_name("PikaOS Installer"); let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4"); diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index a397e6a..8a49c67 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -7,6 +7,7 @@ use glib::*; use gtk::*; use crate::config::{DISTRO_ICON}; +use gettextrs::{gettext, LocaleCategory}; use std::path::Path; use std::process::Command; diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 4e0b23b..a9dd891 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -8,6 +8,8 @@ use adw::{prelude::*, subclass::prelude::*, *}; use glib::{clone, subclass::Signal, Properties}; use gtk::{glib, Orientation::Horizontal}; +use gettextrs::{gettext, LocaleCategory}; + // ANCHOR: custom_button // Object holding the state #[derive(Properties, Default)] diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index ba552c8..3121e3f 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the efi_error page let efi_error_main_box = gtk::Box::builder() diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 3491a0e..9b10dfd 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + pub fn eula_page(content_stack: >k::Stack) { // create the bottom box for next and back buttons let bottom_box = gtk::Box::builder() diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index 744841c..d148f93 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -10,6 +10,8 @@ use gtk::*; use vte::prelude::*; use vte::*; +use gettextrs::{gettext, LocaleCategory}; + use crate::done_page::done_page; use std::process::Command; diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 9f1082a..42dd38a 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index 504bbf4..2712301 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::env; use std::io::BufRead; use std::io::BufReader; @@ -226,6 +228,11 @@ pub fn language_page(content_stack: >k::Stack) { .arg("LANG=".to_owned() + &lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8") .spawn() .expect("locale failed to start"); + gettextrs::setlocale(LocaleCategory::LcAll, lang_data_buffer_clone.text(&lang_data_buffer_clone.bounds().0, &lang_data_buffer_clone.bounds().1, true).to_string() + ".UTF-8"); + if gettext("pikaos_installer") == "pikaos_installer" { + println!("Warning: Current LANG is not supported, using fallback Locale."); + gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8"); + } content_stack.set_visible_child_name("eula_page") })); bottom_back_button.connect_clicked(clone!(@weak content_stack => move |_| { diff --git a/src/main.rs b/src/main.rs index b61937c..6a943e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,7 +48,7 @@ fn main() { gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain"); // Fallback if no translation present - if gettext("first_setup_initial_box_text_title") == "first_setup_initial_box_text_title" { + if gettext("pikaos_installer") == "pikaos_installer" { println!("Warning: Current LANG is not supported, using fallback Locale."); gettextrs::setlocale(LocaleCategory::LcAll, "en_US.UTF8"); } diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 4d60a02..fe9659d 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -7,6 +7,8 @@ use glib::*; use gtk::*; use std::thread; +use gettextrs::{gettext, LocaleCategory}; + use std::cell::{RefCell}; use std::rc::Rc; diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index a88835d..58d7802 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -7,6 +7,8 @@ use glob::glob; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use crate::automatic_partitioning::automatic_partitioning; use crate::install_page::install_page; use crate::manual_partitioning::manual_partitioning; diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index 727f6e8..f594bb3 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -6,6 +6,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + use std::io::BufRead; use std::io::BufReader; use std::process::Command; diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index a429f38..56e37f9 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -7,6 +7,8 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use gettextrs::{gettext, LocaleCategory}; + pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the welcome page let welcome_main_box = gtk::Box::builder() From 90941b2eb1277b25277e6b3dcb8d71b99134685c Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 21:30:41 +0300 Subject: [PATCH 34/52] RR: Begin Translation Process for few stacks and use err id based problem detection in manual partitioning --- po/en_US.po | 42 +++++++++++++++- src/automatic_partitioning/mod.rs | 2 +- src/build_ui.rs | 6 +-- src/done_page/mod.rs | 2 +- src/drive_mount_row/imp.rs | 4 +- src/efi_error_page/mod.rs | 2 +- src/eula_page/mod.rs | 2 +- src/install_page/mod.rs | 2 +- src/keyboard_page/mod.rs | 2 +- src/manual_partitioning/mod.rs | 82 ++++++++++++------------------- src/partitioning_page/mod.rs | 16 +++--- src/timezone_page/mod.rs | 18 +++---- src/welcome_page/mod.rs | 10 ++-- 13 files changed, 106 insertions(+), 84 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index f7fb881..cbd9793 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -13,4 +13,44 @@ msgstr "" "X-Poedit-Basepath: .\n" msgid "pikaos_installer" -msgstr "PikaOS Installer" \ No newline at end of file +msgstr "PikaOS Installer" + +msgid "welcome_to_pikaos" +msgstr "Welcome to PikaOS" + +msgid "use_pikaos_in_live_media" +msgstr "Use PikaOS in Live media" + +msgid "install_distro_to_system" +msgstr "Install Distro to System" + +msgid "welcome" +msgstr "Welcome" + +msgid "back" +msgstr "Back" + +msgid "next" +msgstr "Next" + +msgid "select_a_timezone" +msgstr "Select a timezone" + +msgid "please_select_timezone" +msgstr "Please select a Time Zone for the system to use" + +msgid "no_timezone_select" +msgstr "No Time Zone selected" + +msgid "timezone" +msgstr "Time Zone" + +msgid "choose_install_method" +msgstr "Choose an install method" + +msgid "manual_partition_drive" +msgstr "Manually Partition The Drive" + +msgid "auto_partition_drive" +msgstr "Automatically Partition\nThe Drive" + diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index 61468eb..85eada3 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::io::BufRead; use std::io::BufReader; diff --git a/src/build_ui.rs b/src/build_ui.rs index 64fa83a..e7279cd 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::path::Path; @@ -30,7 +30,7 @@ use crate::partitioning_page::partitioning_page; pub fn build_ui(app: &adw::Application) { // setup glib gtk::glib::set_prgname(Some(gettext("pikaos_installer"))); - glib::set_application_name("PikaOS Installer"); + glib::set_application_name(&gettext("pikaos_installer")); let glib_settings = gio::Settings::new("com.github.pikaos-linux.pikainstallergtk4"); // Widget Bank @@ -67,7 +67,7 @@ pub fn build_ui(app: &adw::Application) { let window = adw::ApplicationWindow::builder() // The text on the titlebar - .title("PikaOS Installer") + .title(gettext("pikaos_installer")) // link it to the application "app" .application(app) // Add the box called "_main_box" to it diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index 8a49c67..f969cdd 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -7,7 +7,7 @@ use glib::*; use gtk::*; use crate::config::{DISTRO_ICON}; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::path::Path; use std::process::Command; diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index a9dd891..5cb2baf 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -8,7 +8,7 @@ use adw::{prelude::*, subclass::prelude::*, *}; use glib::{clone, subclass::Signal, Properties}; use gtk::{glib, Orientation::Horizontal}; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; // ANCHOR: custom_button // Object holding the state @@ -123,7 +123,7 @@ impl ObjectImpl for DriveMountRow { .width_request(53) .height_request(53) .valign(gtk::Align::Start) - .icon_name("edit-delete") + .icon_name("user-trash") .halign(gtk::Align::End) .build(); diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index 3121e3f..ce9de09 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the efi_error page diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 9b10dfd..293ede4 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; pub fn eula_page(content_stack: >k::Stack) { // create the bottom box for next and back buttons diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index d148f93..d3157e4 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -10,7 +10,7 @@ use gtk::*; use vte::prelude::*; use vte::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use crate::done_page::done_page; diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 42dd38a..3d394dd 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::io::BufRead; use std::io::BufReader; diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index fe9659d..03a1214 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -7,7 +7,7 @@ use glib::*; use gtk::*; use std::thread; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::cell::{RefCell}; use std::rc::Rc; @@ -116,6 +116,7 @@ fn create_mount_row( closure_local!(@strong partition_method_manual_error_label ,@strong partition_method_manual_valid_label, @strong row as _row => move |_row: DriveMountRow| { listbox_clone.remove(&_row); partition_method_manual_error_label.set_label(""); + partition_method_manual_error_label.set_widget_name(""); partition_method_manual_error_label.set_visible(false); partition_method_manual_valid_label.set_label(""); partition_method_manual_valid_label.set_visible(false); @@ -458,8 +459,8 @@ fn partition_err_check( } if empty_mountpoint == false { - if &partition_method_manual_error_label.label() - == "Some drives don't have a mountpoint configured." + if &partition_method_manual_error_label.widget_name() + == "err1" { partition_method_manual_error_label.set_visible(false); } @@ -475,11 +476,10 @@ fn partition_err_check( partition_method_manual_error_label .set_label("Multiple drives were mounted to the same mountpoint."); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err0"); } } else { - if partition_method_manual_error_label.label() - == "Multiple drives were mounted to the same mountpoint." - { + if &partition_method_manual_error_label.widget_name() == "err0" { partition_method_manual_error_label.set_visible(false); } } @@ -487,6 +487,7 @@ fn partition_err_check( if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label .set_label("Some drives don't have a mountpoint configured."); + partition_method_manual_error_label.set_widget_name("err1"); partition_method_manual_error_label.set_visible(true); } } @@ -495,10 +496,11 @@ fn partition_err_check( if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label .set_label("There's a drive row without a partition."); + partition_method_manual_error_label.set_widget_name("err2"); partition_method_manual_error_label.set_visible(true); } } else { - if partition_method_manual_error_label.label() == "There's a drive row without a partition." + if partition_method_manual_error_label.widget_name() == "err2" { partition_method_manual_error_label.set_visible(false); } @@ -541,12 +543,10 @@ fn partition_err_check( + ") Must at least be 512MBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err3"); } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to /boot/efi (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err3" { partition_method_manual_error_label.set_visible(false); } } @@ -559,12 +559,10 @@ fn partition_err_check( + ") Must at be FAT32/vFAT"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err4"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to /boot/efi (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err4" { partition_method_manual_error_label.set_visible(false); } } @@ -578,12 +576,10 @@ fn partition_err_check( + ") Must at least be 1000MBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err5"); } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to /boot (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err5" { partition_method_manual_error_label.set_visible(false); } } @@ -595,12 +591,10 @@ fn partition_err_check( + ") Cannot be FAT32/vFAT"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err6"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to /boot (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err6" { partition_method_manual_error_label.set_visible(false); } } @@ -614,16 +608,14 @@ fn partition_err_check( + ") Must at least be 25GBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err7") } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to / (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err7" { partition_method_manual_error_label.set_visible(false); } } - if partition_fs == "vfat" || partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { + if partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( &("Bad Filesystem: The partition mounted to / (/dev/".to_owned() @@ -631,12 +623,10 @@ fn partition_err_check( + ") Has an Invalid Filesystem"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err8"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to / (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err8" { partition_method_manual_error_label.set_visible(false); } } @@ -650,29 +640,25 @@ fn partition_err_check( + ") Must at least be 10GBs"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err9"); } } else { - if partition_method_manual_error_label - .label() - .contains("Small size: The partition mounted to /home (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err9" { partition_method_manual_error_label.set_visible(false); } } - if partition_fs == "vfat" { + if partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( &("Bad Filesystem: The partition mounted to /home (/dev/".to_owned() + &drivemounts.partition - + ") Cannot be FAT32/vFAT"), + + ") Has an Invalid Filesystem"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err10"); } } else { - if partition_method_manual_error_label - .label() - .contains("Bad Filesystem: The partition mounted to /home (/dev/") - { + if &partition_method_manual_error_label.widget_name() == "err10" { partition_method_manual_error_label.set_visible(false); } } @@ -686,12 +672,10 @@ fn partition_err_check( + " Is not a swap partition"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err11"); } } else { - if partition_method_manual_error_label - .label() - .contains(" Is not a swap partition") - { + if &partition_method_manual_error_label.widget_name() == "err11" { partition_method_manual_error_label.set_visible(false); } } @@ -708,12 +692,10 @@ fn partition_err_check( + " Is not a valid mountpoint"), ); partition_method_manual_error_label.set_visible(true); + partition_method_manual_error_label.set_widget_name("err12"); } } else { - if partition_method_manual_error_label - .label() - .contains(" Is not a valid mountpoint") - { + if &partition_method_manual_error_label.widget_name() == "err12" { partition_method_manual_error_label.set_visible(false); } } diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 58d7802..0f525a2 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -7,7 +7,7 @@ use glob::glob; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use crate::automatic_partitioning::automatic_partitioning; use crate::install_page::install_page; @@ -42,7 +42,7 @@ pub fn partitioning_page( // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -51,7 +51,7 @@ pub fn partitioning_page( .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -81,7 +81,7 @@ pub fn partitioning_page( // the header text for the partitioning page let partitioning_header_text = gtk::Label::builder() - .label("Choose an install method") + .label(gettext("choose_install_method")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -125,7 +125,7 @@ pub fn partitioning_page( .build(); let manual_method_button_content_image = gtk::Image::builder() - .icon_name("input-tablet") + .icon_name("org.gnome.Settings") .pixel_size(128) .margin_top(15) .margin_bottom(15) @@ -134,7 +134,7 @@ pub fn partitioning_page( .build(); let manual_method_button_content_text = gtk::Label::builder() - .label("Manually Partition The Drive") + .label(gettext("manual_partition_drive")) .margin_top(0) .margin_bottom(15) .margin_start(15) @@ -151,7 +151,7 @@ pub fn partitioning_page( .build(); let automatic_method_button_content_image = gtk::Image::builder() - .icon_name("media-playlist-shuffle") + .icon_name("builder") .pixel_size(128) .margin_top(15) .margin_bottom(15) @@ -160,7 +160,7 @@ pub fn partitioning_page( .build(); let automatic_method_button_content_text = gtk::Label::builder() - .label("Automatically Partition\nThe Drive") + .label(gettext("auto_partition_drive")) .margin_top(0) .margin_bottom(15) .margin_start(15) diff --git a/src/timezone_page/mod.rs b/src/timezone_page/mod.rs index f594bb3..e071e28 100644 --- a/src/timezone_page/mod.rs +++ b/src/timezone_page/mod.rs @@ -6,7 +6,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; use std::io::BufRead; use std::io::BufReader; @@ -27,7 +27,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -36,7 +36,7 @@ pub fn timezone_page(content_stack: >k::Stack) { .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -66,7 +66,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // the header text for the timezone page let timezone_header_text = gtk::Label::builder() - .label("Select a timezone") + .label(gettext("select_a_timezone")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -78,7 +78,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // the header icon for the timezone icon let timezone_header_icon = gtk::Image::builder() - .icon_name("clock") + .icon_name("alarm-clock") .halign(gtk::Align::Start) .hexpand(true) .pixel_size(78) @@ -106,7 +106,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // text above timezone selection box let timezone_selection_text = gtk::Label::builder() - .label("Please select a Time Zone for the system to use") + .label(gettext("please_select_timezone")) .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -117,11 +117,11 @@ pub fn timezone_page(content_stack: >k::Stack) { timezone_selection_text.add_css_class("medium_sized_text"); let timezone_selection_expander_row = adw::ExpanderRow::builder() - .title("No Time Zone selected") + .title(gettext("no_timezone_select")) .build(); let null_checkbutton = gtk::CheckButton::builder() - .label("No Time Zone selected") + .label(gettext("no_timezone_select")) .build(); let timezone_selection_expander_row_viewport = @@ -213,7 +213,7 @@ pub fn timezone_page(content_stack: >k::Stack) { // / Content stack appends //// Add the timezone_main_box as page: timezone_page, Give it nice title - content_stack.add_titled(&timezone_main_box, Some("timezone_page"), "Time Zone"); + content_stack.add_titled(&timezone_main_box, Some("timezone_page"), &gettext("timezone")); let timezone_data_buffer_clone = timezone_data_buffer.clone(); diff --git a/src/welcome_page/mod.rs b/src/welcome_page/mod.rs index 56e37f9..ea34407 100644 --- a/src/welcome_page/mod.rs +++ b/src/welcome_page/mod.rs @@ -7,7 +7,7 @@ use glib::*; /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; -use gettextrs::{gettext, LocaleCategory}; +use gettextrs::{gettext}; pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) { // the header box for the welcome page @@ -22,7 +22,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) // the header text for the welcome page let welcome_header_text = gtk::Label::builder() - .label("Welcome to PikaOS") + .label(gettext("welcome_to_pikaos")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -64,7 +64,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) .build(); let live_media_button_content_text = gtk::Label::builder() - .label("Use PikaOS in Live media") + .label(gettext("use_pikaos_in_live_media")) .margin_top(0) .margin_bottom(15) .margin_start(15) @@ -86,7 +86,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) .build(); let install_media_button_content_text = gtk::Label::builder() - .label("Install Distro to System") + .label(gettext("install_distro_to_system")) .margin_top(0) .margin_bottom(15) .margin_start(15) @@ -160,7 +160,7 @@ pub fn welcome_page(window: &adw::ApplicationWindow, content_stack: >k::Stack) // / Content stack appends //// Add the welcome_main_box as page: welcome_page, Give it nice title - content_stack.add_titled(&welcome_main_box, Some("welcome_page"), "Welcome"); + content_stack.add_titled(&welcome_main_box, Some("welcome_page"), &gettext("welcome")); install_media_button.connect_clicked(clone!(@weak content_stack => move |_| content_stack.set_visible_child_name("language_page"))); live_media_button.connect_clicked(clone!(@weak window => move |_| window.close())); From 00cadafc29b3169eadef15aca94f8ea4b91cd7ad Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 22:36:24 +0300 Subject: [PATCH 35/52] RR: Translate Manual partition page --- data/scripts/automatic-partition-install.sh | 2 + data/scripts/begin-install.sh | 2 + data/scripts/manual-partition-install.sh | 2 + data/scripts/partition-utility.sh | 2 + po/en_US.po | 83 +++++++++++++++++++++ src/automatic_partitioning/mod.rs | 2 +- src/manual_partitioning/mod.rs | 71 +++++++++--------- 7 files changed, 127 insertions(+), 37 deletions(-) diff --git a/data/scripts/automatic-partition-install.sh b/data/scripts/automatic-partition-install.sh index f5d3c27..2fa961e 100644 --- a/data/scripts/automatic-partition-install.sh +++ b/data/scripts/automatic-partition-install.sh @@ -1,5 +1,7 @@ #! /bin/bash +export LANG=en_US.UTF8 + set -e DISK="$(cat "/tmp/pika-installer-gtk4-target-auto.txt")" diff --git a/data/scripts/begin-install.sh b/data/scripts/begin-install.sh index 5f2bc3f..9cd80b6 100644 --- a/data/scripts/begin-install.sh +++ b/data/scripts/begin-install.sh @@ -1,5 +1,7 @@ #! /bin/bash +export LANG=en_US.UTF8 + exec &> >(tee /tmp/pika-installer-gtk4-log) if [[ -f /tmp/pika-installer-gtk4-target-manual.txt ]] diff --git a/data/scripts/manual-partition-install.sh b/data/scripts/manual-partition-install.sh index 8055830..cbb164e 100644 --- a/data/scripts/manual-partition-install.sh +++ b/data/scripts/manual-partition-install.sh @@ -1,5 +1,7 @@ #! /bin/bash +export LANG=en_US.UTF8 + set -e LOCALE="$(cat "/tmp/pika-installer-gtk4-lang.txt")" diff --git a/data/scripts/partition-utility.sh b/data/scripts/partition-utility.sh index 28b48da..171e457 100755 --- a/data/scripts/partition-utility.sh +++ b/data/scripts/partition-utility.sh @@ -1,5 +1,7 @@ #! /bin/bash +export LANG=en_US.UTF8 + if [[ "$1" = "get_block_devices" ]] then lsblk -dn -o NAME | grep -v -i -E 'loop|zram|sr|cdrom|portal' diff --git a/po/en_US.po b/po/en_US.po index cbd9793..f72547c 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -54,3 +54,86 @@ msgstr "Manually Partition The Drive" msgid "auto_partition_drive" msgstr "Automatically Partition\nThe Drive" +msgid "manual_part_installer" +msgstr "Manual Partitioning Installer" + +msgid "use_utility_manual" +msgstr "Use this utility to partition/mount/format your drives." + +msgid "open_gparted" +msgstr "Open GPARTED" + +msgid "manual_part_note" +msgstr "\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n " + +msgid "refresh_part_table" +msgstr "Refresh Partition Table" + +msgid "validate_fs_table" +msgstr "Validate Filesystem Table" + +msgid "fstab_status_valid" +msgstr "Filesystem Table Status: All entries are valid!" + +msgid "part_need_mapper" +msgstr "This partition needs a mapper!" + +msgid "fstab_subvol_warn" +msgstr "Filesystem Table Warning: Partition reuse check will be skipped due to subvol usage." + +msgid "fstab_multiple_part_mountpoint_err" +msgstr "Filesystem Table Error: Multiple partitions are configured to the same mountpoint!" + +msgid "fstab_no_mountpoint_err" +msgstr "Filesystem Table Error: One or more partitions don't have a mountpoint configured!" + +msgid "fstab_no_partition_err" +msgstr "Filesystem Table Error: One or more entries don't have a partition configured!" + +msgid "fstab_badfs" +msgstr "Filesystem Table Error: Invalid filesystem: (/dev/" + +msgstr "fstab_small_efi_err" +msgstr "Filesystem Table Error: Small size: The partition mounted to /boot/efi (/dev/" + +msgid "fstab_small_efi_size" +msgstr ") Must at least be 512MBs!" + +msgid "fstab_badfs_efi" +msgstr ") Must be FAT32/vFAT to be mounted at /boot/efi!" + +msgstr "fstab_small_boot_err" +msgstr "Filesystem Table Error: Small size: The partition mounted to /boot (/dev/" + +msgid "fstab_small_boot_size" +msgstr ") Must at least be 1GBs!" + +msgid "fstab_badfs_boot" +msgstr ") Must not be FAT32/vFAT to be mounted at /boot!" + +msgstr "fstab_small_root_err" +msgstr "Filesystem Table Error: Small size: The partition mounted to / (/dev/" + +msgid "fstab_small_root_size" +msgstr ") Must at least be 26GBs!" + +msgid "fstab_badfs_root" +msgstr ") Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs to be mounted at /!" + +msgstr "fstab_small_home_err" +msgstr "Filesystem Table Error: Small size: The partition mounted to /home (/dev/" + +msgid "fstab_small_home_size" +msgstr ") Must at least be 11GBs!" + +msgid "fstab_badfs_home" +msgstr ") Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs to be mounted at /home!" + +msgid "fstab_badfs_swap" +msgstr ") Must not be swap to be used as [SWAP]!" + +msgid "fstab_bad_mountpoint" +msgstr "Filesystem Table Error: Invalid mountpoint: (" + +msgid "fstab_bad_mountpoint_msg" +msgstr ") Is not a valid mountpoint!" \ No newline at end of file diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index 85eada3..b50da21 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -43,7 +43,7 @@ pub fn automatic_partitioning( // the header icon for the partitioning icon let partition_method_automatic_header_icon = gtk::Image::builder() - .icon_name("media-playlist-shuffle") + .icon_name("builder") .halign(gtk::Align::Start) .hexpand(true) .pixel_size(78) diff --git a/src/manual_partitioning/mod.rs b/src/manual_partitioning/mod.rs index 03a1214..4e5bc4c 100644 --- a/src/manual_partitioning/mod.rs +++ b/src/manual_partitioning/mod.rs @@ -84,7 +84,7 @@ fn create_mount_row( .activatable_widget(&partition_button) .title(partition.clone()) .name(partition.clone()) - .subtitle("This partition needs a mapper!") + .subtitle(gettext("part_need_mapper")) .build(); prow } else { @@ -151,7 +151,7 @@ pub fn manual_partitioning( // the header text for the partitioning page let partition_method_manual_header_text = gtk::Label::builder() - .label("Manual Partitioning Installer") + .label(gettext("manual_part_installer")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -163,7 +163,7 @@ pub fn manual_partitioning( // the header icon for the partitioning icon let partition_method_manual_header_icon = gtk::Image::builder() - .icon_name("input-tablet") + .icon_name("org.gnome.Settings") .halign(gtk::Align::Start) .hexpand(true) .pixel_size(78) @@ -182,11 +182,11 @@ pub fn manual_partitioning( .build(); let partition_method_manual_gparted_button_content_text = gtk::Label::builder() - .label("Use this utility to partition/mount/format your drives.") + .label(gettext("use_utility_manual")) .build(); let partition_method_manual_gparted_button_content = adw::ButtonContent::builder() - .label("Open GPARTED") + .label(gettext("open_gparted")) .icon_name("gparted") .build(); @@ -216,7 +216,7 @@ pub fn manual_partitioning( .build(); let partition_method_manual_selection_text = gtk::Label::builder() - .label("\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n ") + .label(gettext("manual_part_note")) .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -227,13 +227,13 @@ pub fn manual_partitioning( partition_method_manual_selection_text.add_css_class("medium_sized_text"); let partition_refresh_button = gtk::Button::builder() - .label("Refresh Partition Table") + .label(gettext("refresh_part_table")) .halign(gtk::Align::End) .build(); partition_refresh_button.add_css_class("destructive-action"); let fstab_valid_check = gtk::Button::builder() - .label("Validate Filesystem Table") + .label(gettext("validate_fs_table")) .halign(gtk::Align::Start) .build(); fstab_valid_check.add_css_class("valid-action"); @@ -257,7 +257,7 @@ pub fn manual_partitioning( .valign(Align::End) .vexpand(true) .visible(false) - .label("Filesystem Table is valid!") + .label(gettext("fstab_status_valid")) .build(); partition_method_manual_valid_label.add_css_class("small_valid_text"); @@ -366,13 +366,13 @@ pub fn manual_partitioning( if *check_part_unique.borrow_mut() == true { row_scrw.set_sensitive(false) - } else if row_scrw.property::("subtitle").contains("This partition needs a mapper!") { + } else if row_scrw.property::("subtitle").contains(&gettext("part_need_mapper")) { row_scrw.set_sensitive(false) } else { row_scrw.set_sensitive(true) } } - else if row_scrw.property::("subtitle").contains("This partition needs a mapper!") { + else if row_scrw.property::("subtitle").contains(&gettext("part_need_mapper")) { row_scrw.set_sensitive(false) } else { row_scrw.set_sensitive(true) @@ -397,7 +397,7 @@ pub fn manual_partitioning( if *check_part_unique.borrow_mut() == false { partition_method_manual_warn_label - .set_label("Partition reuse check will be skipped due to subvol usage."); + .set_label(&gettext("fstab_subvol_warn")); partition_method_manual_warn_label.set_visible(true); } else { partition_method_manual_warn_label.set_visible(false); @@ -474,7 +474,7 @@ fn partition_err_check( { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label - .set_label("Multiple drives were mounted to the same mountpoint."); + .set_label(&gettext("fstab_multiple_part_mountpoint_err")); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err0"); } @@ -486,7 +486,7 @@ fn partition_err_check( } else { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label - .set_label("Some drives don't have a mountpoint configured."); + .set_label(&gettext("fstab_no_mountpoint_err")); partition_method_manual_error_label.set_widget_name("err1"); partition_method_manual_error_label.set_visible(true); } @@ -495,7 +495,7 @@ fn partition_err_check( if empty_partition == true { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label - .set_label("There's a drive row without a partition."); + .set_label(&gettext("fstab_no_partition_err")); partition_method_manual_error_label.set_widget_name("err2"); partition_method_manual_error_label.set_visible(true); } @@ -538,9 +538,9 @@ fn partition_err_check( if partition_size < 500000000.0 { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Small size: The partition mounted to /boot/efi (/dev/".to_owned() + &(gettext("fstab_small_efi_err") + &drivemounts.partition - + ") Must at least be 512MBs"), + + &gettext("fstab_small_efi_size")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err3"); @@ -553,10 +553,9 @@ fn partition_err_check( if partition_fs != "vfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Bad Filesystem: The partition mounted to /boot/efi (/dev/" - .to_owned() + &(gettext("fstab_badfs") + &drivemounts.partition - + ") Must at be FAT32/vFAT"), + + &gettext("fstab_badfs_efi")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err4"); @@ -571,9 +570,9 @@ fn partition_err_check( if partition_size < 1000000000.0 { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Small size: The partition mounted to /boot (/dev/".to_owned() + &(gettext("fstab_small_boot_err") + &drivemounts.partition - + ") Must at least be 1000MBs"), + + &gettext("fstab_small_boot_size")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err5"); @@ -586,9 +585,9 @@ fn partition_err_check( if partition_fs == "vfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Bad Filesystem: The partition mounted to /boot (/dev/".to_owned() + &(gettext("fstab_badfs") + &drivemounts.partition - + ") Cannot be FAT32/vFAT"), + + &gettext("fstab_badfs_boot")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err6"); @@ -603,9 +602,9 @@ fn partition_err_check( if partition_size < 25000000000.0 { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Small size: The partition mounted to / (/dev/".to_owned() + &(gettext("fstab_small_root_err") + &drivemounts.partition - + ") Must at least be 25GBs"), + + &gettext("fstab_small_root_size")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err7") @@ -618,9 +617,9 @@ fn partition_err_check( if partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Bad Filesystem: The partition mounted to / (/dev/".to_owned() + &(gettext("fstab_badfs") + &drivemounts.partition - + ") Has an Invalid Filesystem"), + + &gettext("fstab_badfs_root")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err8"); @@ -635,9 +634,9 @@ fn partition_err_check( if partition_size < 10000000000.0 { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Small size: The partition mounted to /home (/dev/".to_owned() + &(gettext("fstab_small_home_err") + &drivemounts.partition - + ") Must at least be 10GBs"), + + &gettext("fstab_small_home_size")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err9"); @@ -650,9 +649,9 @@ fn partition_err_check( if partition_fs == "vfat" || partition_fs == "ntfs" || partition_fs == "swap" || partition_fs == "exfat" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Bad Filesystem: The partition mounted to /home (/dev/".to_owned() + &(gettext("fstab_badfs") + &drivemounts.partition - + ") Has an Invalid Filesystem"), + + &gettext("fstab_badfs_home")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err10"); @@ -667,9 +666,9 @@ fn partition_err_check( if partition_fs != "swap" { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Bad Filesystem: ".to_owned() + &(gettext("fstab_badfs") + &drivemounts.partition - + " Is not a swap partition"), + + &gettext("fstab_badfs_swap")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err11"); @@ -687,9 +686,9 @@ fn partition_err_check( { if !partition_method_manual_error_label.is_visible() { partition_method_manual_error_label.set_label( - &("Bad Mountpoint: ".to_owned() + &(gettext("fstab_bad_mountpoint") + &drivemounts.mountpoint - + " Is not a valid mountpoint"), + + &gettext("fstab_bad_mountpoint_msg")), ); partition_method_manual_error_label.set_visible(true); partition_method_manual_error_label.set_widget_name("err12"); From c05bb7cc82b25ced4d33a02e9be488dd81abbe42 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 22:44:49 +0300 Subject: [PATCH 36/52] RR: Translate Language page --- po/en_US.po | 14 +++++++++++++- src/language_page/mod.rs | 14 +++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index f72547c..6f96a30 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -136,4 +136,16 @@ msgid "fstab_bad_mountpoint" msgstr "Filesystem Table Error: Invalid mountpoint: (" msgid "fstab_bad_mountpoint_msg" -msgstr ") Is not a valid mountpoint!" \ No newline at end of file +msgstr ") Is not a valid mountpoint!" + +msgid "select_a_language" +msgstr "Select a language" + +msgid "please_select_locale" +msgstr "Please select a locale for the system to use" + +msgid "no_locale_selected" +msgstr "No locale selected" + +msgid "language" +msgid "Language" \ No newline at end of file diff --git a/src/language_page/mod.rs b/src/language_page/mod.rs index 2712301..d21373c 100644 --- a/src/language_page/mod.rs +++ b/src/language_page/mod.rs @@ -27,7 +27,7 @@ pub fn language_page(content_stack: >k::Stack) { // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -36,7 +36,7 @@ pub fn language_page(content_stack: >k::Stack) { .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -66,7 +66,7 @@ pub fn language_page(content_stack: >k::Stack) { // the header text for the language page let language_header_text = gtk::Label::builder() - .label("Select a language") + .label(gettext("select_a_language")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -106,7 +106,7 @@ pub fn language_page(content_stack: >k::Stack) { // text above language selection box let language_selection_text = gtk::Label::builder() - .label("Please select a locale for the system to use") + .label(gettext("please_select_locale")) .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -117,11 +117,11 @@ pub fn language_page(content_stack: >k::Stack) { language_selection_text.add_css_class("medium_sized_text"); let language_selection_expander_row = adw::ExpanderRow::builder() - .title("No locale selected") + .title(gettext("no_locale_selected")) .build(); let null_checkbutton = gtk::CheckButton::builder() - .label("No locale selected") + .label(gettext("no_locale_selected")) .build(); let language_selection_expander_row_viewport = @@ -213,7 +213,7 @@ pub fn language_page(content_stack: >k::Stack) { // / Content stack appends //// Add the language_main_box as page: language_page, Give it nice title - content_stack.add_titled(&language_main_box, Some("language_page"), "Language"); + content_stack.add_titled(&language_main_box, Some("language_page"), &gettext("language")); let lang_data_buffer_clone = lang_data_buffer.clone(); From 7c112db4e3de30188a9021a9eec6f83c197301f2 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 23:44:12 +0300 Subject: [PATCH 37/52] RR: Translate Install Page --- po/en_US.po | 80 +++++++++++++++++++++++++++++++++++++++- src/install_page/mod.rs | 46 +++++++++++------------ src/keyboard_page/mod.rs | 16 ++++---- 3 files changed, 110 insertions(+), 32 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index 6f96a30..0d6b263 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -148,4 +148,82 @@ msgid "no_locale_selected" msgstr "No locale selected" msgid "language" -msgid "Language" \ No newline at end of file +msgstr "Language" + +msgid "select_a_keyboard" +msgstr "Select a keyboard" + +msgid "please_select_keyboard" +msgstr "Please select a Keyboard layout for the system to use" + +msgid "no_keyboard_selected" +msgstr "No Keyboard Layout selected" + +msgid "test_you_keyboard" +msgstr "Test Your Keyboard here!" + +msgid "keyboard" +msgstr "Keyboard" + +msgid "luks_password_for" +msgstr "LUKS Password for " + +msgid "luks_how_should" +msgstr "How should " + +msgid "be_added_crypttab" +msgstr " be added to /etc/crypttab?" + +msgid "unlock_boot_manually" +msgstr "Unlock on boot manually" + +msgid "unlock_boot_manual" +msgstr "Automatic Unlock with root unlock" + +msgid "sit_back_relax" +msgstr "Sit back, Relax, and watch the show." + +msgid "language_detail" +msgstr "Language:" + +msgid "timezone_detail" +msgstr "Timezone:" + +msgid "keyboard_detail" +msgstr "Keyboard layout:" + +msgid "mounted_on_detail" +msgstr " mounted on " + +msgid "install_target_detail" +msgstr "Install Target:" + +msgid "confirm_install_pika" +msgstr "Confirm & Install PikaOS" + +msgid "view_logs" +msgstr "View Logs" + +msgid "parting_status_text" +msgstr "Partitioning The Target Drives." + +msgid "image_status_text" +msgstr "Writing image to target." + +msgid "flag1_status_text" +msgstr "Enabling bls_boot flag on /boot." + +msgid "flag2_status_text" +msgstr "Enabling efi flag on /boot/efi." + +msgid "crypt_status_text" +msgstr "Setting up encryption crypttab." + +msgid "lang_status_text" +msgstr "Setting Up Language and Keyboard." + +msgid "boot_status_status_text" +msgstr "Configuring bootloader." + +msgid "post_status_text" +msgstr "Running post installation script." \ No newline at end of file diff --git a/src/install_page/mod.rs b/src/install_page/mod.rs index d3157e4..6b0adf3 100644 --- a/src/install_page/mod.rs +++ b/src/install_page/mod.rs @@ -61,7 +61,7 @@ pub fn install_page( .build(); crypttab_password_listbox.add_css_class("boxed-list"); let crypttab_password = adw::PasswordEntryRow::builder() - .title("LUKS Password for ".to_owned() + &partitions.partition) + .title(gettext("luks_password_for") + &partitions.partition) .build(); crypttab_password.set_show_apply_button(true); crypttab_password_listbox.append(&crypttab_password); @@ -72,14 +72,14 @@ pub fn install_page( .width_request(400) .height_request(200) .heading( - "How should ".to_owned() + gettext("luks_how_should") + &partitions.partition - + " be added to /etc/crypttab?", + + &gettext("be_added_crypttab"), ) .build(); - crypttab_dialog.add_response("crypttab_dialog_boot", "Unlock on boot manually"); + crypttab_dialog.add_response("crypttab_dialog_boot", &gettext("unlock_boot_manually")); crypttab_dialog - .add_response("crypttab_dialog_auto", "Automatic Unlock with root unlock"); + .add_response("crypttab_dialog_auto", &gettext("unlock_boot_manual")); crypttab_dialog.set_response_enabled("crypttab_dialog_auto", false); crypttab_password.connect_apply(clone!(@weak crypttab_password, @strong partitions, @weak crypttab_dialog => move |_| { let (luks_manual_password_sender, luks_manual_password_receiver) = async_channel::unbounded(); @@ -163,7 +163,7 @@ pub fn install_page( // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -191,7 +191,7 @@ pub fn install_page( // the header text for the install page let install_confirm_header_text = gtk::Label::builder() - .label("Sit back, Relax, and watch the show.") + .label(gettext("sit_back_relax")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -233,7 +233,7 @@ pub fn install_page( install_confirm_details_boxed_list.add_css_class("boxed-list"); let install_confirm_detail_language = adw::ActionRow::builder() - .title("Language:") + .title(gettext("language_detail")) .subtitle( fs::read_to_string("/tmp/pika-installer-gtk4-lang.txt").expect("Unable to read file"), ) @@ -241,7 +241,7 @@ pub fn install_page( install_confirm_detail_language.add_css_class("property"); let install_confirm_detail_timezone = adw::ActionRow::builder() - .title("Time zone:") + .title(gettext("timezone_detail")) .subtitle( fs::read_to_string("/tmp/pika-installer-gtk4-timezone.txt") .expect("Unable to read file"), @@ -250,7 +250,7 @@ pub fn install_page( install_confirm_detail_timezone.add_css_class("property"); let install_confirm_detail_keyboard = adw::ActionRow::builder() - .title("Keyboard layout:") + .title(gettext("keyboard_detail")) .subtitle( fs::read_to_string("/tmp/pika-installer-gtk4-keyboard.txt") .expect("Unable to read file"), @@ -268,15 +268,15 @@ pub fn install_page( .title( "/dev/".to_owned() + &partitions.partition - + " mounted on " - + &partitions.mountpoint, + + &gettext("mounted_on_detail") + + &partitions.mountpoint ) .build(); install_confirm_details_boxed_list.append(&confirm_row); } } else { let install_confirm_detail_target = - adw::ActionRow::builder().title("Install Target:").build(); + adw::ActionRow::builder().title(gettext("install_target_detail")).build(); install_confirm_detail_target.set_subtitle( &fs::read_to_string("/tmp/pika-installer-gtk4-target-auto.txt") .expect("Unable to read file"), @@ -369,7 +369,7 @@ pub fn install_page( } let install_confirm_button = gtk::Button::builder() - .label("Confirm & Install PikaOS") + .label(gettext("confirm_install_pika")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .build(); @@ -454,7 +454,7 @@ pub fn install_page( .build(); let progress_log_button_content = adw::ButtonContent::builder() - .label("View Logs") + .label(gettext("view_logs")) .icon_name("terminal") .build(); @@ -564,7 +564,7 @@ fn begin_install( if parting_status_state == true { println!("Installation status: Parting"); install_progress_bar.set_fraction(0.20); - install_progress_bar.set_text(Some("Partitioning The Disk Target.")); + install_progress_bar.set_text(Some(&gettext("parting_status_text"))); } } })); @@ -591,7 +591,7 @@ fn begin_install( if image_status_state == true { println!("Installation status: Imaging"); install_progress_bar.set_fraction(0.60); - install_progress_bar.set_text(Some("Writing image to target.")); + install_progress_bar.set_text(Some(&gettext("image_status_text"))); } } })); @@ -618,7 +618,7 @@ fn begin_install( if flag1_status_state == true { println!("Installation status: Flag1"); install_progress_bar.set_fraction(0.65); - install_progress_bar.set_text(Some("Enabling bls_boot flag on /boot.")); + install_progress_bar.set_text(Some(&gettext("flag1_status_text"))); } } })); @@ -645,7 +645,7 @@ fn begin_install( if flag2_status_state == true { println!("Installation status: Flag2"); install_progress_bar.set_fraction(0.70); - install_progress_bar.set_text(Some("Enabling efi flag on /boot/efi.")); + install_progress_bar.set_text(Some(&gettext("flag2_status_text"))); } } })); @@ -672,7 +672,7 @@ fn begin_install( if crypt_status_state == true { println!("Installation status: Crypttab"); install_progress_bar.set_fraction(0.75); - install_progress_bar.set_text(Some("Setting up encryption crypttab.")); + install_progress_bar.set_text(Some(&gettext("crypt_status_text"))); } } })); @@ -699,7 +699,7 @@ fn begin_install( if lang_status_state == true { println!("Installation status: Language"); install_progress_bar.set_fraction(0.80); - install_progress_bar.set_text(Some("Setting Up Language and Keyboard.")); + install_progress_bar.set_text(Some(&gettext("lang_status_text"))); } } })); @@ -726,7 +726,7 @@ fn begin_install( if boot_status_state == true { println!("Installation status: Bootloader"); install_progress_bar.set_fraction(0.85); - install_progress_bar.set_text(Some("Configuring bootloader.")); + install_progress_bar.set_text(Some(&gettext("boot_status_status_text"))); } } })); @@ -753,7 +753,7 @@ fn begin_install( if post_status_state == true { println!("Installation status: Post Install"); install_progress_bar.set_fraction(0.90); - install_progress_bar.set_text(Some("Running post installation script.")); + install_progress_bar.set_text(Some(&gettext("post_status_text"))); } } })); diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index 3d394dd..ffff257 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -27,7 +27,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -36,7 +36,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -66,7 +66,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { // the header text for the keyboard page let keyboard_header_text = gtk::Label::builder() - .label("Select a keyboard") + .label(gettext("select_a_keyboard")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -106,7 +106,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { // text above keyboard selection box let keyboard_selection_text = gtk::Label::builder() - .label("Please select a Keyboard layout for the system to use") + .label(gettext("please_select_keyboard")) .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -117,11 +117,11 @@ pub fn keyboard_page(content_stack: >k::Stack) { keyboard_selection_text.add_css_class("medium_sized_text"); let keyboard_selection_expander_row = adw::ExpanderRow::builder() - .title("No Keyboard Layout selected") + .title(gettext("no_keyboard_selected")) .build(); let null_checkbutton = gtk::CheckButton::builder() - .label("No Keyboard Layout selected") + .label(gettext("no_keyboard_selected")) .build(); let keyboard_selection_expander_row_viewport = @@ -234,7 +234,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { .margin_top(15) .margin_end(15) .margin_start(15) - .placeholder_text("Test Your Keyboard here!") + .placeholder_text(gettext("test_you_keyboard")) .build(), ); @@ -242,7 +242,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { // / Content stack appends //// Add the keyboard_main_box as page: keyboard_page, Give it nice title - content_stack.add_titled(&keyboard_main_box, Some("keyboard_page"), "Keyboard"); + content_stack.add_titled(&keyboard_main_box, Some("keyboard_page"), &gettext("keyboard")); let keyboard_data_buffer_clone = keyboard_data_buffer.clone(); From 3fbeefaedf76761376e868833d035f027a4007de Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Sun, 18 Feb 2024 23:57:27 +0300 Subject: [PATCH 38/52] RR: Translate Eula Page --- po/en_US.po | 69 +++++++++++++++++++++++++++++----------- src/eula_page/mod.rs | 25 ++++----------- src/keyboard_page/mod.rs | 2 +- 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index 0d6b263..9733379 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" -"PO-Revision-Date: 2024-02-09 17:55+0300\n" +"PO-Revision-Date: 2024-02-18 23:53+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -52,7 +52,9 @@ msgid "manual_partition_drive" msgstr "Manually Partition The Drive" msgid "auto_partition_drive" -msgstr "Automatically Partition\nThe Drive" +msgstr "" +"Automatically Partition\n" +"The Drive" msgid "manual_part_installer" msgstr "Manual Partitioning Installer" @@ -64,7 +66,17 @@ msgid "open_gparted" msgstr "Open GPARTED" msgid "manual_part_note" -msgstr "\n - Press the plus button below to begin adding filesystem entries.\nNotes:\n - This installer doesn't erase any data automatically, format your drives manually via gparted.\n - To Add a linux-swap partition set mountpoint to [SWAP]\n - We recommend the following partitions as a base layout:\n /boot ~ 1000mb ext4.\n /boot/efi ~ 512mb vfat/fat32.\n / >= 25GB btrfs.\n " +msgstr "" +"\n" +" - Press the plus button below to begin adding filesystem entries.\n" +"Notes:\n" +" - This installer doesn't erase any data automatically, format your drives manually via gparted.\n" +" - To Add a linux-swap partition set mountpoint to [SWAP]\n" +" - We recommend the following partitions as a base layout:\n" +" /boot ~ 1000mb ext4.\n" +" /boot/efi ~ 512mb vfat/fat32.\n" +" / >= 25GB btrfs.\n" +" " msgid "refresh_part_table" msgstr "Refresh Partition Table" @@ -93,41 +105,33 @@ msgstr "Filesystem Table Error: One or more entries don't have a partition confi msgid "fstab_badfs" msgstr "Filesystem Table Error: Invalid filesystem: (/dev/" -msgstr "fstab_small_efi_err" -msgstr "Filesystem Table Error: Small size: The partition mounted to /boot/efi (/dev/" - msgid "fstab_small_efi_size" msgstr ") Must at least be 512MBs!" msgid "fstab_badfs_efi" msgstr ") Must be FAT32/vFAT to be mounted at /boot/efi!" -msgstr "fstab_small_boot_err" -msgstr "Filesystem Table Error: Small size: The partition mounted to /boot (/dev/" - msgid "fstab_small_boot_size" msgstr ") Must at least be 1GBs!" msgid "fstab_badfs_boot" msgstr ") Must not be FAT32/vFAT to be mounted at /boot!" -msgstr "fstab_small_root_err" -msgstr "Filesystem Table Error: Small size: The partition mounted to / (/dev/" - msgid "fstab_small_root_size" msgstr ") Must at least be 26GBs!" msgid "fstab_badfs_root" -msgstr ") Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs to be mounted at /!" - -msgstr "fstab_small_home_err" -msgstr "Filesystem Table Error: Small size: The partition mounted to /home (/dev/" +msgstr "" +") Must be a Linux* compatible filesystem such as:\n" +" ext4/btrfs/xfs/f2fs to be mounted at /!" msgid "fstab_small_home_size" msgstr ") Must at least be 11GBs!" msgid "fstab_badfs_home" -msgstr ") Must be a Linux* compatible filesystem such as:\n ext4/btrfs/xfs/f2fs to be mounted at /home!" +msgstr "" +") Must be a Linux* compatible filesystem such as:\n" +" ext4/btrfs/xfs/f2fs to be mounted at /home!" msgid "fstab_badfs_swap" msgstr ") Must not be swap to be used as [SWAP]!" @@ -159,7 +163,7 @@ msgstr "Please select a Keyboard layout for the system to use" msgid "no_keyboard_selected" msgstr "No Keyboard Layout selected" -msgid "test_you_keyboard" +msgid "test_your_keyboard" msgstr "Test Your Keyboard here!" msgid "keyboard" @@ -226,4 +230,31 @@ msgid "boot_status_status_text" msgstr "Configuring bootloader." msgid "post_status_text" -msgstr "Running post installation script." \ No newline at end of file +msgstr "Running post installation script." + +msgid "pikaos_eula_agreement" +msgstr "PikaOS User license Agreement" + +msgid "please_read_eula" +msgstr "Please carefully read and make sure you consent to the following before installing PikaOS:" + +msgid "eula_buffer" +msgstr "" +"There are a few things to keep in mind: \n" +" 1 - You understand that this distribution is -NOT- to be considered an ‘Ubuntu Flavor’. \n" +" 2 - This is a hobby distribution, so we will try our best to provide formal support but it will -NOT- be guaranteed. \n" +" 3 - Although PikaOS might provide identical patches and user experience to the Nobara project, we are -NOT- directly a part of them so questions and bug reports should not be sent directly to them (they dont have to deal with it!) \n" +" 4 - While the installer is running DO NOT INTERRUPT IT! or you will end up with a corrupted system. \n" +" 5 - Try to use pikman instead of apt when using the terminal, it is much faster! \n" +" 6 - You understand the xone driver downloads needed binaries locally and does not directly package or distribute any copyrighted firmware or other related data. \n" +" 7 - Automatic partitioning will format all partitons on a drive, so if you want to dualboot make a separate EFI partition for PikaOS and use manual partitioning \n" +" 8 - In case you need the login info for this session: \n" +" - username: pikaos \n" +" - password: \n" +" MEANING: JUST PRESS ENTER" + +msgid "i_agree_eula" +msgstr "I Agree and Accept the User license Agreement" + +msgid "eula" +msgstr "EULA" diff --git a/src/eula_page/mod.rs b/src/eula_page/mod.rs index 293ede4..1618da2 100644 --- a/src/eula_page/mod.rs +++ b/src/eula_page/mod.rs @@ -18,7 +18,7 @@ pub fn eula_page(content_stack: >k::Stack) { // Next and back button let bottom_back_button = gtk::Button::builder() - .label("Back") + .label(gettext("back")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -27,7 +27,7 @@ pub fn eula_page(content_stack: >k::Stack) { .hexpand(true) .build(); let bottom_next_button = gtk::Button::builder() - .label("Next") + .label(gettext("next")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -57,7 +57,7 @@ pub fn eula_page(content_stack: >k::Stack) { // the header text for the eula page let eula_header_text = gtk::Label::builder() - .label("PikaOS User license Agreement") + .label(gettext("pikaos_eula_agreement")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -97,7 +97,7 @@ pub fn eula_page(content_stack: >k::Stack) { // text above eula selection box let eula_selection_text = gtk::Label::builder() - .label("Please carefully read and make sure you consent to the following before installing PikaOS:") + .label(gettext("please_read_eula")) .halign(gtk::Align::Center) .hexpand(true) .margin_top(15) @@ -108,18 +108,7 @@ pub fn eula_page(content_stack: >k::Stack) { eula_selection_text.add_css_class("medium_sized_text"); let eula_buffer = gtk::TextBuffer::builder() - .text("There are a few things to keep in mind: - 1 - You understand that this distribution is -NOT- to be considered an ‘Ubuntu Flavor’. - 2 - This is a hobby distribution, so we will try our best to provide formal support but it will -NOT- be guaranteed. - 3 - Although PikaOS might provide identical patches and user experience to the Nobara project, we are -NOT- directly a part of them so questions and bug reports should not be sent directly to them (they dont have to deal with it!) - 4 - While the installer is running DO NOT INTERRUPT IT! or you will end up with a corrupted system. - 5 - Try to use pikman instead of apt when using the terminal, it is much faster! - 6 - You understand the xone driver downloads needed binaries locally and does not directly package or distribute any copyrighted firmware or other related data. - 7 - Automatic partitioning will format all partitons on a drive, so if you want to dualboot make a separate EFI partition for PikaOS and use manual partitioning - 8 - In case you need the login info for this session: - - username: pikaos - - password: - MEANING: JUST PRESS ENTER") + .text(gettext("eula_buffer")) .build(); let eula_selection_text_view = gtk::TextView::builder() @@ -139,7 +128,7 @@ pub fn eula_page(content_stack: >k::Stack) { .build(); let eula_accept_checkbutton = gtk::CheckButton::builder() - .label("I Agree and Accept the User license Agreement") + .label(gettext("i_agree_eula")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -167,7 +156,7 @@ pub fn eula_page(content_stack: >k::Stack) { // / Content stack appends //// Add the eula_main_box as page: eula_page, Give it nice title - content_stack.add_titled(&eula_main_box, Some("eula_page"), "EULA"); + content_stack.add_titled(&eula_main_box, Some("eula_page"), &gettext("eula")); eula_accept_checkbutton.connect_toggled( clone!(@weak eula_accept_checkbutton, @weak bottom_next_button => move |_| { diff --git a/src/keyboard_page/mod.rs b/src/keyboard_page/mod.rs index ffff257..8012a92 100644 --- a/src/keyboard_page/mod.rs +++ b/src/keyboard_page/mod.rs @@ -234,7 +234,7 @@ pub fn keyboard_page(content_stack: >k::Stack) { .margin_top(15) .margin_end(15) .margin_start(15) - .placeholder_text(gettext("test_you_keyboard")) + .placeholder_text(gettext("test_your_keyboard")) .build(), ); From 6e7fb5723d2ba50297ef8fab4b9079b263b3d330 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Mon, 19 Feb 2024 00:09:21 +0300 Subject: [PATCH 39/52] RR: Translate Done Page --- po/en_US.po | 30 ++++++++++++++++++++++++++++++ src/done_page/mod.rs | 12 ++++++------ src/drive_mount_row/imp.rs | 6 +++--- src/efi_error_page/mod.rs | 12 ++++++------ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index 9733379..ef7203b 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -258,3 +258,33 @@ msgstr "I Agree and Accept the User license Agreement" msgid "eula" msgstr "EULA" + +msgid "bad_boot_platfrom" +msgstr Unsupported boot platform + +msgid "pika_nowork_csm" +msgstr "PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode." + +msgid "exit" +msgstr "Exit" + +msgid "subtitle_partition" +msgstr "Partition" + +msgid "title_mountpoint" +msgstr "Mountpoint" + +msgid "title_mountopt" +msgstr "Additional Mount Options" + +msgid "pika_install_good" +msgstr "The installation of PikaOS has been completed sucessfully." + +msgid "reboot" +msgstr "Reboot" + +msgid "pika_install_bad" +msgstr "PikaOS has Failed!\nCheck logs for further info." + +msgid "logs" +msgstr "Logs" \ No newline at end of file diff --git a/src/done_page/mod.rs b/src/done_page/mod.rs index f969cdd..2e30699 100644 --- a/src/done_page/mod.rs +++ b/src/done_page/mod.rs @@ -72,7 +72,7 @@ pub fn done_page( .build(); let installation_successful_text = gtk::Label::builder() - .label("The installation of PikaOS has been completed sucessfully.") + .label(gettext("pika_install_good")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .build(); @@ -89,7 +89,7 @@ pub fn done_page( .build(); let installation_successful_exit_button = gtk::Button::builder() - .label("Exit") + .label(gettext("exit")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .margin_start(5) @@ -97,7 +97,7 @@ pub fn done_page( .build(); let installation_successful_reboot_button = gtk::Button::builder() - .label("Reboot") + .label(gettext("reboot")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .margin_start(5) @@ -162,7 +162,7 @@ pub fn done_page( .build(); let installation_failed_text = gtk::Label::builder() - .label("PikaOS has Failed!\nCheck logs for further info.") + .label(gettext("pika_install_bad")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .build(); @@ -179,7 +179,7 @@ pub fn done_page( .build(); let installation_failed_exit_button = gtk::Button::builder() - .label("Exit") + .label(gettext("exit")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .margin_start(5) @@ -187,7 +187,7 @@ pub fn done_page( .build(); let installation_failed_logs_button = gtk::Button::builder() - .label("Logs") + .label(gettext("logs")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .margin_start(5) diff --git a/src/drive_mount_row/imp.rs b/src/drive_mount_row/imp.rs index 5cb2baf..4f3bf52 100644 --- a/src/drive_mount_row/imp.rs +++ b/src/drive_mount_row/imp.rs @@ -66,7 +66,7 @@ impl ObjectImpl for DriveMountRow { partition_row_expander_adw_listbox.add_css_class("boxed-list"); let partition_row_expander = adw::ExpanderRow::builder() - .subtitle("Partition") + .subtitle(gettext("subtitle_partition")) .vexpand(true) .hexpand(true) .width_request(300) @@ -87,7 +87,7 @@ impl ObjectImpl for DriveMountRow { mountpoint_entry_adw_listbox.add_css_class("boxed-list"); let mountpoint_entry_row = adw::EntryRow::builder() - .title("Mountpoint") + .title(gettext("title_mountpoint")) .hexpand(true) .valign(gtk::Align::Start) .width_request(300) @@ -109,7 +109,7 @@ impl ObjectImpl for DriveMountRow { mountopt_entry_adw_listbox.add_css_class("boxed-list"); let mountopt_entry_row = adw::EntryRow::builder() - .title("Additional Mount Options") + .title(gettext("title_mountopt")) .hexpand(true) .valign(gtk::Align::Start) .width_request(300) diff --git a/src/efi_error_page/mod.rs b/src/efi_error_page/mod.rs index ce9de09..318dfaa 100644 --- a/src/efi_error_page/mod.rs +++ b/src/efi_error_page/mod.rs @@ -21,7 +21,7 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stac // the header text for the efi_error page let efi_error_header_text = gtk::Label::builder() - .label("Unsupported boot platform") + .label(gettext("bad_boot_platfrom")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -55,14 +55,14 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stac let efi_error_text = gtk::Label::builder() .vexpand(true) .hexpand(true) - .label("PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode.") + .label(gettext("pika_nowork_csm")) .halign(gtk::Align::Center) .valign(gtk::Align::Center) .build(); efi_error_text.add_css_class("big_error_text"); - let kill_me_button = gtk::Button::builder() - .label("Exit") + let exit_button = gtk::Button::builder() + .label(gettext("exit")) .vexpand(true) .hexpand(true) .halign(gtk::Align::Center) @@ -87,7 +87,7 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stac // / efi_error_selection_box appends //// add live and install media button to efi_error page selections efi_error_selection_box.append(&efi_error_text); - efi_error_selection_box.append(&kill_me_button); + efi_error_selection_box.append(&exit_button); // / efi_error_header_box appends //// Add the efi_error page header text and icon @@ -104,5 +104,5 @@ pub fn efi_error_page(window: &adw::ApplicationWindow, content_stack: >k::Stac //// Add the efi_error_main_box as page: efi_error_page, Give it nice title content_stack.add_titled(&efi_error_main_box, Some("efi_error_page"), "Welcome"); - kill_me_button.connect_clicked(clone!(@weak window => move |_| window.close())); + exit_button.connect_clicked(clone!(@weak window => move |_| window.close())); } From fe9e526d7b645bf0df5ad3691e32b5e1d05f5575 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Mon, 19 Feb 2024 00:21:54 +0300 Subject: [PATCH 40/52] RR: Hopefully translated --- debian/changelog | 2 +- po/en_US.po | 46 +++++++++++++++++++++++++++---- src/automatic_partitioning/mod.rs | 16 +++++------ src/build_ui.rs | 4 +-- src/partitioning_page/mod.rs | 2 +- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/debian/changelog b/debian/changelog index d34bb64..c7c6f1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pika-installer-gtk4 (1.0.0-100pika14) pikauwu; urgency=low +pika-installer-gtk4 (1.0.0-100pika15) pikauwu; urgency=low * First release diff --git a/po/en_US.po b/po/en_US.po index ef7203b..6e2f429 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" -"PO-Revision-Date: 2024-02-18 23:53+0300\n" +"PO-Revision-Date: 2024-02-19 00:21+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -259,9 +259,6 @@ msgstr "I Agree and Accept the User license Agreement" msgid "eula" msgstr "EULA" -msgid "bad_boot_platfrom" -msgstr Unsupported boot platform - msgid "pika_nowork_csm" msgstr "PikaOS Only works on GPT UEFI Systems, this machine is booted in CSM/LEGACY mode." @@ -284,7 +281,44 @@ msgid "reboot" msgstr "Reboot" msgid "pika_install_bad" -msgstr "PikaOS has Failed!\nCheck logs for further info." +msgstr "" +"PikaOS has Failed!\n" +"Check logs for further info." msgid "logs" -msgstr "Logs" \ No newline at end of file +msgstr "Log" + +msgid "auto_part_installer" +msgstr "Automatic Partitioning Installer" + +msgid "choose_drive_auto" +msgstr "" +"Choose the Drive you want to install PikaOS on\n" +"Note: This will erase the entire drive backup your data!" + +msgid "no_drive_auto_selected" +msgstr "No disk selected for installation" + +msgid "no_disk_specified" +msgstr "No Disk specified." + +msgid "luks_yes_but_empty" +msgstr "LUKS Encryption Enabled but no password provided." + +msgid "enable_luks2_enc" +msgstr "Enable LUKS2 Disk Encryption" + +msgid "luks2_password" +msgstr "LUKS Password" + +msgid "disk_auto_target_small" +msgstr "Disk Size too small, PikaOS needs 40GB Disk" + +msgid "installation" +msgstr "Installation" + +msgid "done" +msgstr "Done" + +msgid "partitioning" +msgstr "Partitioning" diff --git a/src/automatic_partitioning/mod.rs b/src/automatic_partitioning/mod.rs index b50da21..ba157a5 100644 --- a/src/automatic_partitioning/mod.rs +++ b/src/automatic_partitioning/mod.rs @@ -31,7 +31,7 @@ pub fn automatic_partitioning( // the header text for the partitioning page let partition_method_automatic_header_text = gtk::Label::builder() - .label("Automatic Partitioning Installer") + .label(gettext("auto_part_installer")) .halign(gtk::Align::End) .hexpand(true) .margin_top(15) @@ -58,7 +58,7 @@ pub fn automatic_partitioning( .build(); let partition_method_automatic_selection_text = gtk::Label::builder() - .label("Choose the Drive you want to install PikaOS on\nNote: This will erase the entire drive backup your data!") + .label(gettext("choose_drive_auto")) .justify(Justification::Center) .halign(gtk::Align::Center) .hexpand(true) @@ -70,7 +70,7 @@ pub fn automatic_partitioning( partition_method_automatic_selection_text.add_css_class("medium_sized_text"); let devices_selection_expander_row = adw::ExpanderRow::builder() - .title("No disk selected for selection") + .title(gettext("no_drive_auto_selected")) .build(); let null_checkbutton = gtk::CheckButton::builder().build(); @@ -111,7 +111,7 @@ pub fn automatic_partitioning( ); let partition_method_automatic_disk_error_label = gtk::Label::builder() - .label("No Disk specified.") + .label(gettext("no_disk_specified")) .halign(Align::Start) .valign(Align::End) .vexpand(true) @@ -119,7 +119,7 @@ pub fn automatic_partitioning( partition_method_automatic_disk_error_label.add_css_class("small_error_text"); let partition_method_automatic_luks_error_label = gtk::Label::builder() - .label("LUKS Encryption Enabled but no password provided.") + .label(gettext("luks_yes_but_empty")) .halign(Align::Start) .valign(Align::End) .vexpand(true) @@ -132,7 +132,7 @@ pub fn automatic_partitioning( .build(); let partition_method_automatic_luks_checkbutton = gtk::CheckButton::builder() - .label("Enable LUKS2 Disk Encryption") + .label(gettext("enable_luks2_enc")) .margin_top(15) .margin_bottom(15) .margin_start(15) @@ -148,7 +148,7 @@ pub fn automatic_partitioning( partition_method_automatic_luks_listbox.add_css_class("boxed-list"); let partition_method_automatic_luks_password_entry = adw::PasswordEntryRow::builder() - .title("LUKS Password") + .title(gettext("luks2_password")) .hexpand(true) .sensitive(false) .build(); @@ -200,7 +200,7 @@ pub fn automatic_partitioning( } } else { partition_method_automatic_disk_error_label.set_visible(true); - partition_method_automatic_disk_error_label.set_label("Disk Size too small, PikaOS needs 40GB Disk"); + partition_method_automatic_disk_error_label.set_label(&gettext("disk_auto_target_small")); bottom_next_button.set_sensitive(false); } } diff --git a/src/build_ui.rs b/src/build_ui.rs index e7279cd..f113d2d 100644 --- a/src/build_ui.rs +++ b/src/build_ui.rs @@ -128,10 +128,10 @@ pub fn build_ui(app: &adw::Application) { partitioning_page(&done_main_box, &install_main_box, &content_stack, &window); //// Add the install_main_box as page: install_page, Give it nice title - content_stack.add_titled(&install_main_box, Some("install_page"), "Installation"); + content_stack.add_titled(&install_main_box, Some("install_page"), &gettext("installation")); // Add done_page.rs as a page for content_stack - content_stack.add_titled(&done_main_box, Some("done_page"), "Done"); + content_stack.add_titled(&done_main_box, Some("done_page"), &gettext("done")); // glib maximization if glib_settings.boolean("is-maximized") == true { diff --git a/src/partitioning_page/mod.rs b/src/partitioning_page/mod.rs index 0f525a2..eb54920 100644 --- a/src/partitioning_page/mod.rs +++ b/src/partitioning_page/mod.rs @@ -231,7 +231,7 @@ pub fn partitioning_page( content_stack.add_titled( &partitioning_main_box, Some("partitioning_page"), - "Partitioning", + &gettext("partitioning"), ); automatic_method_button.connect_clicked(clone!(@weak partitioning_stack => move |_| partitioning_stack.set_visible_child_name("partition_method_automatic_page"))); From 547f5e3c414ccd6528c5e7d739fc91a80ad7da48 Mon Sep 17 00:00:00 2001 From: Ward from fusion-voyager-3 Date: Mon, 19 Feb 2024 00:22:21 +0300 Subject: [PATCH 41/52] RR: Hopefully translated --- makepot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepot b/makepot index 0a75270..ea26740 100755 --- a/makepot +++ b/makepot @@ -5,5 +5,5 @@ set -e for i in po/*.po do mkdir -p "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES - msgfmt -v $i -o "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES/pika-first-setup-gtk4.mo + msgfmt -v $i -o "$1"/"$(echo $i | cut -d"/" -f2 | cut -d"." -f1)"/LC_MESSAGES/pika-installer-gtk4.mo done \ No newline at end of file From f35b7ae020e0d335177018decc82059bb2c25b76 Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Mon, 19 Feb 2024 00:29:58 +0300 Subject: [PATCH 42/52] Update en_US.po --- po/en_US.po | 1 - 1 file changed, 1 deletion(-) diff --git a/po/en_US.po b/po/en_US.po index 6e2f429..5c245ab 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -67,7 +67,6 @@ msgstr "Open GPARTED" msgid "manual_part_note" msgstr "" -"\n" " - Press the plus button below to begin adding filesystem entries.\n" "Notes:\n" " - This installer doesn't erase any data automatically, format your drives manually via gparted.\n" From fc1b9dde5784a2628649e390837292ddbdd5c848 Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:49:27 +0300 Subject: [PATCH 43/52] Create README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1113695 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +### PikaOS installer +A Rust based GTK4 + Libadwaita App +for installing PikaOS. + +### Help Us + +#### You can help by translating the app +[Weblate](https://hosted.weblate.org/projects/pika-first-setup-gtk4/) From a8ccb781c19620ce45581ba16a9d06ccc7e96df1 Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:55:51 +0300 Subject: [PATCH 44/52] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1113695..d917618 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ for installing PikaOS. ### Help Us #### You can help by translating the app -[Weblate](https://hosted.weblate.org/projects/pika-first-setup-gtk4/) +[Weblate](https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4/) From b64f40edeecfc9f1aaf621c04c658f9bce04ec9c Mon Sep 17 00:00:00 2001 From: ToasterUwU Date: Mon, 19 Feb 2024 00:25:10 +0100 Subject: [PATCH 45/52] Added translation using Weblate (German) --- po/de.po | 292 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 po/de.po diff --git a/po/de.po b/po/de.po new file mode 100644 index 0000000..a610885 --- /dev/null +++ b/po/de.po @@ -0,0 +1,292 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2024-02-09 17:48+0300\n" +"PO-Revision-Date: 2024-02-19 00:21+0300\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.4\n" +"X-Poedit-Basepath: .\n" + +msgid "pikaos_installer" +msgstr "" + +msgid "welcome_to_pikaos" +msgstr "" + +msgid "use_pikaos_in_live_media" +msgstr "" + +msgid "install_distro_to_system" +msgstr "" + +msgid "welcome" +msgstr "" + +msgid "back" +msgstr "" + +msgid "next" +msgstr "" + +msgid "select_a_timezone" +msgstr "" + +msgid "please_select_timezone" +msgstr "" + +msgid "no_timezone_select" +msgstr "" + +msgid "timezone" +msgstr "" + +msgid "choose_install_method" +msgstr "" + +msgid "manual_partition_drive" +msgstr "" + +msgid "auto_partition_drive" +msgstr "" + +msgid "manual_part_installer" +msgstr "" + +msgid "use_utility_manual" +msgstr "" + +msgid "open_gparted" +msgstr "" + +msgid "manual_part_note" +msgstr "" + +msgid "refresh_part_table" +msgstr "" + +msgid "validate_fs_table" +msgstr "" + +msgid "fstab_status_valid" +msgstr "" + +msgid "part_need_mapper" +msgstr "" + +msgid "fstab_subvol_warn" +msgstr "" + +msgid "fstab_multiple_part_mountpoint_err" +msgstr "" + +msgid "fstab_no_mountpoint_err" +msgstr "" + +msgid "fstab_no_partition_err" +msgstr "" + +msgid "fstab_badfs" +msgstr "" + +msgid "fstab_small_efi_size" +msgstr "" + +msgid "fstab_badfs_efi" +msgstr "" + +msgid "fstab_small_boot_size" +msgstr "" + +msgid "fstab_badfs_boot" +msgstr "" + +msgid "fstab_small_root_size" +msgstr "" + +msgid "fstab_badfs_root" +msgstr "" + +msgid "fstab_small_home_size" +msgstr "" + +msgid "fstab_badfs_home" +msgstr "" + +msgid "fstab_badfs_swap" +msgstr "" + +msgid "fstab_bad_mountpoint" +msgstr "" + +msgid "fstab_bad_mountpoint_msg" +msgstr "" + +msgid "select_a_language" +msgstr "" + +msgid "please_select_locale" +msgstr "" + +msgid "no_locale_selected" +msgstr "" + +msgid "language" +msgstr "" + +msgid "select_a_keyboard" +msgstr "" + +msgid "please_select_keyboard" +msgstr "" + +msgid "no_keyboard_selected" +msgstr "" + +msgid "test_your_keyboard" +msgstr "" + +msgid "keyboard" +msgstr "" + +msgid "luks_password_for" +msgstr "" + +msgid "luks_how_should" +msgstr "" + +msgid "be_added_crypttab" +msgstr "" + +msgid "unlock_boot_manually" +msgstr "" + +msgid "unlock_boot_manual" +msgstr "" + +msgid "sit_back_relax" +msgstr "" + +msgid "language_detail" +msgstr "" + +msgid "timezone_detail" +msgstr "" + +msgid "keyboard_detail" +msgstr "" + +msgid "mounted_on_detail" +msgstr "" + +msgid "install_target_detail" +msgstr "" + +msgid "confirm_install_pika" +msgstr "" + +msgid "view_logs" +msgstr "" + +msgid "parting_status_text" +msgstr "" + +msgid "image_status_text" +msgstr "" + +msgid "flag1_status_text" +msgstr "" + +msgid "flag2_status_text" +msgstr "" + +msgid "crypt_status_text" +msgstr "" + +msgid "lang_status_text" +msgstr "" + +msgid "boot_status_status_text" +msgstr "" + +msgid "post_status_text" +msgstr "" + +msgid "pikaos_eula_agreement" +msgstr "" + +msgid "please_read_eula" +msgstr "" + +msgid "eula_buffer" +msgstr "" + +msgid "i_agree_eula" +msgstr "" + +msgid "eula" +msgstr "" + +msgid "pika_nowork_csm" +msgstr "" + +msgid "exit" +msgstr "" + +msgid "subtitle_partition" +msgstr "" + +msgid "title_mountpoint" +msgstr "" + +msgid "title_mountopt" +msgstr "" + +msgid "pika_install_good" +msgstr "" + +msgid "reboot" +msgstr "" + +msgid "pika_install_bad" +msgstr "" + +msgid "logs" +msgstr "" + +msgid "auto_part_installer" +msgstr "" + +msgid "choose_drive_auto" +msgstr "" + +msgid "no_drive_auto_selected" +msgstr "" + +msgid "no_disk_specified" +msgstr "" + +msgid "luks_yes_but_empty" +msgstr "" + +msgid "enable_luks2_enc" +msgstr "" + +msgid "luks2_password" +msgstr "" + +msgid "disk_auto_target_small" +msgstr "" + +msgid "installation" +msgstr "" + +msgid "done" +msgstr "" + +msgid "partitioning" +msgstr "" From 3668b5050fbf9e9bb0ff316a338a1421d1a663e6 Mon Sep 17 00:00:00 2001 From: ToasterUwU Date: Sun, 18 Feb 2024 23:32:26 +0000 Subject: [PATCH 46/52] Translated using Weblate (German) Currently translated at 1.0% (1 of 93 strings) Translation: PikaOS Linux/pika-installer-gtk4 Translate-URL: https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4/de/ --- po/de.po | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/po/de.po b/po/de.po index a610885..7e589cd 100644 --- a/po/de.po +++ b/po/de.po @@ -2,14 +2,16 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" -"PO-Revision-Date: 2024-02-19 00:21+0300\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2024-02-18 23:48+0000\n" +"Last-Translator: ToasterUwU \n" +"Language-Team: German \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.4\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.4\n" "X-Poedit-Basepath: .\n" msgid "pikaos_installer" @@ -19,7 +21,7 @@ msgid "welcome_to_pikaos" msgstr "" msgid "use_pikaos_in_live_media" -msgstr "" +msgstr "Nutze PikaOS im Live Modus" msgid "install_distro_to_system" msgstr "" From dc942afdbce0d9f506d199eb4604a680dc10fed5 Mon Sep 17 00:00:00 2001 From: Peter Tsvetkov Date: Mon, 19 Feb 2024 09:35:47 +0100 Subject: [PATCH 47/52] Added translation using Weblate (Bulgarian) --- po/bg.po | 292 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 po/bg.po diff --git a/po/bg.po b/po/bg.po new file mode 100644 index 0000000..612e15a --- /dev/null +++ b/po/bg.po @@ -0,0 +1,292 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2024-02-09 17:48+0300\n" +"PO-Revision-Date: 2024-02-19 00:21+0300\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: bg\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.4\n" +"X-Poedit-Basepath: .\n" + +msgid "pikaos_installer" +msgstr "" + +msgid "welcome_to_pikaos" +msgstr "" + +msgid "use_pikaos_in_live_media" +msgstr "" + +msgid "install_distro_to_system" +msgstr "" + +msgid "welcome" +msgstr "" + +msgid "back" +msgstr "" + +msgid "next" +msgstr "" + +msgid "select_a_timezone" +msgstr "" + +msgid "please_select_timezone" +msgstr "" + +msgid "no_timezone_select" +msgstr "" + +msgid "timezone" +msgstr "" + +msgid "choose_install_method" +msgstr "" + +msgid "manual_partition_drive" +msgstr "" + +msgid "auto_partition_drive" +msgstr "" + +msgid "manual_part_installer" +msgstr "" + +msgid "use_utility_manual" +msgstr "" + +msgid "open_gparted" +msgstr "" + +msgid "manual_part_note" +msgstr "" + +msgid "refresh_part_table" +msgstr "" + +msgid "validate_fs_table" +msgstr "" + +msgid "fstab_status_valid" +msgstr "" + +msgid "part_need_mapper" +msgstr "" + +msgid "fstab_subvol_warn" +msgstr "" + +msgid "fstab_multiple_part_mountpoint_err" +msgstr "" + +msgid "fstab_no_mountpoint_err" +msgstr "" + +msgid "fstab_no_partition_err" +msgstr "" + +msgid "fstab_badfs" +msgstr "" + +msgid "fstab_small_efi_size" +msgstr "" + +msgid "fstab_badfs_efi" +msgstr "" + +msgid "fstab_small_boot_size" +msgstr "" + +msgid "fstab_badfs_boot" +msgstr "" + +msgid "fstab_small_root_size" +msgstr "" + +msgid "fstab_badfs_root" +msgstr "" + +msgid "fstab_small_home_size" +msgstr "" + +msgid "fstab_badfs_home" +msgstr "" + +msgid "fstab_badfs_swap" +msgstr "" + +msgid "fstab_bad_mountpoint" +msgstr "" + +msgid "fstab_bad_mountpoint_msg" +msgstr "" + +msgid "select_a_language" +msgstr "" + +msgid "please_select_locale" +msgstr "" + +msgid "no_locale_selected" +msgstr "" + +msgid "language" +msgstr "" + +msgid "select_a_keyboard" +msgstr "" + +msgid "please_select_keyboard" +msgstr "" + +msgid "no_keyboard_selected" +msgstr "" + +msgid "test_your_keyboard" +msgstr "" + +msgid "keyboard" +msgstr "" + +msgid "luks_password_for" +msgstr "" + +msgid "luks_how_should" +msgstr "" + +msgid "be_added_crypttab" +msgstr "" + +msgid "unlock_boot_manually" +msgstr "" + +msgid "unlock_boot_manual" +msgstr "" + +msgid "sit_back_relax" +msgstr "" + +msgid "language_detail" +msgstr "" + +msgid "timezone_detail" +msgstr "" + +msgid "keyboard_detail" +msgstr "" + +msgid "mounted_on_detail" +msgstr "" + +msgid "install_target_detail" +msgstr "" + +msgid "confirm_install_pika" +msgstr "" + +msgid "view_logs" +msgstr "" + +msgid "parting_status_text" +msgstr "" + +msgid "image_status_text" +msgstr "" + +msgid "flag1_status_text" +msgstr "" + +msgid "flag2_status_text" +msgstr "" + +msgid "crypt_status_text" +msgstr "" + +msgid "lang_status_text" +msgstr "" + +msgid "boot_status_status_text" +msgstr "" + +msgid "post_status_text" +msgstr "" + +msgid "pikaos_eula_agreement" +msgstr "" + +msgid "please_read_eula" +msgstr "" + +msgid "eula_buffer" +msgstr "" + +msgid "i_agree_eula" +msgstr "" + +msgid "eula" +msgstr "" + +msgid "pika_nowork_csm" +msgstr "" + +msgid "exit" +msgstr "" + +msgid "subtitle_partition" +msgstr "" + +msgid "title_mountpoint" +msgstr "" + +msgid "title_mountopt" +msgstr "" + +msgid "pika_install_good" +msgstr "" + +msgid "reboot" +msgstr "" + +msgid "pika_install_bad" +msgstr "" + +msgid "logs" +msgstr "" + +msgid "auto_part_installer" +msgstr "" + +msgid "choose_drive_auto" +msgstr "" + +msgid "no_drive_auto_selected" +msgstr "" + +msgid "no_disk_specified" +msgstr "" + +msgid "luks_yes_but_empty" +msgstr "" + +msgid "enable_luks2_enc" +msgstr "" + +msgid "luks2_password" +msgstr "" + +msgid "disk_auto_target_small" +msgstr "" + +msgid "installation" +msgstr "" + +msgid "done" +msgstr "" + +msgid "partitioning" +msgstr "" From 50af783c196c1dbc12bfeb184e8612ab2cf16b61 Mon Sep 17 00:00:00 2001 From: Nico Hartwig Date: Mon, 19 Feb 2024 06:32:23 +0000 Subject: [PATCH 48/52] Translated using Weblate (German) Currently translated at 20.4% (19 of 93 strings) Translation: PikaOS Linux/pika-installer-gtk4-old Translate-URL: https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4-old/de/ --- po/de.po | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/po/de.po b/po/de.po index 7e589cd..55a390e 100644 --- a/po/de.po +++ b/po/de.po @@ -2,10 +2,10 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" -"PO-Revision-Date: 2024-02-18 23:48+0000\n" -"Last-Translator: ToasterUwU \n" +"PO-Revision-Date: 2024-02-19 11:46+0000\n" +"Last-Translator: Nico Hartwig \n" "Language-Team: German \n" +"pika-installer-gtk4-old/de/>\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -27,25 +27,25 @@ msgid "install_distro_to_system" msgstr "" msgid "welcome" -msgstr "" +msgstr "Willkommen" msgid "back" -msgstr "" +msgstr "Zurück" msgid "next" -msgstr "" +msgstr "Weiter" msgid "select_a_timezone" -msgstr "" +msgstr "Wähle eine Zeitzone" msgid "please_select_timezone" -msgstr "" +msgstr "Bitte wähle eine Zeitzone" msgid "no_timezone_select" -msgstr "" +msgstr "Keine Zeitzohne ausgewählt" msgid "timezone" -msgstr "" +msgstr "Zeitzone" msgid "choose_install_method" msgstr "" From e7283f73490cde138f63deba8c610fe2dc86f474 Mon Sep 17 00:00:00 2001 From: selektionsrest Date: Mon, 19 Feb 2024 11:43:07 +0000 Subject: [PATCH 49/52] Translated using Weblate (German) Currently translated at 20.4% (19 of 93 strings) Translation: PikaOS Linux/pika-installer-gtk4-old Translate-URL: https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4-old/de/ --- po/de.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/po/de.po b/po/de.po index 55a390e..add5cf0 100644 --- a/po/de.po +++ b/po/de.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" "PO-Revision-Date: 2024-02-19 11:46+0000\n" -"Last-Translator: Nico Hartwig \n" +"Last-Translator: selektionsrest \n" "Language-Team: German \n" "Language: de\n" @@ -15,16 +15,16 @@ msgstr "" "X-Poedit-Basepath: .\n" msgid "pikaos_installer" -msgstr "" +msgstr "PikaOS-Installationsprogramm" msgid "welcome_to_pikaos" -msgstr "" +msgstr "Willkommen bei PikaOS" msgid "use_pikaos_in_live_media" msgstr "Nutze PikaOS im Live Modus" msgid "install_distro_to_system" -msgstr "" +msgstr "PikaOS installieren" msgid "welcome" msgstr "Willkommen" From 23f58b2c5df21bb0143b82f6f583e1b220b3fb1d Mon Sep 17 00:00:00 2001 From: Ryota Date: Mon, 19 Feb 2024 08:15:30 +0000 Subject: [PATCH 50/52] Translated using Weblate (German) Currently translated at 20.4% (19 of 93 strings) Translation: PikaOS Linux/pika-installer-gtk4-old Translate-URL: https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4-old/de/ --- po/de.po | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/po/de.po b/po/de.po index add5cf0..acd991d 100644 --- a/po/de.po +++ b/po/de.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" "PO-Revision-Date: 2024-02-19 11:46+0000\n" -"Last-Translator: selektionsrest \n" +"Last-Translator: Ryota \n" "Language-Team: German \n" "Language: de\n" @@ -51,10 +51,10 @@ msgid "choose_install_method" msgstr "" msgid "manual_partition_drive" -msgstr "" +msgstr "Manuelle Partitionierung" msgid "auto_partition_drive" -msgstr "" +msgstr "Automatische Partitionierung" msgid "manual_part_installer" msgstr "" @@ -63,13 +63,13 @@ msgid "use_utility_manual" msgstr "" msgid "open_gparted" -msgstr "" +msgstr "Öffne Gparted" msgid "manual_part_note" msgstr "" msgid "refresh_part_table" -msgstr "" +msgstr "Aktualisiere Partitionstabelle" msgid "validate_fs_table" msgstr "" @@ -129,7 +129,7 @@ msgid "fstab_bad_mountpoint_msg" msgstr "" msgid "select_a_language" -msgstr "" +msgstr "Sprache auswählen" msgid "please_select_locale" msgstr "" @@ -138,7 +138,7 @@ msgid "no_locale_selected" msgstr "" msgid "language" -msgstr "" +msgstr "Sprache" msgid "select_a_keyboard" msgstr "" @@ -153,10 +153,10 @@ msgid "test_your_keyboard" msgstr "" msgid "keyboard" -msgstr "" +msgstr "Tastatur" msgid "luks_password_for" -msgstr "" +msgstr "Luks Passwort für" msgid "luks_how_should" msgstr "" From 3cd39c02191a164f04d0b606feb24aa4183de5f9 Mon Sep 17 00:00:00 2001 From: Peter Tsvetkov Date: Mon, 19 Feb 2024 10:21:14 +0000 Subject: [PATCH 51/52] Translated using Weblate (Bulgarian) Currently translated at 29.0% (27 of 93 strings) Translation: PikaOS Linux/pika-installer-gtk4-old Translate-URL: https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4-old/bg/ --- po/bg.po | 64 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/po/bg.po b/po/bg.po index 612e15a..626c40f 100644 --- a/po/bg.po +++ b/po/bg.po @@ -2,78 +2,80 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" -"PO-Revision-Date: 2024-02-19 00:21+0300\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2024-02-19 11:46+0000\n" +"Last-Translator: Peter Tsvetkov \n" +"Language-Team: Bulgarian \n" "Language: bg\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.4\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.4\n" "X-Poedit-Basepath: .\n" msgid "pikaos_installer" -msgstr "" +msgstr "pikaos_инсталатор" msgid "welcome_to_pikaos" -msgstr "" +msgstr "добре_дошли_в_pikaos" msgid "use_pikaos_in_live_media" -msgstr "" +msgstr "използвай_pikaos_без_да_инсталираш" msgid "install_distro_to_system" -msgstr "" +msgstr "инсталирай_дистрибуцията" msgid "welcome" -msgstr "" +msgstr "добре_дошли" msgid "back" -msgstr "" +msgstr "върни" msgid "next" -msgstr "" +msgstr "следващ" msgid "select_a_timezone" -msgstr "" +msgstr "изберте_часова_зона" msgid "please_select_timezone" -msgstr "" +msgstr "Моля, изберете времева зона" msgid "no_timezone_select" -msgstr "" +msgstr "Не е избрава времева зона" msgid "timezone" -msgstr "" +msgstr "Времева зона" msgid "choose_install_method" -msgstr "" +msgstr "Изберете метод на инсталиране" msgid "manual_partition_drive" -msgstr "" +msgstr "ръчно_разделяне_на_диска" msgid "auto_partition_drive" -msgstr "" +msgstr "автоматично_разделяне_на_диска" msgid "manual_part_installer" -msgstr "" +msgstr "ръчно_" msgid "use_utility_manual" msgstr "" msgid "open_gparted" -msgstr "" +msgstr "отвори_gparter" msgid "manual_part_note" msgstr "" msgid "refresh_part_table" -msgstr "" +msgstr "обнови_таблица_на_дяловете" msgid "validate_fs_table" -msgstr "" +msgstr "валидиране_таблица_на_файлова_система" msgid "fstab_status_valid" -msgstr "" +msgstr "таблицата_на_файловата_система_е_валидна" msgid "part_need_mapper" msgstr "" @@ -94,7 +96,7 @@ msgid "fstab_badfs" msgstr "" msgid "fstab_small_efi_size" -msgstr "" +msgstr "размерът_на_EFI_дялът_е_малък" msgid "fstab_badfs_efi" msgstr "" @@ -259,34 +261,34 @@ msgid "logs" msgstr "" msgid "auto_part_installer" -msgstr "" +msgstr "Автоматичен дялов инсталатор" msgid "choose_drive_auto" -msgstr "" +msgstr "Автоматичо избери диск" msgid "no_drive_auto_selected" msgstr "" msgid "no_disk_specified" -msgstr "" +msgstr "Не е избран диск" msgid "luks_yes_but_empty" msgstr "" msgid "enable_luks2_enc" -msgstr "" +msgstr "Активирайте Luks2 криптиране" msgid "luks2_password" -msgstr "" +msgstr "Luks2 парола" msgid "disk_auto_target_small" msgstr "" msgid "installation" -msgstr "" +msgstr "Инсталация" msgid "done" -msgstr "" +msgstr "Завършено" msgid "partitioning" msgstr "" From 0bc3735ab259181ea3822dcadc3d467bd19215fa Mon Sep 17 00:00:00 2001 From: selektionsrest Date: Mon, 19 Feb 2024 11:48:20 +0000 Subject: [PATCH 52/52] Translated using Weblate (German) Currently translated at 21.5% (20 of 93 strings) Translation: PikaOS Linux/pika-installer-gtk4-old Translate-URL: https://hosted.weblate.org/projects/pikaos/pika-installer-gtk4-old/de/ --- po/de.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/po/de.po b/po/de.po index acd991d..da0d685 100644 --- a/po/de.po +++ b/po/de.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2024-02-09 17:48+0300\n" -"PO-Revision-Date: 2024-02-19 11:46+0000\n" -"Last-Translator: Ryota \n" +"PO-Revision-Date: 2024-02-19 11:57+0000\n" +"Last-Translator: selektionsrest \n" "Language-Team: German \n" "Language: de\n" @@ -42,13 +42,13 @@ msgid "please_select_timezone" msgstr "Bitte wähle eine Zeitzone" msgid "no_timezone_select" -msgstr "Keine Zeitzohne ausgewählt" +msgstr "Keine Zeitzone ausgewählt" msgid "timezone" msgstr "Zeitzone" msgid "choose_install_method" -msgstr "" +msgstr "Wähle eine Installationsmethode" msgid "manual_partition_drive" msgstr "Manuelle Partitionierung"