mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
chore: update dependencies, adopt new gtk-rs clone macro syntax
This commit is contained in:
parent
f9f4225a88
commit
cd9a3b2f31
637
Cargo.lock
generated
637
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -19,8 +19,8 @@ anyhow = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
|
||||
gtk = { version = "0.8", package = "gtk4", features = ["v4_6", "blueprint"] }
|
||||
adw = { package = "libadwaita", version = "0.6.0", features = [
|
||||
gtk = { version = "0.9", package = "gtk4", features = ["v4_6", "blueprint"] }
|
||||
adw = { package = "libadwaita", version = "0.7.0", features = [
|
||||
"v1_4",
|
||||
], optional = true }
|
||||
|
||||
@ -31,7 +31,7 @@ plotters = { version = "0.3.5", default-features = false, features = [
|
||||
"histogram",
|
||||
"full_palette",
|
||||
] }
|
||||
plotters-cairo = "0.6.0"
|
||||
plotters-cairo = "0.7.0"
|
||||
itertools = "0.13.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -98,19 +98,27 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn run(self, connection_err: Option<anyhow::Error>) -> anyhow::Result<()> {
|
||||
self.application
|
||||
.connect_activate(clone!(@strong self as app => move |_| {
|
||||
self.application.connect_activate(clone!(
|
||||
#[strong(rename_to = app)]
|
||||
self,
|
||||
move |_| {
|
||||
app.window.set_application(Some(&app.application));
|
||||
|
||||
let current_gpu_id = Rc::new(RefCell::new(String::new()));
|
||||
|
||||
app.header.connect_gpu_selection_changed(clone!(@strong app, @strong current_gpu_id => move |gpu_id| {
|
||||
debug!("GPU Selection changed");
|
||||
app.set_info(&gpu_id);
|
||||
*current_gpu_id.borrow_mut() = gpu_id;
|
||||
debug!("Updated current GPU id");
|
||||
app.graphs_window.clear();
|
||||
}));
|
||||
app.header.connect_gpu_selection_changed(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move |gpu_id| {
|
||||
debug!("GPU Selection changed");
|
||||
app.set_info(&gpu_id);
|
||||
*current_gpu_id.borrow_mut() = gpu_id;
|
||||
debug!("Updated current GPU id");
|
||||
app.graphs_window.clear();
|
||||
}
|
||||
));
|
||||
|
||||
let devices_buf = app
|
||||
.daemon_client
|
||||
@ -119,108 +127,184 @@ impl App {
|
||||
let devices = devices_buf.inner().expect("Could not access devices");
|
||||
app.header.set_devices(&devices);
|
||||
|
||||
app.root_stack.oc_page.clocks_frame.connect_clocks_reset(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
debug!("Resetting clocks");
|
||||
app.root_stack
|
||||
.oc_page
|
||||
.clocks_frame
|
||||
.connect_clocks_reset(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move || {
|
||||
debug!("Resetting clocks");
|
||||
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
|
||||
match app.daemon_client.set_clocks_value(&gpu_id, SetClocksCommand::Reset)
|
||||
.and_then(|_| app.daemon_client.confirm_pending_config(ConfirmCommand::Confirm))
|
||||
{
|
||||
Ok(()) => {
|
||||
app.set_initial(&gpu_id);
|
||||
}
|
||||
Err(err) => {
|
||||
show_error(&app.window, err);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
app.root_stack.thermals_page.connect_reset_pmfw(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
debug!("Resetting PMFW settings");
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
|
||||
match app.daemon_client.reset_pmfw(&gpu_id)
|
||||
.and_then(|buffer| buffer.inner())
|
||||
.and_then(|_| app.daemon_client.confirm_pending_config(ConfirmCommand::Confirm))
|
||||
{
|
||||
Ok(()) => {
|
||||
app.set_initial(&gpu_id);
|
||||
}
|
||||
Err(err) => {
|
||||
show_error(&app.window, err);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
app.apply_revealer.connect_apply_button_clicked(
|
||||
clone!(@strong app, @strong current_gpu_id => move || {
|
||||
glib::idle_add_local_once(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
if let Err(err) = app.apply_settings(current_gpu_id.clone())
|
||||
.context("Could not apply settings (GUI)")
|
||||
{
|
||||
show_error(&app.window, err);
|
||||
|
||||
glib::idle_add_local_once(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
app.set_initial(&gpu_id)
|
||||
}));
|
||||
match app
|
||||
.daemon_client
|
||||
.set_clocks_value(&gpu_id, SetClocksCommand::Reset)
|
||||
.and_then(|_| {
|
||||
app.daemon_client
|
||||
.confirm_pending_config(ConfirmCommand::Confirm)
|
||||
}) {
|
||||
Ok(()) => {
|
||||
app.set_initial(&gpu_id);
|
||||
}
|
||||
Err(err) => {
|
||||
show_error(&app.window, err);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}),
|
||||
);
|
||||
app.apply_revealer.connect_reset_button_clicked(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
app.set_initial(&gpu_id)
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
app.root_stack.thermals_page.connect_reset_pmfw(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move || {
|
||||
debug!("Resetting PMFW settings");
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
|
||||
match app
|
||||
.daemon_client
|
||||
.reset_pmfw(&gpu_id)
|
||||
.and_then(|buffer| buffer.inner())
|
||||
.and_then(|_| {
|
||||
app.daemon_client
|
||||
.confirm_pending_config(ConfirmCommand::Confirm)
|
||||
}) {
|
||||
Ok(()) => {
|
||||
app.set_initial(&gpu_id);
|
||||
}
|
||||
Err(err) => {
|
||||
show_error(&app.window, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
app.apply_revealer.connect_apply_button_clicked(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move || {
|
||||
glib::idle_add_local_once(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move || {
|
||||
if let Err(err) = app
|
||||
.apply_settings(current_gpu_id.clone())
|
||||
.context("Could not apply settings (GUI)")
|
||||
{
|
||||
show_error(&app.window, err);
|
||||
|
||||
glib::idle_add_local_once(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move || {
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
app.set_initial(&gpu_id)
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
));
|
||||
app.apply_revealer.connect_reset_button_clicked(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move || {
|
||||
let gpu_id = current_gpu_id.borrow().clone();
|
||||
app.set_initial(&gpu_id)
|
||||
}
|
||||
));
|
||||
|
||||
if let Some(ref button) = app.root_stack.oc_page.enable_overclocking_button {
|
||||
button.connect_clicked(clone!(@strong app => move |_| {
|
||||
app.enable_overclocking();
|
||||
}));
|
||||
button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
move |_| {
|
||||
app.enable_overclocking();
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
let snapshot_action = ActionEntry::builder("generate-debug-snapshot")
|
||||
.activate(clone!(@strong app => move |_, _, _| {
|
||||
app.generate_debug_snapshot();
|
||||
}))
|
||||
.activate(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
move |_, _, _| {
|
||||
app.generate_debug_snapshot();
|
||||
}
|
||||
))
|
||||
.build();
|
||||
|
||||
let disable_overdive_action = ActionEntry::builder("disable-overdrive")
|
||||
.activate(clone!(@strong app => move |_, _, _| {
|
||||
app.disable_overclocking();
|
||||
}))
|
||||
.activate(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
move |_, _, _| {
|
||||
app.disable_overclocking();
|
||||
}
|
||||
))
|
||||
.build();
|
||||
|
||||
let show_graphs_window_action = ActionEntry::builder("show-graphs-window")
|
||||
.activate(clone!(@strong app => move |_, _, _| {
|
||||
app.graphs_window.show();
|
||||
}))
|
||||
.activate(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
move |_, _, _| {
|
||||
app.graphs_window.show();
|
||||
}
|
||||
))
|
||||
.build();
|
||||
|
||||
let dump_vbios_action = ActionEntry::builder("dump-vbios")
|
||||
.activate(clone!(@strong app, @strong current_gpu_id => move |_, _, _| {
|
||||
let gpu_id = current_gpu_id.borrow();
|
||||
app.dump_vbios(&gpu_id);
|
||||
}))
|
||||
.activate(clone!(
|
||||
#[strong]
|
||||
app,
|
||||
#[strong]
|
||||
current_gpu_id,
|
||||
move |_, _, _| {
|
||||
let gpu_id = current_gpu_id.borrow();
|
||||
app.dump_vbios(&gpu_id);
|
||||
}
|
||||
))
|
||||
.build();
|
||||
|
||||
app.application.add_action_entries([snapshot_action, disable_overdive_action, show_graphs_window_action, dump_vbios_action]);
|
||||
app.application.add_action_entries([
|
||||
snapshot_action,
|
||||
disable_overdive_action,
|
||||
show_graphs_window_action,
|
||||
dump_vbios_action,
|
||||
]);
|
||||
|
||||
app.start_stats_update_loop(current_gpu_id);
|
||||
|
||||
app.window.show();
|
||||
|
||||
if app.daemon_client.embedded {
|
||||
let error_text = connection_err.as_ref().map(|err| {
|
||||
format!("Error info: {err:#}\n\n")
|
||||
}).unwrap_or_default();
|
||||
let error_text = connection_err
|
||||
.as_ref()
|
||||
.map(|err| format!("Error info: {err:#}\n\n"))
|
||||
.unwrap_or_default();
|
||||
|
||||
let text = format!("Could not connect to daemon, running in embedded mode. \n\
|
||||
let text = format!(
|
||||
"Could not connect to daemon, running in embedded mode. \n\
|
||||
Please make sure the lactd service is running. \n\
|
||||
Using embedded mode, you will not be able to change any settings. \n\n\
|
||||
{error_text}\
|
||||
To enable the daemon, run the following command:");
|
||||
To enable the daemon, run the following command:"
|
||||
);
|
||||
|
||||
let text_label = Label::new(Some(&text));
|
||||
let enable_label = Entry::builder()
|
||||
@ -249,13 +333,18 @@ impl App {
|
||||
.transient_for(&app.window)
|
||||
.build();
|
||||
|
||||
close_button.connect_clicked(clone!(@strong diag => move |_| diag.hide()));
|
||||
close_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
diag,
|
||||
move |_| diag.hide()
|
||||
));
|
||||
|
||||
diag.run_async(|diag, _| {
|
||||
diag.hide();
|
||||
})
|
||||
}
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
// Args are passed manually since they were already processed by clap before
|
||||
self.application.run_with_args::<String>(&[]);
|
||||
@ -338,10 +427,14 @@ impl App {
|
||||
|
||||
// Show apply button on setting changes
|
||||
// This is done here because new widgets may appear after applying settings (like fan curve points) which should be connected
|
||||
let show_revealer = clone!(@strong self.apply_revealer as apply_revealer => move || {
|
||||
let show_revealer = clone!(
|
||||
#[strong(rename_to = apply_revealer)]
|
||||
self.apply_revealer,
|
||||
move || {
|
||||
debug!("settings changed, showing apply button");
|
||||
apply_revealer.show();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
self.root_stack
|
||||
.thermals_page
|
||||
@ -356,8 +449,14 @@ impl App {
|
||||
|
||||
fn start_stats_update_loop(&self, current_gpu_id: Rc<RefCell<String>>) {
|
||||
// The loop that gets stats
|
||||
glib::spawn_future_local(
|
||||
clone!(@strong self.daemon_client as daemon_client, @strong self.root_stack as root_stack, @strong self.graphs_window as graphs_window => async move {
|
||||
glib::spawn_future_local(clone!(
|
||||
#[strong(rename_to = daemon_client)]
|
||||
self.daemon_client,
|
||||
#[strong(rename_to = root_stack)]
|
||||
self.root_stack,
|
||||
#[strong(rename_to = graphs_window)]
|
||||
self.graphs_window,
|
||||
async move {
|
||||
loop {
|
||||
{
|
||||
let gpu_id = current_gpu_id.borrow();
|
||||
@ -380,8 +479,8 @@ impl App {
|
||||
}
|
||||
timeout_future(Duration::from_millis(STATS_POLL_INTERVAL)).await;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
fn apply_settings(&self, current_gpu_id: Rc<RefCell<String>>) -> anyhow::Result<()> {
|
||||
@ -570,7 +669,7 @@ impl App {
|
||||
.transient_for(&self.window)
|
||||
.build();
|
||||
|
||||
dialog.run_async(clone!(@strong self as app => move |diag, response| {
|
||||
dialog.run_async(clone!(#[strong(rename_to = app)] self, move |diag, response| {
|
||||
if response == ResponseType::Ok {
|
||||
let handle = gio::spawn_blocking(|| {
|
||||
let (daemon_client, _) = create_connection().expect("Could not create new daemon connection");
|
||||
@ -616,7 +715,7 @@ impl App {
|
||||
.transient_for(&self.window)
|
||||
.build();
|
||||
|
||||
dialog.run_async(clone!(@strong self as app => move |diag, _| {
|
||||
dialog.run_async(clone!(#[strong(rename_to = app)] self, move |diag, _| {
|
||||
diag.hide();
|
||||
|
||||
let handle = gio::spawn_blocking(|| {
|
||||
@ -674,14 +773,18 @@ impl App {
|
||||
.map(|(id, _)| id.replace(':', "_"))
|
||||
.unwrap_or_default();
|
||||
file_chooser.set_current_name(&format!("{file_name_suffix}_vbios_dump.rom"));
|
||||
file_chooser.run_async(
|
||||
clone!(@strong self.window as window => move |diag, _| {
|
||||
file_chooser.run_async(clone!(
|
||||
#[strong(rename_to = window)]
|
||||
self.window,
|
||||
move |diag, _| {
|
||||
diag.close();
|
||||
|
||||
if let Some(file) = diag.file() {
|
||||
match file.path() {
|
||||
Some(path) => {
|
||||
if let Err(err) = std::fs::write(path, vbios_data).context("Could not save vbios file") {
|
||||
if let Err(err) = std::fs::write(path, vbios_data)
|
||||
.context("Could not save vbios file")
|
||||
{
|
||||
show_error(&window, err);
|
||||
}
|
||||
}
|
||||
@ -691,8 +794,8 @@ impl App {
|
||||
),
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
}
|
||||
Err(err) => show_error(&self.window, err),
|
||||
}
|
||||
@ -711,42 +814,55 @@ impl App {
|
||||
|
||||
glib::source::timeout_add_local(
|
||||
Duration::from_secs(1),
|
||||
clone!(@strong dialog, @strong self as app, @strong gpu_id, @strong confirmed => move || {
|
||||
if confirmed.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
return ControlFlow::Break;
|
||||
clone!(
|
||||
#[strong]
|
||||
dialog,
|
||||
#[strong(rename_to = app)]
|
||||
self,
|
||||
#[strong]
|
||||
gpu_id,
|
||||
#[strong]
|
||||
confirmed,
|
||||
move || {
|
||||
if confirmed.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
return ControlFlow::Break;
|
||||
}
|
||||
delay -= 1;
|
||||
|
||||
let text = confirmation_text(delay);
|
||||
dialog.set_text(Some(&text));
|
||||
|
||||
if delay == 0 {
|
||||
dialog.hide();
|
||||
app.set_initial(&gpu_id);
|
||||
|
||||
ControlFlow::Break
|
||||
} else {
|
||||
ControlFlow::Continue
|
||||
}
|
||||
}
|
||||
delay -= 1;
|
||||
|
||||
let text = confirmation_text(delay);
|
||||
dialog.set_text(Some(&text));
|
||||
|
||||
if delay == 0 {
|
||||
dialog.hide();
|
||||
app.set_initial(&gpu_id);
|
||||
|
||||
ControlFlow::Break
|
||||
} else {
|
||||
ControlFlow::Continue
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
dialog.run_async(clone!(@strong self as app => move |diag, response| {
|
||||
confirmed.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
dialog.run_async(clone!(
|
||||
#[strong(rename_to = app)]
|
||||
self,
|
||||
move |diag, response| {
|
||||
confirmed.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
|
||||
let command = match response {
|
||||
ResponseType::Yes => ConfirmCommand::Confirm,
|
||||
_ => ConfirmCommand::Revert,
|
||||
};
|
||||
let command = match response {
|
||||
ResponseType::Yes => ConfirmCommand::Confirm,
|
||||
_ => ConfirmCommand::Revert,
|
||||
};
|
||||
|
||||
diag.hide();
|
||||
diag.hide();
|
||||
|
||||
if let Err(err) = app.daemon_client.confirm_pending_config(command) {
|
||||
show_error(&app.window, err);
|
||||
if let Err(err) = app.daemon_client.confirm_pending_config(command) {
|
||||
show_error(&app.window, err);
|
||||
}
|
||||
app.set_initial(&gpu_id);
|
||||
}
|
||||
app.set_initial(&gpu_id);
|
||||
}));
|
||||
));
|
||||
}
|
||||
|
||||
fn spinner_dialog(&self, title: &str) -> MessageDialog {
|
||||
|
@ -83,20 +83,25 @@ mod imp {
|
||||
PropertyExpression::new(VulkanFeature::static_type(), Expression::NONE, "name");
|
||||
self.search_filter.set_expression(Some(&expression));
|
||||
|
||||
self.search_entry.connect_search_changed(
|
||||
clone!(@strong self.search_filter as filter => move |entry| {
|
||||
self.search_entry.connect_search_changed(clone!(
|
||||
#[strong(rename_to = filter)]
|
||||
self.search_filter,
|
||||
move |entry| {
|
||||
if entry.text().is_empty() {
|
||||
filter.set_search(None);
|
||||
} else {
|
||||
filter.set_search(Some(entry.text().as_str()));
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
self.search_entry
|
||||
.connect_stop_search(clone!(@weak obj as win => move |_search| {
|
||||
self.search_entry.connect_stop_search(clone!(
|
||||
#[weak(rename_to = win)]
|
||||
obj,
|
||||
move |_search| {
|
||||
win.close();
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
self.features_factory.connect_setup(|_, list_item| {
|
||||
let feature = VulkanFeature::default();
|
||||
|
@ -39,15 +39,23 @@ impl VulkanInfoFrame {
|
||||
let driver_version_label = label_row("Driver version:", &grid, 3, 0, true);
|
||||
|
||||
let show_features_button = Button::builder().label("Show").halign(Align::End).build();
|
||||
show_features_button.connect_clicked(clone!(@strong features_model => move |_| {
|
||||
show_features_window("Vulkan features", features_model.clone());
|
||||
}));
|
||||
show_features_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
features_model,
|
||||
move |_| {
|
||||
show_features_window("Vulkan features", features_model.clone());
|
||||
}
|
||||
));
|
||||
values_row("Features:", &grid, &show_features_button, 4, 0);
|
||||
|
||||
let show_extensions_button = Button::builder().label("Show").halign(Align::End).build();
|
||||
show_extensions_button.connect_clicked(clone!(@strong extensions_model => move |_| {
|
||||
show_features_window("Vulkan extensions", extensions_model.clone());
|
||||
}));
|
||||
show_extensions_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
extensions_model,
|
||||
move |_| {
|
||||
show_features_window("Vulkan extensions", extensions_model.clone());
|
||||
}
|
||||
));
|
||||
values_row("Extensions:", &grid, &show_extensions_button, 5, 0);
|
||||
|
||||
container.append(&grid);
|
||||
|
@ -116,16 +116,20 @@ impl ClocksFrame {
|
||||
|
||||
frame.set_configuration_mode(false);
|
||||
|
||||
frame
|
||||
.basic_togglebutton
|
||||
.connect_clicked(clone!(@strong frame => move |button| {
|
||||
frame.basic_togglebutton.connect_clicked(clone!(
|
||||
#[strong]
|
||||
frame,
|
||||
move |button| {
|
||||
frame.set_configuration_mode(!button.is_active());
|
||||
}));
|
||||
frame
|
||||
.advanced_togglebutton
|
||||
.connect_clicked(clone!(@strong frame => move |button| {
|
||||
}
|
||||
));
|
||||
frame.advanced_togglebutton.connect_clicked(clone!(
|
||||
#[strong]
|
||||
frame,
|
||||
move |button| {
|
||||
frame.set_configuration_mode(button.is_active());
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
frame
|
||||
}
|
||||
@ -284,7 +288,11 @@ impl ClocksFrame {
|
||||
}
|
||||
|
||||
pub fn connect_clocks_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
let f = clone!(@strong f => move |_: &Adjustment| f());
|
||||
let f = clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_: &Adjustment| f()
|
||||
);
|
||||
self.min_sclk_adjustment.0.connect_value_changed(f.clone());
|
||||
self.min_mclk_adjustment.0.connect_value_changed(f.clone());
|
||||
self.min_voltage_adjustment
|
||||
@ -385,22 +393,32 @@ fn oc_adjustment(
|
||||
|
||||
let changed = Rc::new(AtomicBool::new(false));
|
||||
|
||||
adjustment.connect_value_changed(
|
||||
clone!(@strong value_label, @strong changed => move |adjustment| {
|
||||
adjustment.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
value_label,
|
||||
#[strong]
|
||||
changed,
|
||||
move |adjustment| {
|
||||
changed.store(true, Ordering::SeqCst);
|
||||
|
||||
let value = adjustment.value();
|
||||
value_label.set_text(&value.to_string());
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
scale.connect_visible_notify(
|
||||
clone!(@strong label, @strong value_label, @strong value_button => move |scale| {
|
||||
scale.connect_visible_notify(clone!(
|
||||
#[strong]
|
||||
label,
|
||||
#[strong]
|
||||
value_label,
|
||||
#[strong]
|
||||
value_button,
|
||||
move |scale| {
|
||||
label.set_visible(scale.get_visible());
|
||||
value_button.set_visible(scale.get_visible());
|
||||
value_label.set_visible(scale.get_visible());
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
grid.attach(&label, 0, row, 1, 1);
|
||||
grid.attach(&scale, 1, row, 4, 1);
|
||||
|
@ -62,12 +62,16 @@ impl OcPage {
|
||||
let clocks_frame = ClocksFrame::new();
|
||||
let power_states_frame = PowerStatesFrame::new();
|
||||
|
||||
performance_level_frame.connect_settings_changed(
|
||||
clone!(@strong performance_level_frame, @strong power_states_frame => move || {
|
||||
performance_level_frame.connect_settings_changed(clone!(
|
||||
#[strong]
|
||||
performance_level_frame,
|
||||
#[strong]
|
||||
power_states_frame,
|
||||
move || {
|
||||
let level = performance_level_frame.get_selected_performance_level();
|
||||
power_states_frame.set_configurable(level == PerformanceLevel::Manual);
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
vbox.append(&power_cap_section);
|
||||
vbox.append(&performance_level_frame.container);
|
||||
@ -128,8 +132,11 @@ impl OcPage {
|
||||
|
||||
pub fn connect_settings_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
self.performance_frame.connect_settings_changed(f.clone());
|
||||
self.power_cap_section
|
||||
.connect_current_value_notify(clone!(@strong f => move |_| f()));
|
||||
self.power_cap_section.connect_current_value_notify(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| f()
|
||||
));
|
||||
self.clocks_frame.connect_clocks_changed(f.clone());
|
||||
self.power_states_frame.connect_values_changed(f);
|
||||
}
|
||||
|
@ -74,17 +74,21 @@ impl PerformanceFrame {
|
||||
modes_table: Rc::new(RefCell::new(None)),
|
||||
};
|
||||
|
||||
frame
|
||||
.level_drop_down
|
||||
.connect_selected_notify(clone!(@strong frame => move |_| {
|
||||
frame.level_drop_down.connect_selected_notify(clone!(
|
||||
#[strong]
|
||||
frame,
|
||||
move |_| {
|
||||
frame.update_from_selection();
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
frame
|
||||
.mode_drop_down
|
||||
.connect_selected_notify(clone!(@strong frame => move |_| {
|
||||
frame.mode_drop_down.connect_selected_notify(clone!(
|
||||
#[strong]
|
||||
frame,
|
||||
move |_| {
|
||||
frame.update_from_selection();
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
frame
|
||||
}
|
||||
@ -125,8 +129,11 @@ impl PerformanceFrame {
|
||||
}
|
||||
|
||||
pub fn connect_settings_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
self.level_drop_down
|
||||
.connect_selected_notify(clone!(@strong f => move |_| f()));
|
||||
self.level_drop_down.connect_selected_notify(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| f()
|
||||
));
|
||||
self.mode_drop_down.connect_selected_notify(move |_| f());
|
||||
}
|
||||
|
||||
|
@ -85,15 +85,18 @@ mod imp {
|
||||
|
||||
let obj = self.obj();
|
||||
|
||||
obj.connect_current_value_notify(clone!(@strong obj => move |section| {
|
||||
obj.connect_current_value_notify(move |section| {
|
||||
let text = format!("{}/{} W", section.current_value(), section.max_value());
|
||||
section.set_value_text(text);
|
||||
}));
|
||||
});
|
||||
|
||||
self.reset_button
|
||||
.connect_clicked(clone!(@strong obj => move |_| {
|
||||
self.reset_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
obj,
|
||||
move |_| {
|
||||
obj.set_current_value(obj.default_value());
|
||||
}));
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,11 @@ impl PowerStatesList {
|
||||
|
||||
pub fn connect_values_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
for row in self.rows() {
|
||||
row.connect_enabled_notify(clone!(@strong f => move |_| f()));
|
||||
row.connect_enabled_notify(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| f()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,20 +119,32 @@ impl FanCurveFrame {
|
||||
hysteresis_grid,
|
||||
};
|
||||
|
||||
default_button.connect_clicked(clone!(@strong curve_frame => move |_| {
|
||||
let curve = default_fan_curve();
|
||||
curve_frame.set_curve(&curve);
|
||||
spindown_delay_adj.set_value(DEFAULT_SPINDOWN_DELAY_MS as f64);
|
||||
change_threshold_adj.set_value(DEFAULT_CHANGE_THRESHOLD as f64);
|
||||
}));
|
||||
default_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
curve_frame,
|
||||
move |_| {
|
||||
let curve = default_fan_curve();
|
||||
curve_frame.set_curve(&curve);
|
||||
spindown_delay_adj.set_value(DEFAULT_SPINDOWN_DELAY_MS as f64);
|
||||
change_threshold_adj.set_value(DEFAULT_CHANGE_THRESHOLD as f64);
|
||||
}
|
||||
));
|
||||
|
||||
add_button.connect_clicked(clone!(@strong curve_frame => move |_| {
|
||||
curve_frame.add_point();
|
||||
}));
|
||||
add_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
curve_frame,
|
||||
move |_| {
|
||||
curve_frame.add_point();
|
||||
}
|
||||
));
|
||||
|
||||
remove_button.connect_clicked(clone!(@strong curve_frame => move |_| {
|
||||
curve_frame.remove_point();
|
||||
}));
|
||||
remove_button.connect_clicked(clone!(
|
||||
#[strong]
|
||||
curve_frame,
|
||||
move |_| {
|
||||
curve_frame.remove_point();
|
||||
}
|
||||
));
|
||||
|
||||
curve_frame
|
||||
}
|
||||
@ -195,18 +207,28 @@ impl FanCurveFrame {
|
||||
}
|
||||
|
||||
pub fn connect_adjusted<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
self.change_threshold_adj
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
self.change_threshold_adj.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}));
|
||||
self.spindown_delay_adj
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
}
|
||||
));
|
||||
self.spindown_delay_adj.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
let closure = clone!(@strong f => move |_: &Adjustment| {
|
||||
f();
|
||||
});
|
||||
let closure = clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_: &Adjustment| {
|
||||
f();
|
||||
}
|
||||
);
|
||||
|
||||
for point in &*self.points.borrow() {
|
||||
point.ratio.connect_value_changed(closure.clone());
|
||||
@ -288,16 +310,20 @@ fn oc_adjustment_row(
|
||||
.child(&value_label)
|
||||
.build();
|
||||
|
||||
adjustment.connect_value_changed(clone!(@strong value_label => move |adjustment| {
|
||||
let value = match opts.digits {
|
||||
0 => adjustment.value().round(),
|
||||
_ => {
|
||||
let rounding = opts.digits as f64 * 10.0;
|
||||
(adjustment.value() * rounding).round() / rounding
|
||||
}
|
||||
};
|
||||
value_label.set_text(&format!("{value}{unit}"));
|
||||
}));
|
||||
adjustment.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
value_label,
|
||||
move |adjustment| {
|
||||
let value = match opts.digits {
|
||||
0 => adjustment.value().round(),
|
||||
_ => {
|
||||
let rounding = opts.digits as f64 * 10.0;
|
||||
(adjustment.value() * rounding).round() / rounding
|
||||
}
|
||||
};
|
||||
value_label.set_text(&format!("{value}{unit}"));
|
||||
}
|
||||
));
|
||||
|
||||
grid.attach(&label, 0, row, 1, 1);
|
||||
grid.attach(&scale, 1, row, 4, 1);
|
||||
|
@ -74,18 +74,26 @@ impl PointAdjustment {
|
||||
let text = format!("<b>{}%</b> at {temperature}°C", (ratio * 100.0).round());
|
||||
let temperature_label = Label::builder().label(text).use_markup(true).build();
|
||||
|
||||
temperature_adjustment.connect_value_changed(
|
||||
clone!(@strong temperature_label, @strong ratio_adjustment => move |temperature_adjustment| {
|
||||
temperature_adjustment.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
temperature_label,
|
||||
#[strong]
|
||||
ratio_adjustment,
|
||||
move |temperature_adjustment| {
|
||||
let temperature = temperature_adjustment.value();
|
||||
let ratio = (ratio_adjustment.value() * 100.0).round();
|
||||
let text = format!("<b>{ratio}%</b> at {temperature}°C");
|
||||
temperature_label.set_markup(&text);
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
ratio_adjustment.connect_value_changed(clone!(@strong temperature_adjustment => move |_| {
|
||||
temperature_adjustment.emit_by_name::<()>("value-changed", &[]);
|
||||
}));
|
||||
ratio_adjustment.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
temperature_adjustment,
|
||||
move |_| {
|
||||
temperature_adjustment.emit_by_name::<()>("value-changed", &[]);
|
||||
}
|
||||
));
|
||||
|
||||
let popover = Popover::builder().child(&popover_menu).build();
|
||||
let temperature_button = MenuButton::builder()
|
||||
|
@ -216,14 +216,22 @@ impl ThermalsPage {
|
||||
|
||||
pub fn connect_settings_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
self.fan_control_mode_stack
|
||||
.connect_visible_child_name_notify(clone!(@strong f => move |_| {
|
||||
f();
|
||||
}));
|
||||
.connect_visible_child_name_notify(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}
|
||||
));
|
||||
|
||||
self.fan_static_speed_adjustment
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
f();
|
||||
}));
|
||||
.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}
|
||||
));
|
||||
|
||||
self.pmfw_frame.connect_settings_changed(f.clone());
|
||||
|
||||
@ -295,10 +303,14 @@ fn static_speed_adj(parent_box: &Box) -> Adjustment {
|
||||
.child(&value_label)
|
||||
.build();
|
||||
|
||||
adjustment.connect_value_changed(clone!(@strong value_label => move |adjustment| {
|
||||
let value = adjustment.value();
|
||||
value_label.set_text(&format!("{value:.1}"));
|
||||
}));
|
||||
adjustment.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
value_label,
|
||||
move |adjustment| {
|
||||
let value = adjustment.value();
|
||||
value_label.set_text(&format!("{value:.1}"));
|
||||
}
|
||||
));
|
||||
|
||||
adjustment.set_value(50.0);
|
||||
|
||||
|
@ -65,22 +65,34 @@ impl PmfwFrame {
|
||||
}
|
||||
|
||||
pub fn connect_settings_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
self.acoustic_limit
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
self.acoustic_limit.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}));
|
||||
self.acoustic_target
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
}
|
||||
));
|
||||
self.acoustic_target.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}));
|
||||
self.minimum_pwm
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
}
|
||||
));
|
||||
self.minimum_pwm.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}));
|
||||
self.target_temperature
|
||||
.connect_value_changed(clone!(@strong f => move |_| {
|
||||
}
|
||||
));
|
||||
self.target_temperature.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
f,
|
||||
move |_| {
|
||||
f();
|
||||
}));
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
pub fn connect_reset<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
@ -153,8 +165,16 @@ fn adjustment(parent_grid: &Grid, label: &str, row: i32) -> OcAdjustment {
|
||||
.child(&value_label)
|
||||
.build();
|
||||
|
||||
adjustment.connect_value_changed(
|
||||
clone!(@strong value_label, @strong label, @strong scale, @strong value_button => move |adjustment| {
|
||||
adjustment.connect_value_changed(clone!(
|
||||
#[strong]
|
||||
value_label,
|
||||
#[strong]
|
||||
label,
|
||||
#[strong]
|
||||
scale,
|
||||
#[strong]
|
||||
value_button,
|
||||
move |adjustment| {
|
||||
let value = adjustment.value();
|
||||
value_label.set_text(&format!("{}", value as u32));
|
||||
|
||||
@ -169,8 +189,8 @@ fn adjustment(parent_grid: &Grid, label: &str, row: i32) -> OcAdjustment {
|
||||
scale.show();
|
||||
value_button.show();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
));
|
||||
|
||||
parent_grid.attach(&label, 0, row, 1, 1);
|
||||
parent_grid.attach(&scale, 1, row, 4, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user