app: Sent notifications via config subscriptions
This commit is contained in:
@@ -17,8 +17,5 @@ class GlobalState:
|
||||
def navigate_to_page(self, *args):
|
||||
self._uninitialized()
|
||||
|
||||
def send_notification(self, *args):
|
||||
self._uninitialized()
|
||||
|
||||
|
||||
global_state = GlobalState()
|
||||
|
||||
@@ -40,7 +40,8 @@ class Application(Adw.Application):
|
||||
GLib.OptionArg.NONE, "Run in testing mode. Does not alter the system, but runs scripts.", None)
|
||||
|
||||
config.set('version', version)
|
||||
global_state.send_notification = self._send_notification
|
||||
config.set('send_notification', None)
|
||||
config.subscribe('send_notification', self._send_notification)
|
||||
|
||||
def _setup_icons(self):
|
||||
icon_theme = Gtk.IconTheme.get_for_display(self.window.get_display())
|
||||
@@ -85,10 +86,11 @@ class Application(Adw.Application):
|
||||
self.window.close()
|
||||
return True
|
||||
|
||||
def _send_notification(self, title, text):
|
||||
def _send_notification(self, title):
|
||||
if not title:
|
||||
return
|
||||
n = Gio.Notification()
|
||||
n.set_title(title)
|
||||
n.set_body(text)
|
||||
self.send_notification(APP_ID, n)
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class InstallationScripting():
|
||||
config.set('installation_running', False)
|
||||
global_state.navigate_to_page("failed")
|
||||
# Translators: Notification text
|
||||
global_state.send_notification(_("Installation Failed"), '')
|
||||
config.set('send_notification', _("Finished Installation"))
|
||||
|
||||
def _try_start_next_script(self):
|
||||
if self.running_step != InstallationStep.none:
|
||||
@@ -92,7 +92,7 @@ class InstallationScripting():
|
||||
if self.finished_step is InstallationStep.configure:
|
||||
config.set('installation_running', False)
|
||||
# Translators: Notification text
|
||||
global_state.send_notification(_("Finished Installation"), '')
|
||||
config.set('send_notification', _("Finished Installation"))
|
||||
global_state.advance(None)
|
||||
else:
|
||||
self._try_start_next_script()
|
||||
|
||||
Reference in New Issue
Block a user