mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: fan curve reset
This commit is contained in:
@@ -83,15 +83,12 @@ impl App {
|
||||
|
||||
let current_gpu_id = Arc::new(RwLock::new(String::new()));
|
||||
|
||||
{
|
||||
let current_gpu_id = current_gpu_id.clone();
|
||||
|
||||
app.header.connect_gpu_selection_changed(clone!(@strong app => move |gpu_id| {
|
||||
app.header.connect_gpu_selection_changed(clone!(@strong app, @strong current_gpu_id => move |gpu_id| {
|
||||
info!("GPU Selection changed");
|
||||
app.set_info(&gpu_id);
|
||||
*current_gpu_id.write().unwrap() = gpu_id;
|
||||
}));
|
||||
}
|
||||
|
||||
let devices_buf = app
|
||||
.daemon_client
|
||||
@@ -138,7 +135,7 @@ impl App {
|
||||
app.set_initial(&gpu_id)
|
||||
}));
|
||||
|
||||
app.start_stats_update_loop(current_gpu_id.clone());
|
||||
app.start_stats_update_loop(current_gpu_id);
|
||||
|
||||
app.window.show();
|
||||
|
||||
@@ -151,6 +148,7 @@ impl App {
|
||||
}
|
||||
}));
|
||||
|
||||
// Args are passed manually since they were already processed by clap before
|
||||
self.application.run_with_args::<String>(&[]);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use gtk::graphene::Point;
|
||||
use gtk::gsk::Transform;
|
||||
use gtk::prelude::*;
|
||||
use gtk::*;
|
||||
use lact_client::schema::FanCurveMap;
|
||||
use lact_client::schema::{default_fan_curve, FanCurveMap};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::rc::Rc;
|
||||
@@ -47,22 +47,46 @@ impl FanCurveFrame {
|
||||
|
||||
let temperature_title_label = Label::new(Some("Temperature (°C)"));
|
||||
|
||||
// let add_button = Button::builder().icon_name("list-add-symbolic").build();
|
||||
let buttons_box = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.spacing(5)
|
||||
.halign(Align::End)
|
||||
.build();
|
||||
|
||||
let add_button = Button::builder().icon_name("list-add-symbolic").build();
|
||||
let remove_button = Button::builder().icon_name("list-remove-symbolic").build();
|
||||
let default_button = Button::builder().label("Default").build();
|
||||
|
||||
buttons_box.append(&default_button);
|
||||
buttons_box.append(&remove_button);
|
||||
buttons_box.append(&add_button);
|
||||
|
||||
root_box.append(&hbox);
|
||||
root_box.append(&temperature_title_label);
|
||||
// root_box.append(&add_button);
|
||||
root_box.append(&buttons_box);
|
||||
|
||||
let points = Rc::new(RefCell::new(Vec::new()));
|
||||
|
||||
Self {
|
||||
let curve_frame = Self {
|
||||
container: root_box,
|
||||
curve_container,
|
||||
points,
|
||||
}
|
||||
};
|
||||
|
||||
default_button.connect_clicked(clone!(@strong curve_frame => move |_| {
|
||||
let curve = default_fan_curve();
|
||||
curve_frame.set_curve(&curve);
|
||||
}));
|
||||
|
||||
curve_frame
|
||||
}
|
||||
|
||||
pub fn set_curve(&self, curve: &FanCurveMap) {
|
||||
// Notify that the values were changed when the entire curve is overwritten, e.g. when resetting to default
|
||||
if let Some(point) = self.points.borrow().first() {
|
||||
point.ratio.emit_by_name::<()>("value-changed", &[]);
|
||||
}
|
||||
|
||||
let points_container = Box::builder()
|
||||
.orientation(Orientation::Horizontal)
|
||||
.spacing(5)
|
||||
|
||||
Reference in New Issue
Block a user