From 1764d577ad866f653b0204b33d1251d0443c36d2 Mon Sep 17 00:00:00 2001 From: Simon Long Date: Thu, 24 Oct 2024 17:42:15 +0100 Subject: [PATCH] Add final check for matching partial strings when looking for icons --- src/icon-loader.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/icon-loader.c b/src/icon-loader.c index 4a15a23b..30ffb6f8 100644 --- a/src/icon-loader.c +++ b/src/icon-loader.c @@ -236,6 +236,20 @@ get_db_entry_by_id_fuzzy(struct sfdo_desktop_db *db, const char *app_id) } } + /* Try matching partial strings - catches GIMP, among others */ + for (size_t i = 0; i < n_entries; i++) { + struct sfdo_desktop_entry *entry = entries[i]; + const char *desktop_id = sfdo_desktop_entry_get_id(entry, NULL); + const char *dot = strrchr(desktop_id, '.'); + const char *desktop_id_base = dot ? (dot + 1) : desktop_id; + int alen = strlen(app_id); + int dlen = strlen(desktop_id_base); + + if (!strncmp(app_id, desktop_id, alen > dlen ? dlen : alen)) { + return entry; + } + } + return NULL; }