make getLayout is not static and set css classes for short name keyboard layout in getLayout method

This commit is contained in:
dimti
2025-10-10 11:35:47 +03:00
parent cd820a100d
commit bdf501a8a5
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -82,9 +82,7 @@ void Language::onEvent(const std::string& ev) {
layoutName = waybar::util::sanitize_string(layoutName);
label_.get_style_context()->remove_class(layout_.short_name);
layout_ = getLayout(layoutName);
label_.get_style_context()->add_class(layout_.short_name);
spdlog::debug("hyprland language onevent with {}", layoutName);
@@ -105,9 +103,7 @@ void Language::initLanguage() {
searcher = waybar::util::sanitize_string(searcher);
label_.get_style_context()->remove_class(layout_.short_name);
layout_ = getLayout(searcher);
label_.get_style_context()->add_class(layout_.short_name);
spdlog::debug("hyprland language initLanguage found {}", layout_.full_name);
@@ -122,6 +118,8 @@ auto Language::getLayout(const std::string& fullName) -> Layout {
rxkb_context_parse_default_ruleset(context);
rxkb_layout* layout = rxkb_layout_first(context);
label_.get_style_context()->remove_class(layout_.short_name);
spdlog::debug("hyprland language try to remove currently short_name css class {}", layout_.short_name);
while (layout != nullptr) {
std::string nameOfLayout = rxkb_layout_get_description(layout);
@@ -141,6 +139,8 @@ auto Language::getLayout(const std::string& fullName) -> Layout {
rxkb_context_unref(context);
label_.get_style_context()->add_class(info.short_name);
spdlog::debug("hyprland language add new short_name css class {}", info.short_name);
return info;
}