refactor(modules): use ALabel dedup tooltip helper in simpleclock, systemd-failed-units, upower

simpleclock: migrate to updateLabelAndTooltip (label + tooltip share the
localtime arg; default tooltip falls back to the label format).
systemd-failed-units: use setLabelMarkup/setTooltipMarkup dedup setters;
label/tooltip formats are selected by different conditions so the combined
helper does not apply.
upower: use setLabelMarkup for the label; tooltip stays a custom GTK widget.
mpd already uses the dedup setters (label/tooltip use different truncated
args), so no change.
This commit is contained in:
Alex
2026-07-04 00:00:17 +02:00
parent a91dcbe595
commit 836449d253
3 changed files with 5 additions and 16 deletions
+1 -12
View File
@@ -18,18 +18,7 @@ auto waybar::modules::Clock::update() -> void {
tzset(); // Update timezone information
auto now = std::chrono::system_clock::now();
auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now));
auto text = fmt::format(fmt::runtime(format_), localtime);
label_.set_markup(text);
if (tooltipEnabled()) {
if (config_["tooltip-format"].isString()) {
auto tooltip_format = config_["tooltip-format"].asString();
auto tooltip_text = fmt::format(fmt::runtime(tooltip_format), localtime);
label_.set_tooltip_markup(tooltip_text);
} else {
label_.set_tooltip_markup(text);
}
}
updateLabelAndTooltip(format_, format_, localtime);
// Call parent update
ALabel::update();
}