]> git.mdlowis.com Git - proto/labwc.git/commitdiff
icon: matching partial strings (#2266)
authorSimon Long <simon@raspberrypi.com>
Fri, 8 Nov 2024 21:42:02 +0000 (21:42 +0000)
committerGitHub <noreply@github.com>
Fri, 8 Nov 2024 21:42:02 +0000 (21:42 +0000)
...to handle for example app-id="gimp-2.10" with file "gimp.desktop"

src/icon-loader.c

index 4a15a23bc76454ca66179f879594799b8a2a2dec..bf4f2fa374002d66d38c133c95290799d7fbaefd 100644 (file)
@@ -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 (!strncasecmp(app_id, desktop_id, alen > dlen ? dlen : alen)) {
+                       return entry;
+               }
+       }
+
        return NULL;
 }