From 32201a3d505b6b78da7ba15c2bb77093d52ec735 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 20 Oct 2026 19:21:24 +0200 Subject: Notifications: icon per outcome, body says how the job went Title is the job (kind and args), body the outcome: succeeded in, failed with exit code N after, killed after, lost. Icons are freedesktop names: emblem-default, dialog-error, process-stop, dialog-warning, computer. Co-Authored-By: Claude Opus 5.5 --- sb_builder/mainwindow.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'sb_builder/mainwindow.py') diff --git a/sb_builder/mainwindow.py b/sb_builder/mainwindow.py index f63a4ba..ec2b87a 100644 --- a/sb_builder/mainwindow.py +++ b/sb_builder/mainwindow.py @@ -27,7 +27,7 @@ from PyQt6.QtWidgets import (QHeaderView, QLabel, QMainWindow, QMessageBox, QPus from . import VERSION, config from .dashboard import Dashboard -from .fmt import job_title +from .fmt import job_title, outcome from .hints_tab import HINT_JOBS, HintResultDialog, HintsTab from .jobs import JobsTab, NextStep, is_preview from .packages import PackagesTab @@ -51,6 +51,9 @@ QTabBar::tab:selected { background: palette(highlight); color: palette(highlight QTabBar::tab:hover:!selected { background: palette(midlight); } """ END_EVENT = {"ok": "finished", "failed": "failed", "killed": "killed", "lost": "lost"} +# freedesktop icon names per notification event +NOTIFY_ICON = {"finished": "emblem-default", "failed": "dialog-error", "killed": "process-stop", + "lost": "dialog-warning", "vm-up": "computer"} MAX_RETRY_MS = 30000 @@ -66,9 +69,9 @@ class Notifier(QObject): bus.connect(NOTIFY, NOTIFY_PATH, NOTIFY, "ActionInvoked", self._action) self.ids = {} # notification id -> job id - def send(self, title, body, jid=""): + def send(self, title, body, icon="", jid=""): reply = self.iface.call( - "Notify", "sb-builder", QDBusArgument(0, QMetaType.Type.UInt.value), "", title, body, + "Notify", "sb-builder", QDBusArgument(0, QMetaType.Type.UInt.value), icon, title, body, QDBusArgument(["default", "Open"], QMetaType.Type.QStringList.value), {}, -1) if reply.type() == QDBusMessage.MessageType.ReplyMessage: self.ids[reply.arguments()[0]] = jid @@ -231,7 +234,7 @@ class MainWindow(QMainWindow): self.poll_slow() if self.vm_woken: self.vm_woken = False - self.notify("vm-up", f"{self.cfg['vm']['domain']} is up") + self.notify("vm-up", "VM up", f"{self.cfg['vm']['domain']} answers over ssh") def _failed(self, err): if err == MISSING: @@ -290,10 +293,10 @@ class MainWindow(QMainWindow): # ── notifications ─────────────────────────────────────────────────────── - def notify(self, event, body, jid=""): + def notify(self, event, title, body, jid=""): n = self.cfg["notify"] if n["enabled"] and event in n["events"]: - self.notifier.send(f"sb-builder: {event}", body, jid) + self.notifier.send(title, body, NOTIFY_ICON[event], jid) def _notify_ends(self, jobs): prev, self.seen = self.seen, {j["id"]: j["status"] for j in jobs} @@ -302,7 +305,7 @@ class MainWindow(QMainWindow): for j in jobs: event = END_EVENT.get(j["status"]) if event and prev.get(j["id"], "running") != j["status"]: - self.notify(event, job_title(j), j["id"]) + self.notify(event, job_title(j), outcome(j), j["id"]) if self.tabs.currentWidget() is not self.jobs_tab: self._badge("ok" if j["status"] == "ok" else "bad") if j["kind"] in ("slackrepo", "publish"): # build state changed -- cgit v1.2.3