refactor: format tray && partial fix for #235

This commit is contained in:
Alex
2019-04-17 14:19:04 +02:00
parent 93a1bafb46
commit 346ec68578
9 changed files with 244 additions and 267 deletions

View File

@ -2,14 +2,12 @@
#include <iostream>
waybar::modules::SNI::Tray::Tray(const std::string& id, const Bar& bar,
const Json::Value &config)
waybar::modules::SNI::Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
: config_(config),
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0),
watcher_(), host_(nb_hosts_, config,
std::bind(&Tray::onAdd, this, std::placeholders::_1),
std::bind(&Tray::onRemove, this, std::placeholders::_1))
{
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0),
watcher_(),
host_(nb_hosts_, config, std::bind(&Tray::onAdd, this, std::placeholders::_1),
std::bind(&Tray::onRemove, this, std::placeholders::_1)) {
std::cout << "Tray is in beta, so there may be bugs or even be unusable." << std::endl;
if (config_["spacing"].isUInt()) {
box_.set_spacing(config_["spacing"].asUInt());
@ -17,14 +15,12 @@ waybar::modules::SNI::Tray::Tray(const std::string& id, const Bar& bar,
nb_hosts_ += 1;
}
void waybar::modules::SNI::Tray::onAdd(std::unique_ptr<Item>& item)
{
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)
{
void waybar::modules::SNI::Tray::onRemove(std::unique_ptr<Item>& item) {
box_.remove(item->event_box);
dp.emit();
}
@ -38,6 +34,4 @@ auto waybar::modules::SNI::Tray::update() -> void {
}
}
waybar::modules::SNI::Tray::operator Gtk::Widget &() {
return box_;
}
waybar::modules::SNI::Tray::operator Gtk::Widget&() { return box_; }