diff options
author | rbuj <[email protected]> | 2020-07-25 14:15:59 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-08-27 12:33:35 +0200 |
commit | 58e338e80ac0e611626f5b2e62a2f32a4059025a (patch) | |
tree | a0a6b2ab1bda22865e68e0e46c800e56fd937ea9 /src/iconthemewrapper.cpp | |
parent | 706246d2dcb4bc3b41cf3a45c13266ed42be63b9 (diff) | |
download | mate-system-monitor-58e338e80ac0e611626f5b2e62a2f32a4059025a.tar.bz2 mate-system-monitor-58e338e80ac0e611626f5b2e62a2f32a4059025a.tar.xz |
pretty-table: prefer GIO to get application icons
Diffstat (limited to 'src/iconthemewrapper.cpp')
-rw-r--r-- | src/iconthemewrapper.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/iconthemewrapper.cpp b/src/iconthemewrapper.cpp index e44bdcd..f5ab4ef 100644 --- a/src/iconthemewrapper.cpp +++ b/src/iconthemewrapper.cpp @@ -27,3 +27,31 @@ procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) c } } +Glib::RefPtr<Gdk::Pixbuf> +procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon, + int size, Gtk::IconLookupFlags flags) const +{ + Gtk::IconInfo icon_info; + gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ()); + icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags); + + if (!icon_info) { + return Glib::RefPtr<Gdk::Pixbuf>(); + } + + try + { + return icon_info.load_icon(); + } + catch (Gtk::IconThemeError &error) + { + if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND) + g_error("Cannot load gicon from theme: %s", error.what().c_str()); + return Glib::RefPtr<Gdk::Pixbuf>(); + } + catch (Gio::Error &error) + { + g_debug("Could not load gicon: %s", error.what().c_str()); + return Glib::RefPtr<Gdk::Pixbuf>(); + } +} |