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:
commit
6184e43c84
|
@ -34,6 +34,7 @@ class Window : public AIconLabel, public sigc::trackable {
|
||||||
std::string app_id_;
|
std::string app_id_;
|
||||||
std::string old_app_id_;
|
std::string old_app_id_;
|
||||||
std::size_t app_nb_;
|
std::size_t app_nb_;
|
||||||
|
unsigned app_icon_size_{24};
|
||||||
bool update_app_icon_{true};
|
bool update_app_icon_{true};
|
||||||
std::string app_icon_name_;
|
std::string app_icon_name_;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
|
|
|
@ -75,6 +75,11 @@ Addressed by *sway/window*
|
||||||
default: false ++
|
default: false ++
|
||||||
Option to hide the application icon.
|
Option to hide the application icon.
|
||||||
|
|
||||||
|
*icon-size*: ++
|
||||||
|
typeof: integer ++
|
||||||
|
default: 24 ++
|
||||||
|
Option to change the size of the application icon.
|
||||||
|
|
||||||
# REWRITE RULES
|
# REWRITE RULES
|
||||||
|
|
||||||
*rewrite* is an object where keys are regular expressions and values are
|
*rewrite* is an object where keys are regular expressions and values are
|
||||||
|
|
|
@ -15,6 +15,12 @@ namespace waybar::modules::sway {
|
||||||
|
|
||||||
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||||
: AIconLabel(config, "window", id, "{}", 0, true), bar_(bar), windowId_(-1) {
|
: 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_.subscribe(R"(["window","workspace"])");
|
||||||
ipc_.signal_event.connect(sigc::mem_fun(*this, &Window::onEvent));
|
ipc_.signal_event.connect(sigc::mem_fun(*this, &Window::onEvent));
|
||||||
ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Window::onCmd));
|
ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Window::onCmd));
|
||||||
|
@ -99,7 +105,7 @@ void Window::updateAppIcon() {
|
||||||
if (app_icon_name_.empty()) {
|
if (app_icon_name_.empty()) {
|
||||||
image_.set_visible(false);
|
image_.set_visible(false);
|
||||||
} else {
|
} 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);
|
image_.set_visible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue