Improve background check handling, and hide services until connection is proved.
This commit is contained in:
@@ -15,7 +15,9 @@ class LauncherApp(Gtk.Application):
|
||||
super().__init__(application_id="com.local.Launcher")
|
||||
|
||||
self.config = load_launcher_config()
|
||||
|
||||
check_cfg = self.config.get("checks", {})
|
||||
|
||||
self.checks = SystemChecks(
|
||||
network_targets=check_cfg.get("network_targets"),
|
||||
ziti_target=check_cfg.get("ziti_target"),
|
||||
@@ -23,35 +25,24 @@ class LauncherApp(Gtk.Application):
|
||||
self.dispatcher = ActionDispatcher()
|
||||
|
||||
self.ui = UIController(
|
||||
status_provider_callback=lambda: {
|
||||
"net": self.checks.check_network_status(),
|
||||
"ziti": self.checks.check_ziti_status(),
|
||||
},
|
||||
system_checks=self.checks,
|
||||
power_action_callback=self.dispatcher.dispatch,
|
||||
service_action_callback=self.dispatcher.dispatch,
|
||||
services=self.config.get("services", []),
|
||||
)
|
||||
|
||||
def do_activate(self):
|
||||
self.checks.start()
|
||||
|
||||
self.ui.set_app_title(self.config.get("app_title", "Launcher"))
|
||||
|
||||
for service in self.config.get("services", []):
|
||||
title = service.get("title", "Service")
|
||||
desc = service.get("desc", "")
|
||||
bg_img = service.get("bg_image", "")
|
||||
|
||||
self.ui.add_card(
|
||||
title,
|
||||
desc,
|
||||
bg_img,
|
||||
lambda svc=service: self.dispatcher.dispatch(
|
||||
svc.get("type", "command"),
|
||||
svc,
|
||||
),
|
||||
)
|
||||
|
||||
self.ui.setup_exit_shortcut(self.quit)
|
||||
|
||||
self.ui.present(self)
|
||||
|
||||
def do_shutdown(self):
|
||||
self.checks.stop()
|
||||
Gtk.Application.do_shutdown(self)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = LauncherApp()
|
||||
|
||||
Reference in New Issue
Block a user