refactor: cleanup hyprland workspaces constructor
parent
309edd0585
commit
587bd0cd62
|
@ -80,6 +80,8 @@ class Workspaces : public AModule, public EventHandler {
|
||||||
void create_workspace(Json::Value& value);
|
void create_workspace(Json::Value& value);
|
||||||
void remove_workspace(std::string name);
|
void remove_workspace(std::string name);
|
||||||
void set_urgent_workspace(std::string windowaddress);
|
void set_urgent_workspace(std::string windowaddress);
|
||||||
|
void parse_config(const Json::Value& config);
|
||||||
|
void register_ipc();
|
||||||
|
|
||||||
bool all_outputs_ = false;
|
bool all_outputs_ = false;
|
||||||
bool show_special_ = false;
|
bool show_special_ = false;
|
||||||
|
|
|
@ -14,6 +14,20 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
||||||
: AModule(config, "workspaces", id, false, false),
|
: AModule(config, "workspaces", id, false, false),
|
||||||
bar_(bar),
|
bar_(bar),
|
||||||
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0) {
|
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0) {
|
||||||
|
parse_config(config);
|
||||||
|
|
||||||
|
box_.set_name("workspaces");
|
||||||
|
if (!id.empty()) {
|
||||||
|
box_.get_style_context()->add_class(id);
|
||||||
|
}
|
||||||
|
event_box_.add(box_);
|
||||||
|
|
||||||
|
register_ipc();
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Workspaces::parse_config(const Json::Value &config) -> void {
|
||||||
Json::Value config_format = config["format"];
|
Json::Value config_format = config["format"];
|
||||||
|
|
||||||
format_ = config_format.isString() ? config_format.asString() : "{name}";
|
format_ = config_format.isString() ? config_format.asString() : "{name}";
|
||||||
|
@ -43,18 +57,19 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
||||||
active_only_ = config_active_only.asBool();
|
active_only_ = config_active_only.asBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
box_.set_name("workspaces");
|
auto config_sort_by = config_["sort-by"];
|
||||||
if (!id.empty()) {
|
if (config_sort_by.isString()) {
|
||||||
box_.get_style_context()->add_class(id);
|
sort_by = config_sort_by.asString();
|
||||||
}
|
}
|
||||||
event_box_.add(box_);
|
}
|
||||||
|
|
||||||
|
auto Workspaces::register_ipc() -> void {
|
||||||
modulesReady = true;
|
modulesReady = true;
|
||||||
|
|
||||||
if (!gIPC) {
|
if (!gIPC) {
|
||||||
gIPC = std::make_unique<IPC>();
|
gIPC = std::make_unique<IPC>();
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
gIPC->registerForIPC("workspace", this);
|
gIPC->registerForIPC("workspace", this);
|
||||||
gIPC->registerForIPC("createworkspace", this);
|
gIPC->registerForIPC("createworkspace", this);
|
||||||
gIPC->registerForIPC("destroyworkspace", this);
|
gIPC->registerForIPC("destroyworkspace", this);
|
||||||
|
|
Loading…
Reference in New Issue