JS: Widget icons without path, just name

This commit is contained in:
Willy-JL
2024-03-28 22:28:52 +00:00
parent a94a1a96ae
commit a1eeeb245f
2 changed files with 8 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
#include <gui/view.h>
#include <m-array.h>
#include <m-list.h>
#include <string.h>
#include "../js_modules.h"
typedef struct WidgetComponent WidgetComponent;
@@ -505,8 +506,11 @@ static void js_widget_add_icon(struct mjs* mjs) {
const Icon* icon = NULL;
for(size_t i = 0; i < ICON_PATHS_COUNT; i++) {
if(ICON_PATHS[i].path != NULL && strnlen(ICON_PATHS[i].path, icon_len + 2) == icon_len &&
strncmp(icon_name, ICON_PATHS[i].path, icon_len) == 0) {
if(ICON_PATHS[i].path == NULL) continue;
const char* iter_name = strrchr(ICON_PATHS[i].path, '/');
if(iter_name++ == NULL) continue;
if(strnlen(iter_name, icon_len + 1) == icon_len &&
strncmp(iter_name, icon_name, icon_len) == 0) {
icon = ICON_PATHS[i].icon;
break;
}