5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-10 06:41:14 +08:00

Support base64 images in tray

This commit is contained in:
Lea Anthony 2021-03-06 15:43:11 +11:00
parent 14146c8c0c
commit 817c55d318
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405

View File

@ -82,8 +82,18 @@ void UpdateTrayIcon(TrayMenu *trayMenu) {
}
id trayImage = hashmap_get(&trayIconCache, trayMenu->icon, strlen(trayMenu->icon));
// If we don't have the image in the icon cache then assume it's base64 encoded image data
if (trayImage == NULL) {
id data = ALLOC("NSData");
id imageData = msg(data, s("initWithBase64EncodedString:options:"), str(trayMenu->icon), 0);
trayImage = ALLOC("NSImage");
msg(trayImage, s("initWithData:"), imageData);
}
msg(statusBarButton, s("setImagePosition:"), trayMenu->trayIconPosition);
msg(statusBarButton, s("setImage:"), trayImage);
}
void ShowTrayMenu(TrayMenu* trayMenu) {