File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #! / usr/ bin/ env - S vala workbench. vala -- pkg libadwaita- 1
2+
3+ private Gtk . SpinButton hours;
4+ private Gtk . SpinButton minutes;
5+
6+ string tell_time () {
7+ return (@" The time selected is $(hours.text):$(minutes.text)" );
8+ }
9+
10+ public void main () {
11+ hours = (Gtk . SpinButton ) workbench. builder. get_object (" hours" );
12+ minutes = (Gtk . SpinButton ) workbench. builder. get_object (" minutes" );
13+
14+ hours. text = " 00" ;
15+ minutes. text = " 00" ;
16+
17+ hours. value_changed. connect (() = > {
18+ message (@" $(tell_time ())" );
19+ });
20+
21+ minutes. value_changed. connect (() = > {
22+ message (@" $(tell_time ())" );
23+ });
24+
25+
26+ hours. output. connect (() = > {
27+ var value = (int ) hours. adjustment. value ;
28+ hours. text = " %02d " . printf (value );
29+ return true ;
30+ });
31+
32+ minutes. output. connect (() = > {
33+ var value = (int ) minutes. adjustment. value ;
34+ minutes. text = " %02d " . printf (value );
35+ return true ;
36+ });
37+
38+ // This only works for one direction
39+ // Add any extra logic to account for wrapping in both directions
40+ minutes. wrapped. connect (() = > {
41+ hours. spin (STEP_FORWARD , 1 );
42+ });
43+ }
You can’t perform that action at this time.
0 commit comments