2018-08-29 20:36:39 +02:00
|
|
|
#include "modules/sni/tray.hpp"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2018-10-04 18:03:01 +02:00
|
|
|
waybar::modules::SNI::Tray::Tray(const Json::Value &config)
|
2018-10-26 14:53:39 +02:00
|
|
|
: config_(config), watcher_(), host_(&dp, config)
|
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-08-29 20:36:39 +02:00
|
|
|
|
2018-10-04 18:03:01 +02:00
|
|
|
auto waybar::modules::SNI::Tray::update() -> void {
|
2018-10-26 14:53:39 +02:00
|
|
|
auto childrens = box_.get_children();
|
2018-11-16 12:01:03 +01:00
|
|
|
// childrens.erase(childrens.begin(), childrens.end());
|
2018-10-04 18:47:06 +02:00
|
|
|
for (auto &item : host_.items) {
|
2018-11-16 12:01:03 +01:00
|
|
|
box_.pack_start(*item.event_box);
|
2018-08-29 20:36:39 +02:00
|
|
|
}
|
|
|
|
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_;
|
|
|
|
}
|