refactor: AppWindow
This commit is contained in:
parent
a9ec068031
commit
32cbac3ad6
@ -25,7 +25,7 @@ class Application(Adw.Application):
|
|||||||
self.window = AppWindow(application=self)
|
self.window = AppWindow(application=self)
|
||||||
self.window.present()
|
self.window.present()
|
||||||
|
|
||||||
def notify_timer(self) -> None:
|
def send_notification_timeout(self) -> None:
|
||||||
notification = Gio.Notification()
|
notification = Gio.Notification()
|
||||||
notification.set_title('Timeout')
|
notification.set_title('Timeout')
|
||||||
notification.set_body('The time is over and your do-not-disturb mode just got busted!')
|
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.progress_bar = Gtk.ProgressBar(visible=False)
|
||||||
self.box.append(self.progress_bar)
|
self.box.append(self.progress_bar)
|
||||||
|
|
||||||
self.timer = None
|
self.timer = Timer()
|
||||||
|
|
||||||
def update_progress(self) -> bool:
|
def update_progress(self) -> bool:
|
||||||
total_min = 25
|
total_min = 25
|
||||||
@ -69,7 +69,7 @@ class AppWindow(Gtk.ApplicationWindow):
|
|||||||
self.progress_bar.set_fraction(progress)
|
self.progress_bar.set_fraction(progress)
|
||||||
|
|
||||||
if progress >= 1:
|
if progress >= 1:
|
||||||
self.app.notify_timer()
|
self.app.send_notification_timeout()
|
||||||
# Stop regularly calling update_progress()
|
# Stop regularly calling update_progress()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -77,18 +77,18 @@ class AppWindow(Gtk.ApplicationWindow):
|
|||||||
return not self.timer.is_paused()
|
return not self.timer.is_paused()
|
||||||
|
|
||||||
def on_button_start_restart_clicked(self, _widget) -> None:
|
def on_button_start_restart_clicked(self, _widget) -> None:
|
||||||
if self.timer is None:
|
if not self.timer.is_started():
|
||||||
self.add_timer()
|
self.reset_start_timer()
|
||||||
|
|
||||||
self.button_start_restart.set_label("Restart")
|
self.button_start_restart.set_label("Restart")
|
||||||
self.button_pause_resume.set_visible(True)
|
self.button_pause_resume.set_visible(True)
|
||||||
else:
|
else:
|
||||||
self.add_timer()
|
self.reset_start_timer()
|
||||||
|
|
||||||
self.update_label()
|
self.update_label()
|
||||||
|
|
||||||
def add_timer(self) -> None:
|
def reset_start_timer(self) -> None:
|
||||||
self.timer = Timer()
|
self.timer.reset()
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
self.progress_bar.set_visible(True)
|
self.progress_bar.set_visible(True)
|
||||||
self.add_timeout()
|
self.add_timeout()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user