Added tooltip-format

This commit is contained in:
Erik Reider 2022-05-21 12:02:45 +02:00
parent 8d4c7176f8
commit f4f2989e85
2 changed files with 9 additions and 3 deletions

View File

@ -25,6 +25,7 @@ class Gamemode : public AModule {
const std::string DEFAULT_ICON_NAME = "input-gaming-symbolic"; const std::string DEFAULT_ICON_NAME = "input-gaming-symbolic";
const std::string DEFAULT_FORMAT = "{glyph}"; const std::string DEFAULT_FORMAT = "{glyph}";
const std::string DEFAULT_FORMAT_ALT = "{glyph} {count}"; const std::string DEFAULT_FORMAT_ALT = "{glyph} {count}";
const std::string DEFAULT_TOOLTIP_FORMAT = "Games running: {count}";
const std::string DEFAULT_GLYPH = ""; const std::string DEFAULT_GLYPH = "";
void appear(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name, void appear(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name,
@ -43,6 +44,7 @@ class Gamemode : public AModule {
// Config // Config
std::string format = DEFAULT_FORMAT; std::string format = DEFAULT_FORMAT;
std::string format_alt = DEFAULT_FORMAT_ALT; std::string format_alt = DEFAULT_FORMAT_ALT;
std::string tooltip_format = DEFAULT_TOOLTIP_FORMAT;
std::string glyph = DEFAULT_GLYPH; std::string glyph = DEFAULT_GLYPH;
bool tooltip = true; bool tooltip = true;
bool hideNotRunning = true; bool hideNotRunning = true;

View File

@ -34,6 +34,11 @@ Gamemode::Gamemode(const std::string& id, const Json::Value& config)
} }
box_.set_has_tooltip(tooltip); box_.set_has_tooltip(tooltip);
// Tooltip Format
if (config_["tooltip-format"].isString()) {
tooltip_format = config_["tooltip-format"].asString();
}
// Hide when game count is 0 // Hide when game count is 0
if (config_["hide-not-running"].isBool()) { if (config_["hide-not-running"].isBool()) {
hideNotRunning = config_["hide-not-running"].asBool(); hideNotRunning = config_["hide-not-running"].asBool();
@ -208,9 +213,8 @@ auto Gamemode::update() -> void {
// Tooltip // Tooltip
if (tooltip) { if (tooltip) {
std::string text = "Games running: "; std::string text = fmt::format(tooltip_format, fmt::arg("count", gameCount));
box_.set_tooltip_text(text + std::to_string(gameCount)); box_.set_tooltip_text(text);
box_.set_has_tooltip(gameCount > 0);
} }
// Label format // Label format