refactor(AModule): hoist format/tooltip resolution to the base module

Move resolveTooltipFormat() (and add resolveFormat()) from ALabel down into
AModule, and add a generic updateTooltip(Gtk::Widget&, ...) helper. This lets
modules that are not ALabel-derived reuse the shared tooltip logic instead of
re-implementing it. Migrate gamemode (the only non-ALabel module reading
tooltip-format) to updateTooltip(box_, ...). ALabel inherits the resolvers.
This commit is contained in:
Alex
2026-07-04 00:17:14 +02:00
parent f059337beb
commit 003d531701
3 changed files with 41 additions and 16 deletions
+1 -12
View File
@@ -34,18 +34,7 @@ class ALabel : public AModule {
bool setLabelMarkup(const Glib::ustring& markup);
bool setTooltipMarkup(const Glib::ustring& markup);
// Resolve the tooltip format string: prefers `tooltip-format-<state>` (when a
// non-empty state is given), then `tooltip-format`, then `defaultFormat`.
std::string resolveTooltipFormat(const std::string& defaultFormat,
const std::string& state = "") const {
if (!state.empty() && config_["tooltip-format-" + state].isString()) {
return config_["tooltip-format-" + state].asString();
}
if (config_["tooltip-format"].isString()) {
return config_["tooltip-format"].asString();
}
return defaultFormat;
}
// resolveTooltipFormat() / resolveFormat() are inherited from AModule.
// Combined label + tooltip helper. Builds a single fmt argument store from
// `args`, renders `labelFormat` into the label and the resolved tooltip format