Merge pull request #4624 from andresilva/tray-hide-icons
Support hiding tray icons
This commit is contained in:
@@ -172,15 +172,23 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
|
||||
* I still haven't found a way for it to pick from theme automatically, although
|
||||
* it might be my theme.
|
||||
*/
|
||||
std::string icon_id = id;
|
||||
if (id == "chrome_status_icon_1") {
|
||||
Glib::VariantBase value;
|
||||
this->proxy_->get_cached_property(value, "ToolTip");
|
||||
tooltip = get_variant<ToolTip>(value);
|
||||
if (!tooltip.text.empty()) {
|
||||
setCustomIcon(tooltip.text.lowercase());
|
||||
icon_id = tooltip.text.lowercase();
|
||||
setCustomIcon(icon_id);
|
||||
}
|
||||
} else {
|
||||
setCustomIcon(id);
|
||||
setCustomIcon(icon_id);
|
||||
}
|
||||
|
||||
// Check if this item should be hidden
|
||||
if (IconManager::instance().isHidden(icon_id)) {
|
||||
spdlog::debug("Hiding tray item with ID: {}", icon_id);
|
||||
is_hidden_ = true;
|
||||
}
|
||||
} else if (name == "Title") {
|
||||
title = get_variant<std::string>(value);
|
||||
@@ -238,7 +246,7 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
|
||||
|
||||
void Item::setStatus(const Glib::ustring& value) {
|
||||
status_ = value.lowercase();
|
||||
event_box.set_visible(show_passive_ || status_.compare("passive") != 0);
|
||||
event_box.set_visible(!is_hidden_ && (show_passive_ || status_.compare("passive") != 0));
|
||||
|
||||
auto style = event_box.get_style_context();
|
||||
for (const auto& class_name : style->list_classes()) {
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
static void initIconsConfig(const Json::Value& config) {
|
||||
if (config["icons"].isObject()) {
|
||||
IconManager::instance().setIconsConfig(config["icons"]);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Tray::parseIgnoreList(const Json::Value& config) {
|
||||
std::vector<std::string> ignore_list;
|
||||
if (config["ignore-list"].isArray()) {
|
||||
@@ -29,7 +35,7 @@ Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
box_(bar.orientation, 0),
|
||||
watcher_(SNI::Watcher::getInstance()),
|
||||
ignore_list_(parseIgnoreList(config)),
|
||||
host_(nb_hosts_, config, bar, ignore_list_,
|
||||
host_((initIconsConfig(config), nb_hosts_), config, bar, ignore_list_,
|
||||
std::bind(&Tray::onAdd, this, std::placeholders::_1),
|
||||
std::bind(&Tray::onRemove, this, std::placeholders::_1),
|
||||
std::bind(&Tray::queueUpdate, this)) {
|
||||
@@ -43,9 +49,6 @@ Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
box_.set_spacing(config_["spacing"].asUInt());
|
||||
}
|
||||
nb_hosts_ += 1;
|
||||
if (config_["icons"].isObject()) {
|
||||
IconManager::instance().setIconsConfig(config_["icons"]);
|
||||
}
|
||||
dp.emit();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user