From a30d5c09e57d27f30441d2ba983daa4a8ea1431b Mon Sep 17 00:00:00 2001 From: Ian Brunelli Date: Sun, 24 Nov 2019 08:46:14 -0300 Subject: [PATCH] Add a fallback icon to drun entries --- modes/drun.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modes/drun.c b/modes/drun.c index 9fd6e24..32bad5f 100644 --- a/modes/drun.c +++ b/modes/drun.c @@ -35,22 +35,22 @@ static char* get_text(char* file, char* action) { } if(wofi_allow_images()) { GIcon* icon = g_app_info_get_icon(G_APP_INFO(info)); - if(G_IS_THEMED_ICON(icon)) { - GtkIconTheme* theme = gtk_icon_theme_get_default(); - const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON(icon)); - GtkIconInfo* info = gtk_icon_theme_choose_icon(theme, (const gchar**) icon_names, wofi_get_image_size(), 0); - if(info == NULL) { - return utils_concat(2, "text:", name); - } else { - const gchar* icon_path = gtk_icon_info_get_filename(info); - return utils_concat(4, "img:", icon_path, ":text:", name); - } - } else if(G_IS_FILE_ICON(icon)) { + if(G_IS_FILE_ICON(icon)) { GFile* file = g_file_icon_get_file(G_FILE_ICON(icon)); char* path = g_file_get_path(file); return utils_concat(4, "img:", path, ":text:", name); } else { - return utils_concat(2, "text:", name); + GtkIconTheme* theme = gtk_icon_theme_get_default(); + GtkIconInfo* info = NULL; + if(icon != NULL) { + const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON(icon)); + info = gtk_icon_theme_choose_icon(theme, (const gchar**) icon_names, wofi_get_image_size(), 0); + } + if(info == NULL) { + info = gtk_icon_theme_lookup_icon(theme, "application-x-executable", wofi_get_image_size(), 0); + } + const gchar* icon_path = gtk_icon_info_get_filename(info); + return utils_concat(4, "img:", icon_path, ":text:", name); } } else { return strdup(name);