refactor: AppWindow

This commit is contained in:
Daniel Langbein 2025-02-23 21:26:27 +01:00
parent a9ec068031
commit 32cbac3ad6
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002

View File

@ -25,7 +25,7 @@ class Application(Adw.Application):
self.window = AppWindow(application=self)
self.window.present()
def notify_timer(self) -> None:
def send_notification_timeout(self) -> None:
notification = Gio.Notification()
notification.set_title('Timeout')
notification.set_body('The time is over and your do-not-disturb mode just got busted!')
@ -59,7 +59,7 @@ class AppWindow(Gtk.ApplicationWindow):
self.progress_bar = Gtk.ProgressBar(visible=False)
self.box.append(self.progress_bar)
self.timer = None
self.timer = Timer()
def update_progress(self) -> bool:
total_min = 25
@ -69,7 +69,7 @@ class AppWindow(Gtk.ApplicationWindow):
self.progress_bar.set_fraction(progress)
if progress >= 1:
self.app.notify_timer()
self.app.send_notification_timeout()
# Stop regularly calling update_progress()
return False
@ -77,18 +77,18 @@ class AppWindow(Gtk.ApplicationWindow):
return not self.timer.is_paused()
def on_button_start_restart_clicked(self, _widget) -> None:
if self.timer is None:
self.add_timer()
if not self.timer.is_started():
self.reset_start_timer()
self.button_start_restart.set_label("Restart")
self.button_pause_resume.set_visible(True)
else:
self.add_timer()
self.reset_start_timer()
self.update_label()
def add_timer(self) -> None:
self.timer = Timer()
def reset_start_timer(self) -> None:
self.timer.reset()
self.timer.start()
self.progress_bar.set_visible(True)
self.add_timeout()