From 78067462be4f82e93416c1ce98025a8d33289d12 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 11 Apr 2019 15:20:39 +0200 Subject: [PATCH] fix(Tray): icons update --- include/modules/sni/item.hpp | 1 + src/modules/sni/item.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/modules/sni/item.hpp b/include/modules/sni/item.hpp index 016ca4e..71b1a71 100644 --- a/include/modules/sni/item.hpp +++ b/include/modules/sni/item.hpp @@ -38,6 +38,7 @@ public: int32_t window_id; std::string icon_name; Glib::RefPtr icon_pixmap; + Glib::RefPtr icon_theme; std::string overlay_icon_name; std::string attention_icon_name; std::string attention_movie_name; diff --git a/src/modules/sni/item.cpp b/src/modules/sni/item.cpp index fdd481a..2a80b9b 100644 --- a/src/modules/sni/item.cpp +++ b/src/modules/sni/item.cpp @@ -10,7 +10,7 @@ static const unsigned UPDATE_DEBOUNCE_TIME = 10; waybar::modules::SNI::Item::Item(std::string bn, std::string op, const Json::Value& config) : bus_name(bn), object_path(op), icon_size(16), effective_icon_size(0), - update_pending_(false) { + icon_theme(Gtk::IconTheme::create()), update_pending_(false) { if (config["icon-size"].isUInt()) { icon_size = config["icon-size"].asUInt(); } @@ -45,10 +45,6 @@ void waybar::modules::SNI::Item::proxyReady(Glib::RefPtr& resu this->object_path << std::endl; return; } - if (!this->icon_theme_path.empty()) { - Glib::RefPtr icon_theme = Gtk::IconTheme::get_default(); - icon_theme->append_search_path(this->icon_theme_path); - } this->updateImage(); // this->event_box.set_tooltip_text(this->title); @@ -97,6 +93,9 @@ waybar::modules::SNI::Item::setProperty(const ustring& name, // TODO: tooltip } else if (name == "IconThemePath") { icon_theme_path = get_variant(value); + if (!icon_theme_path.empty()) { + icon_theme->set_search_path({icon_theme_path}); + } } else if (name == "Menu") { menu = get_variant(value); } else if (name == "ItemIsMenu") { @@ -248,7 +247,6 @@ void waybar::modules::SNI::Item::updateImage() Glib::RefPtr waybar::modules::SNI::Item::getIconByName(std::string name, int request_size) { int tmp_size = 0; - Glib::RefPtr icon_theme = Gtk::IconTheme::get_default(); icon_theme->rescan_if_needed(); auto sizes = icon_theme->get_icon_sizes(name.c_str());