waybar/src/modules/sni/tray.cpp

41 lines
1020 B
C++
Raw Normal View History

#include "modules/sni/tray.hpp"
#include <iostream>
2018-11-22 16:20:49 +01:00
waybar::modules::SNI::Tray::Tray(Bar& bar, const Json::Value &config)
: config_(config), watcher_(), host_(bar.nb_tray_hosts, config,
2018-11-22 15:47:23 +01:00
std::bind(&Tray::onAdd, this, std::placeholders::_1),
std::bind(&Tray::onRemove, this, std::placeholders::_1))
2018-10-26 12:08:50 +02:00
{
2018-10-28 08:43:48 +01:00
std::cout << "Tray is in beta, so there may be bugs or even be unusable." << std::endl;
2018-10-26 12:08:50 +02:00
if (config_["spacing"].isUInt()) {
box_.set_spacing(config_["spacing"].asUInt());
}
2018-11-22 16:20:49 +01:00
bar.nb_tray_hosts += 1;
2018-10-26 12:08:50 +02:00
}
2018-11-22 15:47:23 +01:00
void waybar::modules::SNI::Tray::onAdd(std::unique_ptr<Item>& item)
{
box_.pack_start(item->event_box);
dp.emit();
}
void waybar::modules::SNI::Tray::onRemove(std::unique_ptr<Item>& item)
{
box_.remove(item->event_box);
dp.emit();
}
2018-10-04 18:03:01 +02:00
auto waybar::modules::SNI::Tray::update() -> void {
if (box_.get_children().size() > 0) {
box_.set_name("tray");
box_.show_all();
} else {
box_.set_name("");
}
}
2018-10-26 14:53:39 +02:00
waybar::modules::SNI::Tray::operator Gtk::Widget &() {
return box_;
}