Merge pull request #3833 from Bahnschrift/master
This commit is contained in:
@ -21,6 +21,7 @@ class Tray : public AModule {
|
|||||||
void onRemove(std::unique_ptr<Item>& item);
|
void onRemove(std::unique_ptr<Item>& item);
|
||||||
|
|
||||||
static inline std::size_t nb_hosts_ = 0;
|
static inline std::size_t nb_hosts_ = 0;
|
||||||
|
bool show_passive_ = false;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
SNI::Watcher::singleton watcher_;
|
SNI::Watcher::singleton watcher_;
|
||||||
SNI::Host host_;
|
SNI::Host host_;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include "modules/sni/icon_manager.hpp"
|
#include "modules/sni/icon_manager.hpp"
|
||||||
|
|
||||||
namespace waybar::modules::SNI {
|
namespace waybar::modules::SNI {
|
||||||
@ -21,6 +22,9 @@ Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
|
|||||||
if (config_["spacing"].isUInt()) {
|
if (config_["spacing"].isUInt()) {
|
||||||
box_.set_spacing(config_["spacing"].asUInt());
|
box_.set_spacing(config_["spacing"].asUInt());
|
||||||
}
|
}
|
||||||
|
if (config["show-passive-items"].isBool()) {
|
||||||
|
show_passive_ = config["show-passive-items"].asBool();
|
||||||
|
}
|
||||||
nb_hosts_ += 1;
|
nb_hosts_ += 1;
|
||||||
if (config_["icons"].isObject()) {
|
if (config_["icons"].isObject()) {
|
||||||
IconManager::instance().setIconsConfig(config_["icons"]);
|
IconManager::instance().setIconsConfig(config_["icons"]);
|
||||||
@ -44,7 +48,15 @@ void Tray::onRemove(std::unique_ptr<Item>& item) {
|
|||||||
|
|
||||||
auto Tray::update() -> void {
|
auto Tray::update() -> void {
|
||||||
// Show tray only when items are available
|
// Show tray only when items are available
|
||||||
event_box_.set_visible(!box_.get_children().empty());
|
std::vector<Gtk::Widget*> children = box_.get_children();
|
||||||
|
if (show_passive_) {
|
||||||
|
event_box_.set_visible(!children.empty());
|
||||||
|
} else {
|
||||||
|
event_box_.set_visible(!std::all_of(children.begin(), children.end(), [](Gtk::Widget* child) {
|
||||||
|
return child->get_style_context()->has_class("passive");
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Call parent update
|
// Call parent update
|
||||||
AModule::update();
|
AModule::update();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user