AIconLabel: support icon-size config
This commit is contained in:
@@ -19,6 +19,7 @@ class AIconLabel : public ALabel {
|
|||||||
protected:
|
protected:
|
||||||
Gtk::Image image_;
|
Gtk::Image image_;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
|
unsigned app_icon_size_{24};
|
||||||
|
|
||||||
bool labelContainsIcon;
|
bool labelContainsIcon;
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -11,6 +11,10 @@ AIconLabel::AIconLabel(const Json::Value &config, const std::string &name, const
|
|||||||
const std::string &format, uint16_t interval, bool ellipsize,
|
const std::string &format, uint16_t interval, bool ellipsize,
|
||||||
bool enable_click, bool enable_scroll)
|
bool enable_click, bool enable_scroll)
|
||||||
: ALabel(config, name, id, format, interval, ellipsize, enable_click, 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();
|
event_box_.remove();
|
||||||
label_.unset_name();
|
label_.unset_name();
|
||||||
label_.get_style_context()->remove_class(MODULE_CLASS);
|
label_.get_style_context()->remove_class(MODULE_CLASS);
|
||||||
@@ -86,9 +90,8 @@ auto AIconLabel::update() -> void {
|
|||||||
label_.set_markup(cleanLabel);
|
label_.set_markup(cleanLabel);
|
||||||
|
|
||||||
if (iconLabel.front() == '/') {
|
if (iconLabel.front() == '/') {
|
||||||
auto pixbuf = Gdk::Pixbuf::create_from_file(iconLabel);
|
int scaled_icon_size = app_icon_size_ * image_.get_scale_factor();
|
||||||
int scaled_icon_size = 6 * image_.get_scale_factor();
|
auto pixbuf = Gdk::Pixbuf::create_from_file(iconLabel, scaled_icon_size, scaled_icon_size);
|
||||||
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(),
|
auto surface = Gdk::Cairo::create_surface_from_pixbuf(pixbuf, image_.get_scale_factor(),
|
||||||
image_.get_window());
|
image_.get_window());
|
||||||
|
|||||||
Reference in New Issue
Block a user