From f80d5b422f60b7d3e91e4b5612d5eb6746450863 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Wed, 28 Aug 2019 17:33:11 -0700 Subject: [PATCH] Added support for desktop icons in drun mode --- src/wofi.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/wofi.c b/src/wofi.c index 5f29dff..ab2ea98 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -317,8 +317,21 @@ static void* do_drun(void* data) { free(full_path); continue; } + char* text; + GIcon* icon = g_app_info_get_icon(G_APP_INFO(info)); + if(allow_images && icon != NULL) { + 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, 32, 0); + const gchar* icon_path = gtk_icon_info_get_filename(info); + text = utils_concat(4, "img:", icon_path, ":text:", name); + } + } else { + text = strdup(name); + } struct node* node = malloc(sizeof(struct node)); - node->text = strdup(name); + node->text = text; node->action = strdup(full_path); node->container = GTK_CONTAINER(inner_box); g_idle_add(insert_widget, node);