From eb2090688ccbf66cfdecba63c2459a54090b1591 Mon Sep 17 00:00:00 2001 From: Rio Sanjaya Date: Wed, 24 Dec 2025 08:25:51 +0700 Subject: [PATCH] AIconLabel: support icon-size config --- include/AIconLabel.hpp | 1 + src/AIconLabel.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/AIconLabel.hpp b/include/AIconLabel.hpp index 2e0956e5..91b022a4 100644 --- a/include/AIconLabel.hpp +++ b/include/AIconLabel.hpp @@ -19,6 +19,7 @@ class AIconLabel : public ALabel { protected: Gtk::Image image_; Gtk::Box box_; + unsigned app_icon_size_{24}; bool labelContainsIcon; diff --git a/src/AIconLabel.cpp b/src/AIconLabel.cpp index 532ed433..81953d7b 100644 --- a/src/AIconLabel.cpp +++ b/src/AIconLabel.cpp @@ -11,6 +11,10 @@ AIconLabel::AIconLabel(const Json::Value &config, const std::string &name, const const std::string &format, uint16_t interval, bool ellipsize, bool enable_click, bool enable_scroll) : ALabel(config, name, id, format, interval, ellipsize, enable_click, enable_scroll) { + if (config["icon-size"].isUInt()) { + app_icon_size_ = config["icon-size"].asUInt(); + } + image_.set_pixel_size(app_icon_size_); event_box_.remove(); label_.unset_name(); label_.get_style_context()->remove_class(MODULE_CLASS); @@ -86,9 +90,8 @@ auto AIconLabel::update() -> void { label_.set_markup(cleanLabel); if (iconLabel.front() == '/') { - auto pixbuf = Gdk::Pixbuf::create_from_file(iconLabel); - int scaled_icon_size = 6 * image_.get_scale_factor(); - pixbuf = Gdk::Pixbuf::create_from_file(iconLabel, scaled_icon_size, scaled_icon_size); + int scaled_icon_size = app_icon_size_ * image_.get_scale_factor(); + auto pixbuf = Gdk::Pixbuf::create_from_file(iconLabel, scaled_icon_size, scaled_icon_size); auto surface = Gdk::Cairo::create_surface_from_pixbuf(pixbuf, image_.get_scale_factor(), image_.get_window());