mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-01 21:58:43 +00:00
fix: calibration synchronization
This commit is contained in:
parent
a0acc92058
commit
ec6c7f447d
1 changed files with 8 additions and 17 deletions
|
@ -1,10 +1,7 @@
|
||||||
use crate::{profile::Profile, runner::Runner};
|
use crate::{profile::Profile, runner::Runner};
|
||||||
use gtk::{
|
use gtk::{glib, prelude::*};
|
||||||
glib::{self, ffi::gboolean},
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
use relm4::prelude::*;
|
use relm4::prelude::*;
|
||||||
use std::{cell::Cell, collections::HashMap, path::Path, time::Duration};
|
use std::{cell::Cell, collections::HashMap, path::Path, rc::Rc, time::Duration};
|
||||||
|
|
||||||
const NO_FILE_MSG: &str = "(No file selected)";
|
const NO_FILE_MSG: &str = "(No file selected)";
|
||||||
const CALIBRATION_RUN_TIME_SECONDS: f64 = 30.0;
|
const CALIBRATION_RUN_TIME_SECONDS: f64 = 30.0;
|
||||||
|
@ -29,7 +26,7 @@ pub struct LibsurviveSetupWindow {
|
||||||
filefilter_listmodel: gtk::gio::ListStore,
|
filefilter_listmodel: gtk::gio::ListStore,
|
||||||
|
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
calibration_running: Cell<bool>,
|
calibration_running: Rc<Cell<bool>>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
first_run_done: bool,
|
first_run_done: bool,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
|
@ -71,7 +68,7 @@ impl LibsurviveSetupWindow {
|
||||||
fn on_close_request(
|
fn on_close_request(
|
||||||
sender: &relm4::ComponentSender<Self>,
|
sender: &relm4::ComponentSender<Self>,
|
||||||
carousel: &adw::Carousel,
|
carousel: &adw::Carousel,
|
||||||
calibration_running: &Cell<bool>,
|
calibration_running: &Rc<Cell<bool>>,
|
||||||
progressbar: >k::ProgressBar,
|
progressbar: >k::ProgressBar,
|
||||||
page1: &adw::StatusPage,
|
page1: &adw::StatusPage,
|
||||||
) -> gtk::Inhibit {
|
) -> gtk::Inhibit {
|
||||||
|
@ -97,12 +94,6 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
set_modal: true,
|
set_modal: true,
|
||||||
set_default_size: (520, 400),
|
set_default_size: (520, 400),
|
||||||
set_hide_on_close: true,
|
set_hide_on_close: true,
|
||||||
// connect_close_request[sender, carousel, page1, progressbar] => move |_| {
|
|
||||||
// carousel.scroll_to(&page1, true);
|
|
||||||
// progressbar.set_fraction(0.0);
|
|
||||||
// sender.input(LibsurviveSetupMsg::SetSteamLighthousePath(None));
|
|
||||||
// gtk::Inhibit(false)
|
|
||||||
// },
|
|
||||||
gtk::Box {
|
gtk::Box {
|
||||||
set_orientation: gtk::Orientation::Vertical,
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
set_hexpand: true,
|
set_hexpand: true,
|
||||||
|
@ -347,10 +338,10 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
runner.start();
|
runner.start();
|
||||||
{
|
{
|
||||||
let timer_sender = sender.clone();
|
let timer_sender = sender.clone();
|
||||||
let continue_watching = self.calibration_running.clone();
|
let cont = self.calibration_running.clone();
|
||||||
glib::timeout_add_local(Duration::from_millis(1000), move || {
|
glib::timeout_add_local(Duration::from_millis(1000), move || {
|
||||||
timer_sender.input(LibsurviveSetupMsg::TickCalibrationRunner);
|
timer_sender.input(LibsurviveSetupMsg::TickCalibrationRunner);
|
||||||
return glib::Continue(continue_watching.get());
|
return glib::Continue(cont.get());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.calibration_runner = Some(runner);
|
self.calibration_runner = Some(runner);
|
||||||
|
@ -422,7 +413,7 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
init: Self::Init,
|
_init: Self::Init,
|
||||||
root: &Self::Root,
|
root: &Self::Root,
|
||||||
sender: relm4::ComponentSender<Self>,
|
sender: relm4::ComponentSender<Self>,
|
||||||
) -> relm4::ComponentParts<Self> {
|
) -> relm4::ComponentParts<Self> {
|
||||||
|
@ -441,7 +432,7 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
.build(),
|
.build(),
|
||||||
profile: None,
|
profile: None,
|
||||||
calibration_runner: None,
|
calibration_runner: None,
|
||||||
calibration_running: Cell::new(false),
|
calibration_running: Rc::new(Cell::new(false)),
|
||||||
first_run_done: false,
|
first_run_done: false,
|
||||||
calibration_seconds_elapsed: 0.0,
|
calibration_seconds_elapsed: 0.0,
|
||||||
tracker: 0,
|
tracker: 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue