| 21 | std::map<std::string, std::string> Workspace::icon_map_; |
| 22 | |
| 23 | WorkspaceManager::WorkspaceManager(const std::string& id, const waybar::Bar& bar, |
| 24 | const Json::Value& config) |
| 25 | : waybar::AModule(config, "workspaces", id, false, false), bar_(bar), box_(bar.orientation, 0) { |
| 26 | add_registry_listener(this); |
| 27 | |
| 28 | // parse configuration |
| 29 | |
| 30 | const auto config_sort_by_number = config_["sort-by-number"]; |
| 31 | if (config_sort_by_number.isBool()) { |
| 32 | spdlog::warn("[ext/workspaces]: Prefer sort-by-id instead of sort-by-number"); |
| 33 | sort_by_id_ = config_sort_by_number.asBool(); |
| 34 | } |
| 35 | |
| 36 | const auto config_sort_by_id = config_["sort-by-id"]; |
| 37 | if (config_sort_by_id.isBool()) { |
| 38 | sort_by_id_ = config_sort_by_id.asBool(); |
| 39 | } |
| 40 | |
| 41 | const auto config_sort_by_name = config_["sort-by-name"]; |
| 42 | if (config_sort_by_name.isBool()) { |
| 43 | sort_by_name_ = config_sort_by_name.asBool(); |
| 44 | } |
| 45 | |
| 46 | const auto config_sort_by_coordinates = config_["sort-by-coordinates"]; |
| 47 | if (config_sort_by_coordinates.isBool()) { |
| 48 | sort_by_coordinates_ = config_sort_by_coordinates.asBool(); |
| 49 | } |
| 50 | |
| 51 | const auto config_all_outputs = config_["all-outputs"]; |
| 52 | if (config_all_outputs.isBool()) { |
| 53 | all_outputs_ = config_all_outputs.asBool(); |
| 54 | } |
| 55 | |
| 56 | // setup UI |
| 57 | |
| 58 | box_.set_name("workspaces"); |
| 59 | if (!id.empty()) { |
| 60 | box_.get_style_context()->add_class(id); |
| 61 | } |
| 62 | box_.get_style_context()->add_class(MODULE_CLASS); |
| 63 | event_box_.add(box_); |
| 64 | |
| 65 | spdlog::debug("[ext/workspaces]: Workspace manager created"); |
| 66 | } |
| 67 | |
| 68 | WorkspaceManager::~WorkspaceManager() { |
| 69 | workspaces_.clear(); |
nothing calls this directly
no test coverage detected