almost
This commit is contained in:
parent
76766a4b48
commit
ce66e6dea8
@ -139,30 +139,37 @@ 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()));
|
||||||
|
|
||||||
let (sender, receiver) = MainContext::channel(Priority::default());
|
let (sender, receiver) = async_channel::unbounded();
|
||||||
|
// Connect to "clicked" signal of `button`
|
||||||
window.connect_show(move |_| {
|
window.connect_show(move |_| {
|
||||||
let sender = sender.clone();
|
let sender = sender.clone();
|
||||||
// The long running operation runs now in a separate thread
|
// The long running operation runs now in a separate thread
|
||||||
thread::spawn(move || {
|
gio::spawn_blocking(move || {
|
||||||
sender.send(false).expect("Could not send through channel");
|
// Deactivate the button until the operation is done
|
||||||
|
while gtk_loops == true {
|
||||||
|
let ten_seconds = Duration::from_secs(1);
|
||||||
|
thread::sleep(ten_seconds);
|
||||||
|
if content_stack.visible_child_name().expect("gstring to string").as_str() == "welcome_page" {
|
||||||
|
sender
|
||||||
|
.send_blocking(false)
|
||||||
|
.expect("The channel needs to be open.");
|
||||||
|
} else {
|
||||||
|
sender
|
||||||
|
.send_blocking(true)
|
||||||
|
.expect("The channel needs to be open.");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
receiver.attach(
|
let main_context = MainContext::default();
|
||||||
None,
|
// The main loop executes the asynchronous block
|
||||||
clone!(@weak bottom_box => @default-return Continue(false),
|
main_context.spawn_local(clone!(@weak bottom_box => async move {
|
||||||
move |state| {
|
while let Ok(state) = receiver.recv().await {
|
||||||
bottom_box_loop(&bottom_box, state);
|
bottom_box.set_visible(state);
|
||||||
glib::ControlFlow::Continue
|
}
|
||||||
}
|
}));
|
||||||
),
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bottom_box_loop(bottom_box: >k::Box, state: bool) {
|
|
||||||
bottom_box.set_visible(state)
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user