Skip to content

Commit

Permalink
Fix a problem where sliders emit values that are outside their range
Browse files Browse the repository at this point in the history
  • Loading branch information
JosuGZ committed Aug 19, 2024
1 parent e1e364d commit 91def1d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions razer_control_gui/src/razer-settings/razer-settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ fn make_page(ac: bool) -> SettingsPage {
scale.set_sensitive(fan_speed != 0);
scale.set_width_request(100);
scale.connect_change_value(clone!(@weak switch => @default-return gtk::glib::Propagation::Stop, move |scale, stype, value| {
let value = value.clamp(3500f64, 5000f64);
set_fan_speed(ac, value as i32).or_crash("Error setting fan speed");
let fan_speed = get_fan_speed(ac).or_crash("Error reading fan speed");
let auto = fan_speed == 0;
Expand Down Expand Up @@ -615,7 +616,7 @@ fn make_general_page() -> SettingsPage {
scale.set_width_request(100);
scale.connect_change_value(clone!(@weak switch => @default-return gtk::glib::Propagation::Stop, move |scale, stype, value| {
let is_on = switch.is_active();
let threshold = value as u8;
let threshold = value.clamp(50f64, 80f64) as u8;

set_bho(is_on, threshold).or_crash("Error setting bho");

Expand All @@ -630,7 +631,7 @@ fn make_general_page() -> SettingsPage {
scale.set_sensitive(bho.0);
switch.connect_changed_active(clone!(@weak scale => move |switch| {
let is_on = switch.is_active();
let threshold = scale.value() as u8;
let threshold = scale.value().clamp(50f64, 80f64) as u8;

set_bho(is_on, threshold); // Ignoramos errores ya que leemos
// el resultado de vuelta
Expand Down

0 comments on commit 91def1d

Please sign in to comment.