Only add tray widgets after the SNI proxy has finished initializing and the item has a valid id/category pair. This also removes invalid items through the host teardown path, refreshes the tray when item status changes, and avoids calling DBus methods through a null proxy during early clicks or scroll events. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
32 lines
679 B
C++
32 lines
679 B
C++
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include "AModule.hpp"
|
|
#include "bar.hpp"
|
|
#include "modules/sni/host.hpp"
|
|
#include "modules/sni/watcher.hpp"
|
|
#include "util/json.hpp"
|
|
|
|
namespace waybar::modules::SNI {
|
|
|
|
class Tray : public AModule {
|
|
public:
|
|
Tray(const std::string&, const Bar&, const Json::Value&);
|
|
virtual ~Tray() = default;
|
|
auto update() -> void override;
|
|
|
|
private:
|
|
void onAdd(std::unique_ptr<Item>& item);
|
|
void onRemove(std::unique_ptr<Item>& item);
|
|
void queueUpdate();
|
|
|
|
static inline std::size_t nb_hosts_ = 0;
|
|
bool show_passive_ = false;
|
|
Gtk::Box box_;
|
|
SNI::Watcher::singleton watcher_;
|
|
SNI::Host host_;
|
|
};
|
|
|
|
} // namespace waybar::modules::SNI
|