From f4f2989e85bc5cfe9c7540d2abd7fa2c951544c4 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sat, 21 May 2022 12:02:45 +0200 Subject: [PATCH] Added tooltip-format --- include/modules/gamemode.hpp | 2 ++ src/modules/gamemode.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/modules/gamemode.hpp b/include/modules/gamemode.hpp index b7caf63..b027393 100644 --- a/include/modules/gamemode.hpp +++ b/include/modules/gamemode.hpp @@ -25,6 +25,7 @@ class Gamemode : public AModule { const std::string DEFAULT_ICON_NAME = "input-gaming-symbolic"; const std::string DEFAULT_FORMAT = "{glyph}"; const std::string DEFAULT_FORMAT_ALT = "{glyph} {count}"; + const std::string DEFAULT_TOOLTIP_FORMAT = "Games running: {count}"; const std::string DEFAULT_GLYPH = ""; void appear(const Glib::RefPtr &connection, const Glib::ustring &name, @@ -43,6 +44,7 @@ class Gamemode : public AModule { // Config std::string format = DEFAULT_FORMAT; std::string format_alt = DEFAULT_FORMAT_ALT; + std::string tooltip_format = DEFAULT_TOOLTIP_FORMAT; std::string glyph = DEFAULT_GLYPH; bool tooltip = true; bool hideNotRunning = true; diff --git a/src/modules/gamemode.cpp b/src/modules/gamemode.cpp index 12d54ab..c7accd5 100644 --- a/src/modules/gamemode.cpp +++ b/src/modules/gamemode.cpp @@ -34,6 +34,11 @@ Gamemode::Gamemode(const std::string& id, const Json::Value& config) } box_.set_has_tooltip(tooltip); + // Tooltip Format + if (config_["tooltip-format"].isString()) { + tooltip_format = config_["tooltip-format"].asString(); + } + // Hide when game count is 0 if (config_["hide-not-running"].isBool()) { hideNotRunning = config_["hide-not-running"].asBool(); @@ -208,9 +213,8 @@ auto Gamemode::update() -> void { // Tooltip if (tooltip) { - std::string text = "Games running: "; - box_.set_tooltip_text(text + std::to_string(gameCount)); - box_.set_has_tooltip(gameCount > 0); + std::string text = fmt::format(tooltip_format, fmt::arg("count", gameCount)); + box_.set_tooltip_text(text); } // Label format