Skip to content

Commit

Permalink
Merge pull request #2626 from akliuxingyuan/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexays authored Nov 1, 2023
2 parents 1149e51 + 335a736 commit 22dc879
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/modules/sni/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,32 +356,15 @@ Glib::RefPtr<Gdk::Pixbuf> Item::getIconPixbuf() {
}

Glib::RefPtr<Gdk::Pixbuf> Item::getIconByName(const std::string& name, int request_size) {
int tmp_size = 0;
icon_theme->rescan_if_needed();
auto sizes = icon_theme->get_icon_sizes(name.c_str());

for (auto const& size : sizes) {
// -1 == scalable
if (size == request_size || size == -1) {
tmp_size = request_size;
break;
} else if (size < request_size) {
tmp_size = size;
} else if (size > tmp_size && tmp_size > 0) {
tmp_size = request_size;
break;
}
}
if (tmp_size == 0) {
tmp_size = request_size;
}
if (!icon_theme_path.empty() &&
icon_theme->lookup_icon(name.c_str(), tmp_size,
icon_theme->lookup_icon(name.c_str(), request_size,
Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE)) {
return icon_theme->load_icon(name.c_str(), tmp_size,
return icon_theme->load_icon(name.c_str(), request_size,
Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
}
return DefaultGtkIconThemeWrapper::load_icon(name.c_str(), tmp_size,
return DefaultGtkIconThemeWrapper::load_icon(name.c_str(), request_size,
Gtk::IconLookupFlags::ICON_LOOKUP_FORCE_SIZE);
}

Expand Down

0 comments on commit 22dc879

Please sign in to comment.