11namespace ExerciseTimer {
22 [GtkTemplate (ui = "/xyz /safeworlds /hiit /ui /timer_page .ui ")]
33 public class TimerPage : Adw.NavigationPage, ITimerNotifier {
4- public TimerPage (TrainingSetup setup) {
4+ public TimerPage (TrainingSetup setup, ITimerPageActionNotifier action_notifier ) {
55 Setup = setup;
6+ this . action_notifier = action_notifier;
67 updateCssClass();
78 timer_label_box. set_direction(Gtk . TextDirection . LTR );
89 volume_button. get_first_child(). css_classes = new string [] { " circular" , " toggle" , " large-button" };
910
1011 var settings = new GLib .Settings (Config . AppId );
1112 settings. bind(" beep-volume" , volume_adjustment, " value" , GLib . SettingsBindFlags . DEFAULT );
13+ settings. bind(" countdown-sec" , this , " CountdownSec" , GLib . SettingsBindFlags . DEFAULT );
1214
1315 this . shown. connect(() = > {
1416 restart();
1517 });
1618 this . hidden. connect((_) = > {
1719 Running = false ;
20+ this . action_notifier. restart_action_called. disconnect(restart);
1821 });
22+ this . action_notifier. restart_action_called. connect(restart);
1923 }
2024
2125 public TrainingSetup Setup { get ; private set ; }
@@ -108,6 +112,8 @@ namespace ExerciseTimer {
108112 }
109113 }
110114
115+ public int CountdownSec { get ; set ; }
116+
111117 [GtkCallback ]
112118 public void restart() {
113119 remaining_sets = Setup . Sets ;
@@ -136,7 +142,7 @@ namespace ExerciseTimer {
136142 if (remaining_sec > 1 ) {
137143 -- remaining_sec;
138144 retval = true ;
139- if (remaining_sec <= countdown_threshold ) {
145+ if (remaining_sec <= CountdownSec ) {
140146 countdown(remaining_sec);
141147 }
142148 } else {
@@ -229,6 +235,6 @@ namespace ExerciseTimer {
229235 private int remaining_sets;
230236 private uint ? timer_id;
231237 private bool running;
232- private const int countdown_threshold = 5 ;
238+ ITimerPageActionNotifier action_notifier ;
233239 }
234240}
0 commit comments