mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-25 05:15:33 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user