Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian committed Sep 5, 2023
1 parent c15c5f6 commit 9c404d0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Library/demos/Spin Button/code.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::workbench;
use glib::clone;
use glib::signal::Propagation;
use gtk::glib;
use gtk::prelude::*;
use gtk::SpinType;
Expand All @@ -10,7 +11,6 @@ pub fn main() {
hours.set_text("00");
minutes.set_text("00");


hours.connect_value_changed(clone!(@weak minutes => move |hours| {
tell_time(&hours.text(), &minutes.text());
}));
Expand All @@ -19,18 +19,18 @@ pub fn main() {
let value = hours.value();
let text = format!("{:02}", value);
hours.set_text(&text);
return true.into();
Propagation::Stop
});

minutes.connect_output(move |minutes| {
let value = minutes.value();
let text = format!("{:02}", value);
minutes.set_text(&text);
return true.into();
Propagation::Stop
});

minutes.connect_wrapped(clone!(@weak hours => move |_| {
hours.spin(SpinType::StepForward, 1.0);
hours.spin(SpinType::StepForward, 1.0);
}));

minutes.connect_value_changed(move |minutes| {
Expand All @@ -39,5 +39,5 @@ pub fn main() {
}

fn tell_time(hours: &str, minutes: &str) {
println!("The time selected is {hours}:{minutes}");
println!("The time selected is {hours}:{minutes}");
}

0 comments on commit 9c404d0

Please sign in to comment.