add broken while loop threading

This commit is contained in:
Ward from fusion-voyager-3 2024-01-15 18:33:56 +03:00
parent c6923d5283
commit 0f60c21e6b
4 changed files with 136 additions and 3 deletions

97
Cargo.lock generated
View File

@ -8,6 +8,19 @@ version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "async-channel"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c"
dependencies = [
"concurrent-queue",
"event-listener",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
@ -55,12 +68,57 @@ dependencies = [
"target-lexicon", "target-lexicon",
] ]
[[package]]
name = "concurrent-queue"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "deranged"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
dependencies = [
"powerfmt",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "event-listener"
version = "4.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e"
dependencies = [
"concurrent-queue",
"parking",
"pin-project-lite",
]
[[package]]
name = "event-listener-strategy"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3"
dependencies = [
"event-listener",
"pin-project-lite",
]
[[package]] [[package]]
name = "field-offset" name = "field-offset"
version = "0.3.6" version = "0.3.6"
@ -71,6 +129,12 @@ dependencies = [
"rustc_version", "rustc_version",
] ]
[[package]]
name = "fragile"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa"
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
version = "0.3.30" version = "0.3.30"
@ -496,12 +560,21 @@ dependencies = [
"system-deps", "system-deps",
] ]
[[package]]
name = "parking"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae"
[[package]] [[package]]
name = "pika-installer-gtk4" name = "pika-installer-gtk4"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-channel",
"fragile",
"gtk4", "gtk4",
"libadwaita", "libadwaita",
"time",
] ]
[[package]] [[package]]
@ -522,6 +595,12 @@ version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.3.1" version = "1.3.1"
@ -704,6 +783,24 @@ dependencies = [
"syn 2.0.48", "syn 2.0.48",
] ]
[[package]]
name = "time"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e"
dependencies = [
"deranged",
"powerfmt",
"serde",
"time-core",
]
[[package]]
name = "time-core"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.8.2" version = "0.8.2"

View File

@ -7,4 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
adw = { version = "0.5.3", package = "libadwaita" } adw = { version = "0.5.3", package = "libadwaita" }
async-channel = "2.1.1"
fragile = "2.0.0"
gtk = { version = "0.7.3", package = "gtk4" } gtk = { version = "0.7.3", package = "gtk4" }
time = "0.3.31"

View File

@ -11,6 +11,11 @@ use gtk::subclass::layout_child;
use crate::save_window_size; use crate::save_window_size;
use crate::welcome_page; use crate::welcome_page;
use std::thread;
use std::time::*;
use fragile::*;
// build ui function linked to app startup above // build ui function linked to app startup above
pub fn build_ui(app: &adw::Application) { pub fn build_ui(app: &adw::Application) {
@ -22,6 +27,9 @@ pub fn build_ui(app: &adw::Application) {
// Widget Bank // Widget Bank
let gtk_loops = true;
/// Create A box /// Create A box
let _main_box = gtk::Box::builder() let _main_box = gtk::Box::builder()
// that puts items vertically // that puts items vertically
@ -93,7 +101,7 @@ pub fn build_ui(app: &adw::Application) {
// Add welcome_page.rs as a page for content_stack // Add welcome_page.rs as a page for content_stack
welcome_page(&content_stack); welcome_page(&content_stack);
// create the main Application window // create the main Application window
let window = adw::ApplicationWindow::builder() let window = adw::ApplicationWindow::builder()
// The text on the titlebar // The text on the titlebar
@ -131,6 +139,25 @@ pub fn build_ui(app: &adw::Application) {
window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings))); window.connect_hide(clone!(@weak window => move |_| save_window_size(&window, &glib_settings)));
window.connect_hide(clone!(@weak window => move |_| window.destroy())); window.connect_hide(clone!(@weak window => move |_| window.destroy()));
// show the window window.show();
window.show()
let bottom_box_clone = fragile::Fragile::new(bottom_box.clone());
let content_stack_clone = fragile::Fragile::new(content_stack.clone());
gio::spawn_blocking(move || {
while gtk_loops == true {
glib::MainContext::default().invoke( move || {
bottom_box_loop( &bottom_box_clone, &content_stack_clone)
});
}
});
}
fn bottom_box_loop(bottom_box: &Fragile<gtk::Box>, content_stack: &Fragile<Stack>) {
if content_stack.get().visible_child_name().expect("gstring to string").as_str() == "welcome_page" {
bottom_box.get().set_visible(false)
} else {
bottom_box.get().set_visible(true)
}
} }

View File

@ -128,4 +128,10 @@ pub fn welcome_page(content_stack: &gtk::Stack) {
// / Content stack appends // / Content stack appends
//// Add the welcome_main_box as page: welcome_page, Give it nice title //// 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"), "Welcome");
let hahaha = gtk::Button::builder()
.label("Rot")
.build();
content_stack.add_titled(&hahaha, Some("shit_page"), "SHit");
} }