Merge pull request #1523 from FlexW/feature/icon-size

sway/window: Allow the user to change the size of the app icon
This commit is contained in:
Alex 2022-04-18 08:59:36 +02:00 committed by GitHub
commit 6184e43c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,7 @@ class Window : public AIconLabel, public sigc::trackable {
std::string app_id_;
std::string old_app_id_;
std::size_t app_nb_;
unsigned app_icon_size_{24};
bool update_app_icon_{true};
std::string app_icon_name_;
util::JsonParser parser_;

View File

@ -75,6 +75,11 @@ Addressed by *sway/window*
default: false ++
Option to hide the application icon.
*icon-size*: ++
typeof: integer ++
default: 24 ++
Option to change the size of the application icon.
# REWRITE RULES
*rewrite* is an object where keys are regular expressions and values are

View File

@ -15,6 +15,12 @@ namespace waybar::modules::sway {
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
: AIconLabel(config, "window", id, "{}", 0, true), bar_(bar), windowId_(-1) {
// Icon size
if (config_["icon-size"].isUInt()) {
app_icon_size_ = config["icon-size"].asUInt();
}
image_.set_pixel_size(app_icon_size_);
ipc_.subscribe(R"(["window","workspace"])");
ipc_.signal_event.connect(sigc::mem_fun(*this, &Window::onEvent));
ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Window::onCmd));
@ -99,7 +105,7 @@ void Window::updateAppIcon() {
if (app_icon_name_.empty()) {
image_.set_visible(false);
} else {
image_.set_from_icon_name(app_icon_name_, Gtk::ICON_SIZE_LARGE_TOOLBAR);
image_.set_from_icon_name(app_icon_name_, Gtk::ICON_SIZE_INVALID);
image_.set_visible(true);
}
}