refactor(Tray): proper lookup in the default theme

This commit is contained in:
Alex 2019-04-19 17:30:40 +02:00
parent 8cf19826aa
commit 29d8f365f8
1 changed files with 8 additions and 7 deletions

View File

@ -265,15 +265,16 @@ Glib::RefPtr<Gdk::Pixbuf> waybar::modules::SNI::Item::getIconByName(std::string
if (tmp_size == 0) { if (tmp_size == 0) {
tmp_size = request_size; tmp_size = request_size;
} }
auto icon = if (!icon_theme_path.empty() &&
icon_theme->load_icon(name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE); icon_theme->lookup_icon(
if (!icon) { name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE)) {
Glib::RefPtr<Gtk::IconTheme> default_theme = Gtk::IconTheme::get_default(); return icon_theme->load_icon(
default_theme->rescan_if_needed();
return default_theme->load_icon(
name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE); name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
} }
return icon; Glib::RefPtr<Gtk::IconTheme> default_theme = Gtk::IconTheme::get_default();
default_theme->rescan_if_needed();
return default_theme->load_icon(
name.c_str(), tmp_size, Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
} }
void waybar::modules::SNI::Item::onMenuDestroyed(Item* self) { void waybar::modules::SNI::Item::onMenuDestroyed(Item* self) {