2021-10-31 22:55:13 +00:00
|
|
|
#include "group.hpp"
|
2022-04-06 06:37:19 +00:00
|
|
|
|
2021-10-31 22:55:13 +00:00
|
|
|
#include <fmt/format.h>
|
2022-04-06 06:37:19 +00:00
|
|
|
|
2021-10-31 22:55:13 +00:00
|
|
|
#include <util/command.hpp>
|
|
|
|
|
|
|
|
namespace waybar {
|
|
|
|
|
2022-06-13 19:17:17 +00:00
|
|
|
Group::Group(const std::string& name, const std::string& id, const Json::Value& config,
|
|
|
|
bool vertical)
|
|
|
|
: AModule(config, name, id, false, false),
|
|
|
|
box{vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0} {
|
|
|
|
box.set_name(name_);
|
|
|
|
if (!id.empty()) {
|
|
|
|
box.get_style_context()->add_class(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// default orientation: orthogonal to parent
|
|
|
|
auto orientation =
|
|
|
|
config_["orientation"].empty() ? "orthogonal" : config_["orientation"].asString();
|
|
|
|
if (orientation == "inherit") {
|
|
|
|
// keep orientation passed
|
|
|
|
} else if (orientation == "orthogonal") {
|
|
|
|
box.set_orientation(vertical ? Gtk::ORIENTATION_HORIZONTAL : Gtk::ORIENTATION_VERTICAL);
|
|
|
|
} else if (orientation == "vertical") {
|
|
|
|
box.set_orientation(Gtk::ORIENTATION_VERTICAL);
|
|
|
|
} else if (orientation == "horizontal") {
|
|
|
|
box.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
|
|
|
|
} else {
|
|
|
|
throw std::runtime_error("Invalid orientation value: " + orientation);
|
|
|
|
}
|
|
|
|
}
|
2021-10-31 22:55:13 +00:00
|
|
|
|
|
|
|
auto Group::update() -> void {
|
|
|
|
// noop
|
|
|
|
}
|
|
|
|
|
|
|
|
Group::operator Gtk::Widget&() { return box; }
|
|
|
|
|
|
|
|
} // namespace waybar
|