Ignore Tray entries by service name and when dbus properties load
This commit is contained in:
@@ -8,11 +8,29 @@
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
std::vector<std::string> Tray::parseIgnoreList(const Json::Value& config) {
|
||||
std::vector<std::string> ignore_list;
|
||||
if (config["ignore-list"].isArray()) {
|
||||
spdlog::info("Tray: Found ignore-list with {} items", config["ignore-list"].size());
|
||||
for (const auto& item : config["ignore-list"]) {
|
||||
if (item.isString()) {
|
||||
ignore_list.push_back(item.asString());
|
||||
spdlog::info("Tray: Adding to ignore list: {}", item.asString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
spdlog::info("Tray: No ignore-list configured");
|
||||
}
|
||||
return ignore_list;
|
||||
}
|
||||
|
||||
Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: AModule(config, "tray", id),
|
||||
box_(bar.orientation, 0),
|
||||
watcher_(SNI::Watcher::getInstance()),
|
||||
host_(nb_hosts_, config, bar, std::bind(&Tray::onAdd, this, std::placeholders::_1),
|
||||
ignore_list_(parseIgnoreList(config)),
|
||||
host_(nb_hosts_, config, bar, ignore_list_,
|
||||
std::bind(&Tray::onAdd, this, std::placeholders::_1),
|
||||
std::bind(&Tray::onRemove, this, std::placeholders::_1)) {
|
||||
box_.set_name("tray");
|
||||
event_box_.add(box_);
|
||||
@@ -33,12 +51,24 @@ Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
dp.emit();
|
||||
}
|
||||
|
||||
void Tray::checkIgnoreList(std::unique_ptr<Item>* item_ptr) {
|
||||
// Delegate to Host's checkIgnoreList method
|
||||
host_.checkIgnoreList(ignore_list_, std::bind(&Tray::onRemove, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void Tray::onAdd(std::unique_ptr<Item>& item) {
|
||||
spdlog::info("Tray::onAdd - item bus_name='{}', category='{}', icon_name='{}', title='{}'",
|
||||
item->bus_name, item->category, item->icon_name, item->title);
|
||||
|
||||
if (config_["reverse-direction"].isBool() && config_["reverse-direction"].asBool()) {
|
||||
box_.pack_end(item->event_box);
|
||||
} else {
|
||||
box_.pack_start(item->event_box);
|
||||
}
|
||||
|
||||
spdlog::debug("Tray::onAdd deferred check - checking ignore list");
|
||||
host_.checkIgnoreList(ignore_list_, std::bind(&Tray::onRemove, this, std::placeholders::_1));
|
||||
|
||||
dp.emit();
|
||||
}
|
||||
|
||||
@@ -48,6 +78,12 @@ void Tray::onRemove(std::unique_ptr<Item>& item) {
|
||||
}
|
||||
|
||||
auto Tray::update() -> void {
|
||||
// Check if any items should be ignored now that properties have loaded
|
||||
if (!ignore_list_.empty()) {
|
||||
spdlog::debug("Tray::update() - checking ignore list");
|
||||
host_.checkIgnoreList(ignore_list_, std::bind(&Tray::onRemove, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
// Show tray only when items are available
|
||||
std::vector<Gtk::Widget*> children = box_.get_children();
|
||||
if (show_passive_) {
|
||||
|
||||
Reference in New Issue
Block a user