modules: systemd_failed_units: Introduce RequestFailedUnits member

Split-out request of failed units from systemd into a separate member
function.

This increases the readability and extendability, but preserves the
current functionality (non-functional change).

Signed-off-by: Steffen Kothe <steffen.kothe@skothe.net>
This commit is contained in:
Steffen Kothe
2025-06-21 15:34:44 +00:00
parent 4bb06b86bc
commit 0731117679
2 changed files with 7 additions and 3 deletions

View File

@ -25,6 +25,7 @@ class SystemdFailedUnits : public ALabel {
void notify_cb(const Glib::ustring &sender_name, const Glib::ustring &signal_name,
const Glib::VariantContainerBase &arguments);
void RequestFailedUnits();
void updateData();
};

View File

@ -68,9 +68,7 @@ auto SystemdFailedUnits::notify_cb(const Glib::ustring& sender_name,
}
}
void SystemdFailedUnits::updateData() {
update_pending = false;
void SystemdFailedUnits::RequestFailedUnits() {
auto load = [](const char* kind, Glib::RefPtr<Gio::DBus::Proxy>& proxy) -> uint32_t {
try {
if (!proxy) return 0;
@ -93,6 +91,11 @@ void SystemdFailedUnits::updateData() {
nr_failed_system = load("systemwide", system_proxy);
nr_failed_user = load("user", user_proxy);
nr_failed = nr_failed_system + nr_failed_user;
}
void SystemdFailedUnits::updateData() {
update_pending = false;
RequestFailedUnits();
dp.emit();
}