Use bundled icons when theme icons are too small

Some icon themes may return a lower-resolution icon than requested.
For example, under XQuartz on macOS, Gtk::IconTheme::load_icon()
returns a 16x16 drive-harddisk icon even when a 64x64 icon is
requested.

Because the theme lookup succeeds, the bundled higher-resolution
icons are never used, resulting in tiny drive icons in the main
window.

Fall back to the bundled icon when the theme-provided icon is
smaller than the requested size.
This commit is contained in:
OldMan2525
2026-07-07 02:13:11 -07:00
parent cab21bd6dd
commit fa31a696a7
+9 -1
View File
@@ -554,10 +554,18 @@ Glib::RefPtr<Gdk::Pixbuf> GscMainWindowIconView::load_icon_pixbuf(Glib::RefPtr<G
{
Glib::RefPtr<Gdk::Pixbuf> icon;
// Try XDG version first
// Try the icon theme first; fall back to the bundled icon if needed.
try {
if (default_icon_theme && !xdg_icon_name.empty()) {
icon = default_icon_theme->load_icon(xdg_icon_name, icon_size_, get_scale_factor(), Gtk::IconLookupFlags(0));
// Some icon themes may return an icon smaller than requested.
// In that case, fall back to the bundled icon.
if (icon &&
(icon->get_width() < icon_size_ ||
icon->get_height() < icon_size_)) {
icon.reset();
}
}
} catch (...) { } // ignore exceptions