| 316 | // Workspace |
| 317 | |
| 318 | Workspace::Workspace(const Json::Value& config, WorkspaceManager& manager, |
| 319 | ext_workspace_handle_v1* handle, uint32_t id, const std::string& name) |
| 320 | : workspace_manager_(manager), ext_handle_(handle), id_(id), workspace_id_(name), name_(name) { |
| 321 | add_workspace_listener(ext_handle_, this); |
| 322 | |
| 323 | // parse configuration |
| 324 | |
| 325 | const auto& config_active_only = config["active-only"]; |
| 326 | if (config_active_only.isBool()) { |
| 327 | active_only_ = config_active_only.asBool(); |
| 328 | } |
| 329 | |
| 330 | const auto& config_ignore_hidden = config["ignore-hidden"]; |
| 331 | if (config_ignore_hidden.isBool()) { |
| 332 | ignore_hidden_ = config_ignore_hidden.asBool(); |
| 333 | } |
| 334 | |
| 335 | const auto& config_format = config["format"]; |
| 336 | format_ = config_format.isString() ? config_format.asString() : "{name}"; |
| 337 | with_icon_ = format_.find("{icon}") != std::string::npos; |
| 338 | |
| 339 | if (with_icon_ && icon_map_.empty()) { |
| 340 | const auto& format_icons = config["format-icons"]; |
| 341 | for (auto& n : format_icons.getMemberNames()) { |
| 342 | icon_map_.emplace(n, format_icons[n].asString()); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | const bool config_on_click = config["on-click"].isString(); |
| 347 | if (config_on_click) { |
| 348 | on_click_action_ = config["on-click"].asString(); |
| 349 | } |
| 350 | const bool config_on_click_middle = config["on-click-middle"].isString(); |
| 351 | if (config_on_click_middle) { |
| 352 | on_click_middle_action_ = config["on-click-middle"].asString(); |
| 353 | } |
| 354 | const bool config_on_click_right = config["on-click-right"].isString(); |
| 355 | if (config_on_click_right) { |
| 356 | on_click_right_action_ = config["on-click-right"].asString(); |
| 357 | } |
| 358 | |
| 359 | // setup UI |
| 360 | |
| 361 | if (config_on_click || config_on_click_middle || config_on_click_right) { |
| 362 | button_.add_events(Gdk::BUTTON_PRESS_MASK); |
| 363 | button_.signal_button_press_event().connect(sigc::mem_fun(*this, &Workspace::handle_clicked), |
| 364 | false); |
| 365 | } |
| 366 | |
| 367 | button_.set_relief(Gtk::RELIEF_NONE); |
| 368 | content_.set_center_widget(label_); |
| 369 | button_.add(content_); |
| 370 | } |
| 371 | |
| 372 | Workspace::~Workspace() { |
| 373 | if (ext_handle_ != nullptr) { |
nothing calls this directly
no test coverage detected