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:
+1
-12
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user