cocoa: add support for GBytesIcon in notification backend

This commit is contained in:
Marvin W 2025-04-18 14:36:34 +02:00
parent e237ec6c81
commit cf44fb0d2a
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A

View File

@ -29,6 +29,7 @@
#include "giomodule-priv.h"
#include "gnotification-private.h"
#include "gthemedicon.h"
#include "gbytesicon.h"
#include "gfileicon.h"
#include "gfile.h"
@ -78,6 +79,22 @@ nsimage_from_gicon (GIcon *icon)
}
return image;
}
else if (G_IS_BYTES_ICON (icon))
{
NSImage *image = nil;
GBytes *bytes;
gconstpointer bytes_data;
gsize bytes_size;
NSData *data;
bytes = g_bytes_icon_get_bytes (G_BYTES_ICON (icon));
bytes_data = g_bytes_get_data (bytes, &bytes_size);
data = [[NSData alloc] initWithBytes:bytes_data
length:bytes_size];
image = [[NSImage alloc] initWithData:data];
return image;
}
else
{
g_warning ("This icon type is not handled by this NotificationBackend");