From ac6667b1c979aa9493c4ae033d121a712743e484 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Tue, 2 Feb 2021 01:03:28 -0400 Subject: [PATCH] [wlr/taskbar] More icon search improvements. * Added ~/.local/share prefix to search in user defined apps. * Add support for apps that don't properly set an id like pamac. --- src/modules/wlr/taskbar.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index 83ce3662..15b927a8 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -15,6 +15,7 @@ #include #include +#include #include @@ -64,6 +65,9 @@ static std::vector search_prefix() } while(end != std::string::npos); } + std::string home_dir = std::getenv("HOME"); + prefixes.push_back(home_dir + "/.local/share/"); + for (auto& p : prefixes) spdlog::debug("Using 'desktop' search path prefix: {}", p); @@ -111,6 +115,26 @@ static std::string get_from_icon_theme(const Glib::RefPtr& icon_ return ""; } +/* Method 3 - as last resort perform a search for most appropriate desktop info file */ +static std::string get_from_desktop_app_info_search(const std::string &app_id) +{ + std::string desktop_file = ""; + + gchar*** desktop_list = g_desktop_app_info_search(app_id.c_str()); + if (desktop_list != nullptr && desktop_list[0] != nullptr) { + for (size_t i=0; desktop_list[0][i]; i++) { + if(desktop_file == "") { + desktop_file = desktop_list[0][i]; + } + break; + } + g_strfreev(desktop_list[0]); + } + g_free(desktop_list); + + return get_from_desktop_app_info(desktop_file); +} + static bool image_load_icon(Gtk::Image& image, const Glib::RefPtr& icon_theme, const std::string &app_id_list, int size) { @@ -142,9 +166,11 @@ static bool image_load_icon(Gtk::Image& image, const Glib::RefPtrload_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); if (pixbuf) {