From 0472d279e4ecb1ffb5d44e763f7b6a19b3d5e079 Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Tue, 23 Nov 2021 14:15:55 +0200 Subject: [PATCH] Add {flag} format replacement --- include/modules/sway/language.hpp | 8 +++++++- src/modules/sway/language.cpp | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/modules/sway/language.hpp b/include/modules/sway/language.hpp index 1faf52b..1944166 100644 --- a/include/modules/sway/language.hpp +++ b/include/modules/sway/language.hpp @@ -32,6 +32,12 @@ class Language : public ALabel, public sigc::trackable { std::string short_name; std::string variant; std::string short_description; + std::string country_flag() const { + static std::string result = "\xf0\x9f\x87\xff\xf0\x9f\x87\xff"; + result[3] = short_name[0] - 0xbb; + result[7] = short_name[1] - 0xbb; + return result; + } }; class XKBContext { @@ -54,7 +60,7 @@ class Language : public ALabel, public sigc::trackable { const static std::string XKB_LAYOUT_NAMES_KEY; const static std::string XKB_ACTIVE_LAYOUT_NAME_KEY; - + Layout layout_; std::string tooltip_format_ = ""; std::map layouts_map_; diff --git a/src/modules/sway/language.cpp b/src/modules/sway/language.cpp index 186fa4b..bdd4b99 100644 --- a/src/modules/sway/language.cpp +++ b/src/modules/sway/language.cpp @@ -99,7 +99,8 @@ auto Language::update() -> void { fmt::arg("short", layout_.short_name), fmt::arg("shortDescription", layout_.short_description), fmt::arg("long", layout_.full_name), - fmt::arg("variant", layout_.variant))); + fmt::arg("variant", layout_.variant), + fmt::arg("flag", layout_.country_flag()))); label_.set_markup(display_layout); if (tooltipEnabled()) { if (tooltip_format_ != "") {