RR: Update page Complete + cargo fmt

This commit is contained in:
Ward from fusion-voyager-3 2024-02-09 00:49:42 +03:00
parent 3998a17d7a
commit f41136a754
13 changed files with 672 additions and 147 deletions

415
Cargo.lock generated
View File

@ -36,6 +36,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.2"
@ -48,7 +54,7 @@ version = "0.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"cairo-sys-rs",
"glib",
"libc",
@ -67,6 +73,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"
@ -77,6 +92,16 @@ dependencies = [
"target-lexicon",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
"termcolor",
"unicode-width",
]
[[package]]
name = "concurrent-queue"
version = "2.4.0"
@ -92,12 +117,78 @@ version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "cxx"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de00f15a6fa069c99b88c5c78c4541d0e7899a33b86f7480e23df2431fce0bc"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxx-build"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a71e1e631fa2f2f5f92e8b0d860a00c198c6771623a6cefcc863e3554f0d8d6"
dependencies = [
"cc",
"codespan-reporting",
"once_cell",
"proc-macro2",
"quote",
"scratch",
"syn 2.0.48",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f3fed61d56ba497c4efef9144dfdbaa25aa58f2f6b3a7cf441d4591c583745c"
[[package]]
name = "cxxbridge-macro"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8908e380a8efd42150c017b0cfa31509fc49b6d47f7cb6b33e93ffb8f4e3661e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "event-listener"
version = "4.0.3"
@ -288,7 +379,7 @@ version = "0.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5"
dependencies = [
"bitflags",
"bitflags 2.4.2",
"futures-channel",
"futures-core",
"futures-executor",
@ -429,16 +520,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "gtk4-rs-adw-project-template"
version = "0.1.0"
dependencies = [
"async-channel",
"gtk4",
"libadwaita",
"regex",
]
[[package]]
name = "gtk4-sys"
version = "0.7.3"
@ -471,15 +552,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "indexmap"
version = "2.2.1"
name = "hermit-abi"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3"
[[package]]
name = "indexmap"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "io-lifetimes"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.48.0",
]
[[package]]
name = "libadwaita"
version = "0.5.3"
@ -514,9 +612,24 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.152"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "link-cplusplus"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9"
dependencies = [
"cc",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "memchr"
@ -539,6 +652,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"
@ -570,6 +693,20 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae"
[[package]]
name = "pika-first-setup-gtk4"
version = "0.1.0"
dependencies = [
"async-channel",
"duct",
"gtk4",
"libadwaita",
"os_pipe",
"regex",
"rust-apt",
"zoha-vte4",
]
[[package]]
name = "pin-project-lite"
version = "0.2.13"
@ -679,6 +816,17 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rust-apt"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dd82de92772f0f06fd84ba751bb72bc6d03c4b1cd5180c7e356b11643351135"
dependencies = [
"cxx",
"cxx-build",
"terminal_size",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
@ -688,6 +836,25 @@ dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
"bitflags 2.4.2",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "scratch"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152"
[[package]]
name = "semver"
version = "1.0.21"
@ -723,6 +890,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"
@ -779,6 +956,25 @@ version = "0.12.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae"
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
dependencies = [
"rustix",
"windows-sys 0.48.0",
]
[[package]]
name = "thiserror"
version = "1.0.56"
@ -850,6 +1046,12 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "version-compare"
version = "0.1.1"
@ -878,6 +1080,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
@ -885,10 +1096,174 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "winnow"
version = "0.5.35"
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"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]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"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]]
name = "windows_aarch64_gnullvm"
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.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5"
dependencies = [
"memchr",
]
[[package]]
name = "zoha-vte4"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e09b58dbfab3b62c5544cafadc504db3b7d12f21ac6e55048489dbf90c979caf"
dependencies = [
"bitflags 1.3.2",
"gdk4",
"gio",
"glib",
"gtk4",
"io-lifetimes",
"libc",
"pango",
"zoha-vte4-sys",
]
[[package]]
name = "zoha-vte4-sys"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "749df284a2c2e68c2c359762b277854d533a4d50c7a216a3adf45cd5e5ee2993"
dependencies = [
"gdk4-sys",
"gio-sys",
"glib",
"gtk4-sys",
"libc",
"pango-sys",
"system-deps",
]

View File

@ -1,5 +1,5 @@
[package]
name = "gtk4-rs-adw-project-template"
name = "pika-first-setup-gtk4"
version = "0.1.0"
edition = "2021"
@ -10,3 +10,7 @@ adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
async-channel = "2.1.1"
regex = "1.10.3"
rust-apt = "0.6.0"
vte = { version = "0.0.2", package = "zoha-vte4", features = ["v0_72"] }
duct = "0.13.7"
os_pipe = "1.1.5"

View File

@ -1,21 +1,20 @@
// GTK crates
use adw::ffi::{AdwToolbarStyle, ADW_TOOLBAR_FLAT};
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 adw::ffi::{ADW_TOOLBAR_FLAT, AdwToolbarStyle};
use glib::*;
use gdk::Display;
// application crates
use crate::save_window_size;
/// first setup crates
use crate::first_setup::first_setup::first_setup;
use crate::save_window_size;
pub fn build_ui(app: &adw::Application) {
// setup glib
gtk::glib::set_prgname(Some("PikaOS First Setup"));
glib::set_application_name("PikaOS First Setup");

View File

@ -1,27 +1,26 @@
// GTK crates
use adw::ffi::ADW_TOOLBAR_FLAT;
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 adw::ffi::ADW_TOOLBAR_FLAT;
use glib::*;
use gdk::Display;
//
use crate::connection_check::check_internet_connection;
use std::cell::RefCell;
use std::rc::Rc;
use crate::connection_check::check_internet_connection;
// carousel crates
use crate::first_setup::initial_carousel::initial_carousel;
use crate::first_setup::internet_carousel::internet_carousel;
use crate::first_setup::user_carousel::user_carousel;
use crate::first_setup::update_carousel::update_carousel;
use crate::first_setup::user_carousel::user_carousel;
pub fn first_setup(window: &adw::ApplicationWindow) {
let first_setup_carousel = adw::Carousel::builder()
.allow_long_swipes(false)
.allow_mouse_drag(false)
@ -35,9 +34,7 @@ pub fn first_setup(window: &adw::ApplicationWindow) {
.carousel(&first_setup_carousel)
.build();
let first_setup_window_headerbar_back_button = gtk::Button::builder()
.label("Back")
.build();
let first_setup_window_headerbar_back_button = gtk::Button::builder().label("Back").build();
let first_setup_window_headerbar = adw::HeaderBar::builder()
.show_start_title_buttons(true)
@ -65,7 +62,7 @@ pub fn first_setup(window: &adw::ApplicationWindow) {
initial_carousel(&first_setup_carousel);
internet_carousel(&first_setup_carousel, &internet_connected, &window);
user_carousel(&first_setup_carousel);
update_carousel(&first_setup_carousel, &internet_connected);
update_carousel(&first_setup_carousel, &internet_connected, &window);
// Add file to window
window.set_content(Some(&first_setup_window_toolbarview))

View File

@ -1,12 +1,12 @@
// GTK crates
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;
pub fn initial_carousel(first_setup_carousel: &adw::Carousel) {
let first_setup_initial_box = gtk::Box::builder()

View File

@ -1,23 +1,26 @@
// GTK crates
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 crate::check_internet_connection;
use std::process::Command;
use std::cell::RefCell;
use std::rc::Rc;
use std::borrow::Borrow as the_rc_borrow;
use std::env;
use gtk::gio::ffi::GAsyncReadyCallback;
use std::borrow::Borrow as the_rc_borrow;
use std::cell::RefCell;
use std::env;
use std::process::Command;
use std::rc::Rc;
pub fn internet_carousel(first_setup_carousel: &adw::Carousel, internet_connected: &Rc<RefCell<bool>>, window: &adw::ApplicationWindow) {
pub fn internet_carousel(
first_setup_carousel: &adw::Carousel,
internet_connected: &Rc<RefCell<bool>>,
window: &adw::ApplicationWindow,
) {
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
let internet_loop_sender = internet_loop_sender.clone();
// The long running operation runs now in a separate thread
@ -37,9 +40,13 @@ pub fn internet_carousel(first_setup_carousel: &adw::Carousel, internet_connecte
.output()
.expect("failed to execute process");
if check_internet_connection_cli.status.success() {
internet_loop_sender.send_blocking(true).expect("The channel needs to be open.");
internet_loop_sender
.send_blocking(true)
.expect("The channel needs to be open.");
} else {
internet_loop_sender.send_blocking(false).expect("The channel needs to be open.");
internet_loop_sender
.send_blocking(false)
.expect("The channel needs to be open.");
}
}
});
@ -136,8 +143,8 @@ pub fn internet_carousel(first_setup_carousel: &adw::Carousel, internet_connecte
first_setup_internet_skip_dialog.add_response("skip_cancel", "Return to Network Setup");
first_setup_internet_skip_dialog.add_response("skip_confirm", "Just Skip!");
first_setup_internet_skip_dialog.set_response_appearance("skip_confirm", adw::ResponseAppearance::Destructive);
first_setup_internet_skip_dialog
.set_response_appearance("skip_confirm", adw::ResponseAppearance::Destructive);
let internet_connected_status = internet_connected.clone();
@ -179,11 +186,13 @@ pub fn internet_carousel(first_setup_carousel: &adw::Carousel, internet_connecte
first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(2), true);
}));
internet_skip_button.connect_clicked(clone!(@weak first_setup_carousel, @weak first_setup_internet_skip_dialog => move |_| {
internet_skip_button.connect_clicked(
clone!(@weak first_setup_carousel, @weak first_setup_internet_skip_dialog => move |_| {
first_setup_internet_skip_dialog.choose(None::<&gio::Cancellable>, move |choice| {
if choice == "skip_confirm" {
first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(2), true);
}
});
}));
}),
);
}

View File

@ -1,5 +1,5 @@
pub mod first_setup;
pub mod initial_carousel;
pub mod internet_carousel;
pub mod user_carousel;
pub mod update_carousel;
pub mod user_carousel;

View File

@ -1,38 +1,84 @@
use std::cell::RefCell;
use std::process::Command;
use std::rc::Rc;
// GTK crates
use adw::ffi::ADW_TOOLBAR_FLAT;
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 adw::ffi::ADW_TOOLBAR_FLAT;
use glib::*;
use gdk::Display;
use vte::prelude::*;
use vte::*;
use std::{thread, time};
pub fn update_carousel(first_setup_carousel: &adw::Carousel, internet_connected: &Rc<RefCell<bool>>) {
use std::{
error::Error,
io::Error as ErrorIO,
io::{ErrorKind, Read, Write},
process::{Command, Stdio},
};
use duct::cmd;
use os_pipe::*;
use std::io::prelude::*;
use std::io::BufReader;
const APT_UPDATE_PROG: &str = "
#! /bin/bash
set -e
sudo apt update -y && sudo apt full-upgrade -y
";
fn apt_update(
log_loop_sender: async_channel::Sender<String>,
) -> Result<(), std::boxed::Box<dyn Error + Send + Sync>> {
let (pipe_reader, pipe_writer) = os_pipe::pipe()?;
let child = cmd!("bash", "-c", APT_UPDATE_PROG)
.stderr_to_stdout()
.stdout_file(pipe_writer)
.start()?;
for line in BufReader::new(pipe_reader).lines() {
log_loop_sender
.send_blocking(line?)
.expect("Channel needs to be opened.")
}
child.wait()?;
Ok(())
}
pub fn update_carousel(
first_setup_carousel: &adw::Carousel,
internet_connected: &Rc<RefCell<bool>>,
window: &adw::ApplicationWindow,
) {
let internet_connected_status = internet_connected.clone();
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
let internet_loop_sender = internet_loop_sender.clone();
// The long running operation runs now in a separate thread
gio::spawn_blocking(move || {
loop {
gio::spawn_blocking(move || loop {
thread::sleep(time::Duration::from_secs(1));
internet_loop_sender.send_blocking(true).expect("The channel needs to be open.");
}
internet_loop_sender
.send_blocking(true)
.expect("The channel needs to be open.");
});
let (log_loop_sender, log_loop_receiver) = async_channel::unbounded();
let log_loop_sender: async_channel::Sender<String> = log_loop_sender.clone();
let (log_status_loop_sender, log_status_loop_receiver) = async_channel::unbounded();
let log_status_loop_sender: async_channel::Sender<bool> = log_status_loop_sender.clone();
let first_setup_update_box = gtk::Box::builder()
// that puts items vertically
.orientation(Orientation::Vertical)
.vexpand(true)
.valign(Align::Center)
.valign(gtk::Align::Center)
.hexpand(true)
.vexpand(true)
.build();
@ -47,20 +93,71 @@ pub fn update_carousel(first_setup_carousel: &adw::Carousel, internet_connected:
let first_setup_update_button = gtk::Button::builder()
.label("Update")
.sensitive(false)
.halign(Align::Center)
.build();
first_setup_update_button.add_css_class("suggested-action");
first_setup_update_button.add_css_class("pill");
let first_setup_update_skip_button = gtk::Button::builder()
.label("Skip Updates")
.sensitive(true)
.width_request(25)
.build();
let first_setup_update_buttons_box = gtk::Box::builder()
.orientation(Orientation::Horizontal)
.halign(gtk::Align::Center)
.valign(gtk::Align::End)
.vexpand(true)
.hexpand(true)
.margin_end(15)
.margin_start(15)
.margin_bottom(15)
.margin_top(15)
.spacing(80)
.build();
first_setup_update_skip_button.add_css_class("pill");
let system_update_log_terminal_buffer = gtk::TextBuffer::builder().build();
let system_update_log_terminal = gtk::TextView::builder()
.vexpand(true)
.hexpand(true)
.editable(false)
.buffer(&system_update_log_terminal_buffer)
.build();
let system_update_log_terminal_scroll = gtk::ScrolledWindow::builder()
.width_request(400)
.height_request(200)
.vexpand(true)
.hexpand(true)
.child(&system_update_log_terminal)
.build();
let system_update_dialog = adw::MessageDialog::builder()
.transient_for(window)
.hide_on_close(true)
.extra_child(&system_update_log_terminal_scroll)
.width_request(400)
.height_request(200)
.heading("System Update Log")
.build();
system_update_dialog.add_response("system_update_dialog_ok", "Ok");
first_setup_update_buttons_box.append(&first_setup_update_button);
first_setup_update_buttons_box.append(&first_setup_update_skip_button);
first_setup_update_box.append(&first_setup_update_box_text);
first_setup_update_box.append(&first_setup_update_button);
first_setup_update_box.append(&first_setup_update_buttons_box);
first_setup_carousel.append(&first_setup_update_box);
let internet_loop_context = MainContext::default();
// The main loop executes the asynchronous block
internet_loop_context.spawn_local(clone!(@strong internet_connected_status, @weak first_setup_update_button => async move {
internet_loop_context.spawn_local(
clone!(@strong internet_connected_status, @weak first_setup_update_button => async move {
while let Ok(_state) = internet_loop_receiver.recv().await {
if *internet_connected_status.borrow_mut() == true {
first_setup_update_button.set_sensitive(true);
@ -70,9 +167,59 @@ pub fn update_carousel(first_setup_carousel: &adw::Carousel, internet_connected:
first_setup_update_button.set_label("Disabled.. Network setup was skipped");
}
}
}),
);
let log_loop_context = MainContext::default();
// The main loop executes the asynchronous block
log_loop_context.spawn_local(clone!(@weak system_update_log_terminal_buffer, @weak system_update_dialog => async move {
while let Ok(state) = log_loop_receiver.recv().await {
system_update_log_terminal_buffer.insert(&mut system_update_log_terminal_buffer.end_iter(), &("\n".to_string() + &state))
}
}));
first_setup_update_button.connect_clicked(clone!(@strong internet_connected_status, @weak first_setup_carousel => move |_| {
let log_status_loop_context = MainContext::default();
// The main loop executes the asynchronous block
log_status_loop_context.spawn_local(clone!(@weak system_update_dialog => async move {
while let Ok(state) = log_status_loop_receiver.recv().await {
if state == true {
system_update_dialog.set_response_enabled("system_update_dialog_ok", true);
system_update_dialog.set_body("Update Completed Successfully!");
} else {
system_update_dialog.set_response_enabled("system_update_dialog_ok", true);
system_update_dialog.set_body("Update Failed!\nPlease try again.");
}
}
}));
system_update_log_terminal_buffer.connect_changed(clone!(@weak system_update_log_terminal, @weak system_update_log_terminal_buffer,@weak system_update_log_terminal_scroll => move |_|{
if system_update_log_terminal_scroll.vadjustment().upper() - system_update_log_terminal_scroll.vadjustment().value() > 100.0 {
system_update_log_terminal_scroll.vadjustment().set_value(system_update_log_terminal_scroll.vadjustment().upper())
}
}));
first_setup_update_button.connect_clicked(clone!(@strong internet_connected_status, @weak system_update_log_terminal,@weak system_update_log_terminal_buffer, @weak system_update_dialog,@weak first_setup_carousel => move |_| {
system_update_log_terminal_buffer.delete(&mut system_update_log_terminal_buffer.bounds().0, &mut system_update_log_terminal_buffer.bounds().1);
system_update_dialog.set_response_enabled("system_update_dialog_ok", false);
system_update_dialog.set_body("");
system_update_dialog.present();
// The long running operation runs now in a separate thread
gio::spawn_blocking(clone!(@strong log_loop_sender, @strong log_status_loop_sender => move || {
let command = apt_update(log_loop_sender);
match command {
Ok(_) => {
println!("Status: Apt System Upgrade Successful");
log_status_loop_sender.send_blocking(true).expect("The channel needs to be open.");
}
Err(_) => {
println!("Status: Apt System Failed");
log_status_loop_sender.send_blocking(false).expect("The channel needs to be open.");
}
}
}));
}));
first_setup_update_skip_button.connect_clicked(clone!(@weak first_setup_carousel => move |_|{
first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(4), true);
}));
}

View File

@ -1,23 +1,23 @@
// GTK crates
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 crate::check_internet_connection;
use std::process::Command;
use std::cell::RefCell;
use std::rc::Rc;
use std::borrow::Borrow as the_rc_borrow;
use regex::Regex;
use std::{env, thread, time};
use gtk::Align::Center;
use gtk::gio::ffi::GAsyncReadyCallback;
use gtk::pango::TextTransform::Capitalize;
use gtk::Align::Center;
use regex::Regex;
use std::borrow::Borrow as the_rc_borrow;
use std::cell::RefCell;
use std::process::Command;
use std::rc::Rc;
use std::{env, thread, time};
fn only_alphanumeric(input: &str) -> bool {
return input.chars().all(|c| c.is_alphanumeric());
@ -32,7 +32,6 @@ fn uppercase_first_letter(s: &str) -> String {
}
pub fn user_carousel(first_setup_carousel: &adw::Carousel) {
let user_info_username_valid = Rc::new(RefCell::new(false));
let user_info_full_name_valid = Rc::new(RefCell::new(false));
let user_info_passwords_valid = Rc::new(RefCell::new(false));
@ -40,11 +39,11 @@ pub fn user_carousel(first_setup_carousel: &adw::Carousel) {
let (user_loop_sender, user_loop_receiver) = async_channel::unbounded();
let user_loop_sender = user_loop_sender.clone();
// The long running operation runs now in a separate thread
gio::spawn_blocking(move || {
loop {
gio::spawn_blocking(move || loop {
thread::sleep(time::Duration::from_secs(1));
user_loop_sender.send_blocking(true).expect("The channel needs to be open.");
}
user_loop_sender
.send_blocking(true)
.expect("The channel needs to be open.");
});
let first_setup_user_box = gtk::Box::builder()
@ -179,7 +178,6 @@ pub fn user_carousel(first_setup_carousel: &adw::Carousel) {
}
}));
user_info_username.connect_changed(clone!(@strong user_info_username_valid, @weak user_info_username, @weak user_info_full_name, @weak error_label => move |_| {
let user_info_username_string = user_info_username.text().to_string();
@ -199,39 +197,35 @@ pub fn user_carousel(first_setup_carousel: &adw::Carousel) {
let mut username_is_pikaos = false;
let mut username_is_special = false;
if only_alphanumeric(&user_info_username_string) {
error_label.set_visible(false);
if user_info_username_string != "root" {
username_is_root=false;
} else {
error_label.set_visible(true);
error_label.set_label("Username can not contain special characters.");
error_label.set_label("Username can not be root.");
username_is_root=true;
}
if user_info_username_string != "pikaos" {
error_label.set_visible(false);
username_is_pikaos=false;
} else {
error_label.set_visible(true);
error_label.set_label("Username can not be pikaos.");
username_is_pikaos=true;
}
if user_info_username_string != "root" {
error_label.set_visible(false);
if only_alphanumeric(&user_info_username_string) {
username_is_special=false;
} else {
error_label.set_visible(true);
error_label.set_label("Username can not be root.");
error_label.set_label("Username can not contain special characters.");
username_is_special=true;
}
if username_is_root == false && username_is_pikaos == false && username_is_special == false {
error_label.set_visible(false);
if !user_info_username.text().is_empty() {
*user_info_username_valid.borrow_mut()=true;
}
} else {
*user_info_username_valid.borrow_mut()=false;
error_label.set_visible(true);
}
}));
@ -276,7 +270,6 @@ pub fn user_carousel(first_setup_carousel: &adw::Carousel) {
}
}));
user_next_button.connect_clicked(clone!(@weak first_setup_carousel => move |_| {
first_setup_carousel.scroll_to(&first_setup_carousel.nth_page(3), true);
}));

View File

@ -1,12 +1,12 @@
// GTK crates
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;
// application crates
mod build_ui;
@ -20,7 +20,10 @@ mod first_setup;
/// main function
fn main() {
let application = adw::Application::new(Some("com.github.pikaos-linux.pikafirstsetup"), Default::default());
let application = adw::Application::new(
Some("com.github.pikaos-linux.pikafirstsetup"),
Default::default(),
);
application.connect_startup(|app| {
// The CSS "magic" happens here.
let provider = CssProvider::new();
@ -38,4 +41,3 @@ fn main() {
application.run();
}

View File

@ -1,16 +1,15 @@
// GTK crates
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();
glib_settings.set_int("window-width", size.0);

View File

@ -1 +1 @@
{"rustc_fingerprint":11104695642277176061,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/ward/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.75.0 (82e1608df 2023-12-21)\nbinary: rustc\ncommit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112\ncommit-date: 2023-12-21\nhost: x86_64-unknown-linux-gnu\nrelease: 1.75.0\nLLVM version: 17.0.6\n","stderr":""}},"successes":{}}
{"rustc_fingerprint":11104695642277176061,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.75.0 (82e1608df 2023-12-21)\nbinary: rustc\ncommit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112\ncommit-date: 2023-12-21\nhost: x86_64-unknown-linux-gnu\nrelease: 1.75.0\nLLVM version: 17.0.6\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/ward/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}