Add base name representation
parent
edd4d8ee11
commit
7638f5c595
|
@ -1,7 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <gtkmm/button.h>
|
||||||
#include <gtkmm/image.h>
|
#include <gtkmm/image.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -23,6 +25,7 @@ class Workspace {
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
|
|
||||||
auto id() const -> uint32_t { return id_; }
|
auto id() const -> uint32_t { return id_; }
|
||||||
|
// wlr stuff
|
||||||
auto handle_name(const std::string &name) -> void { name_ = name; }
|
auto handle_name(const std::string &name) -> void { name_ = name; }
|
||||||
auto handle_coordinates(const std::vector<uint32_t> &coordinates) -> void {
|
auto handle_coordinates(const std::vector<uint32_t> &coordinates) -> void {
|
||||||
coordinates_ = coordinates;
|
coordinates_ = coordinates;
|
||||||
|
@ -46,8 +49,9 @@ class Workspace {
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::vector<uint32_t> coordinates_;
|
std::vector<uint32_t> coordinates_;
|
||||||
|
|
||||||
const Gtk::Box box_;
|
Gtk::Button button_;
|
||||||
const Gtk::Image icon_;
|
Gtk::Box content_;
|
||||||
|
Gtk::Label label_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorkspaceGroup {
|
class WorkspaceGroup {
|
||||||
|
@ -62,11 +66,12 @@ class WorkspaceGroup {
|
||||||
|
|
||||||
// wlr stuff
|
// wlr stuff
|
||||||
auto handle_workspace_create(zwlr_workspace_handle_v1 *workspace_handle) -> void;
|
auto handle_workspace_create(zwlr_workspace_handle_v1 *workspace_handle) -> void;
|
||||||
|
|
||||||
auto handle_remove() -> void;
|
auto handle_remove() -> void;
|
||||||
auto handle_output_enter(wl_output *output) -> void;
|
auto handle_output_enter(wl_output *output) -> void;
|
||||||
auto handle_output_leave() -> void;
|
auto handle_output_leave() -> void;
|
||||||
|
|
||||||
|
auto add_button(Gtk::Button &button) -> void;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint32_t group_global_id;
|
static uint32_t group_global_id;
|
||||||
const waybar::Bar &bar_;
|
const waybar::Bar &bar_;
|
||||||
|
@ -93,10 +98,11 @@ class WorkspaceManager : public AModule {
|
||||||
auto register_manager(wl_registry *registry, uint32_t name, uint32_t version) -> void;
|
auto register_manager(wl_registry *registry, uint32_t name, uint32_t version) -> void;
|
||||||
auto handle_workspace_group_create(zwlr_workspace_group_handle_v1 *workspace_group_handle)
|
auto handle_workspace_group_create(zwlr_workspace_group_handle_v1 *workspace_group_handle)
|
||||||
-> void;
|
-> void;
|
||||||
|
|
||||||
auto handle_done() -> void;
|
auto handle_done() -> void;
|
||||||
auto handle_finished() -> void;
|
auto handle_finished() -> void;
|
||||||
|
|
||||||
|
auto add_button(Gtk::Button &button) -> void { box_.pack_start(button, false, false); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const waybar::Bar & bar_;
|
const waybar::Bar & bar_;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
|
|
|
@ -14,7 +14,7 @@ uint32_t WorkspaceGroup::group_global_id = 0;
|
||||||
|
|
||||||
WorkspaceManager::WorkspaceManager(const std::string &id, const waybar::Bar &bar,
|
WorkspaceManager::WorkspaceManager(const std::string &id, const waybar::Bar &bar,
|
||||||
const Json::Value &config)
|
const Json::Value &config)
|
||||||
: waybar::AModule(config, "workspaces", id, false, !config["disable-scroll"].asBool()),
|
: waybar::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) {
|
||||||
box_.set_name("workspaces");
|
box_.set_name("workspaces");
|
||||||
|
@ -53,6 +53,7 @@ auto WorkspaceManager::handle_finished() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto WorkspaceManager::handle_done() -> void {
|
auto WorkspaceManager::handle_done() -> void {
|
||||||
|
dp.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto WorkspaceManager::update() -> void {
|
auto WorkspaceManager::update() -> void {
|
||||||
|
@ -92,8 +93,11 @@ WorkspaceGroup::WorkspaceGroup(const Bar &bar, const Json::Value &config, Worksp
|
||||||
id_(++group_global_id) {
|
id_(++group_global_id) {
|
||||||
add_workspace_group_listener(workspace_group_handle, this);
|
add_workspace_group_listener(workspace_group_handle, this);
|
||||||
}
|
}
|
||||||
|
auto WorkspaceGroup::add_button(Gtk::Button &button) -> void {
|
||||||
|
workspace_manager_.add_button(button);
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceGroup::~WorkspaceGroup()->void {
|
WorkspaceGroup::~WorkspaceGroup() {
|
||||||
if (!workspace_group_handle_) {
|
if (!workspace_group_handle_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +139,7 @@ auto WorkspaceGroup::remove_workspace(uint32_t id) -> void {
|
||||||
[id](const std::unique_ptr<Workspace> &w) { return w->id() == id; });
|
[id](const std::unique_ptr<Workspace> &w) { return w->id() == id; });
|
||||||
|
|
||||||
if (it == workspaces_.end()) {
|
if (it == workspaces_.end()) {
|
||||||
spdlog::warn("Can't find group with id {}", id);
|
spdlog::warn("Can't find workspace with id {}", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,8 +152,17 @@ Workspace::Workspace(const Bar &bar, const Json::Value &config, WorkspaceGroup &
|
||||||
config_(config),
|
config_(config),
|
||||||
workspace_group_(workspace_group),
|
workspace_group_(workspace_group),
|
||||||
workspace_handle_(workspace),
|
workspace_handle_(workspace),
|
||||||
id_(++workspace_global_id) {
|
id_(++workspace_global_id),
|
||||||
|
content_{bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0} {
|
||||||
add_workspace_listener(workspace, this);
|
add_workspace_listener(workspace, this);
|
||||||
|
workspace_group.add_button(button_);
|
||||||
|
button_.set_relief(Gtk::RELIEF_NONE);
|
||||||
|
label_.set_label(fmt::format("{name}", fmt::arg("name", "1")));
|
||||||
|
label_.show();
|
||||||
|
content_.add(label_);
|
||||||
|
content_.show();
|
||||||
|
button_.add(content_);
|
||||||
|
button_.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Workspace::~Workspace() {
|
Workspace::~Workspace() {
|
||||||
|
@ -161,7 +174,10 @@ Workspace::~Workspace() {
|
||||||
workspace_handle_ = nullptr;
|
workspace_handle_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Workspace::update() -> void {}
|
auto Workspace::update() -> void {
|
||||||
|
label_.set_label(fmt::format("{name}", fmt::arg("name", name_)));
|
||||||
|
label_.show();
|
||||||
|
}
|
||||||
|
|
||||||
auto Workspace::handle_state(const std::vector<uint32_t> &state) -> void {
|
auto Workspace::handle_state(const std::vector<uint32_t> &state) -> void {
|
||||||
state_ = 0;
|
state_ = 0;
|
||||||
|
|
Loading…
Reference in New Issue