Skip to content

Commit

Permalink
display loaded image in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Dec 29, 2023
1 parent bb668b3 commit b4684e2
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions plugins/notify/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep
bool should_wait_for_cover = !image_filename && deadbeef->conf_get_int ("notify.albumart", 0) && artwork_plugin;
bool should_apply_kde_fix = deadbeef->conf_get_int ("notify.fix_kde_5_23_5", 0) ? true : false;

// KDE won't re-display notification via reuse,
// KDE won't re-display notification via reuse,
// so don't show it now and wait for cover callback.
if (!(should_wait_for_cover && should_apply_kde_fix)) {
char *v_iconname = ""; // image_filename ?: "deadbeef";
Expand All @@ -333,19 +333,8 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep
dbus_int32_t v_timeout = -1;

GdkPixbuf *img = _load_image (image_filename);

dbus_int32_t width = 64;
dbus_int32_t height = 64;
dbus_int32_t stride = width * 4;
dbus_bool_t has_alpha = 1; // has to be 1, otherwise channels=4 is ignored and interpreted as 3.
dbus_int32_t bits_per_sample = 8;
dbus_int32_t channels = 4;

uint32_t *image_bytes = malloc (width * width * sizeof (uint32_t));
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image_bytes[y * width + x] = 0xff0000ff;
}
if (!img) {
v_iconname = "deadbeef";
}

DBusMessageIter iter, sub;
Expand All @@ -372,7 +361,15 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep
// hints
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{sv}", &sub);

{
if (img != NULL) {
dbus_int32_t width = gdk_pixbuf_get_width (img);
dbus_int32_t height = gdk_pixbuf_get_height (img);
dbus_int32_t stride = gdk_pixbuf_get_rowstride (img);
dbus_bool_t has_alpha = gdk_pixbuf_get_has_alpha (img);
dbus_int32_t bits_per_sample = gdk_pixbuf_get_bits_per_sample (img);
dbus_int32_t channels = gdk_pixbuf_get_n_channels (img);
guchar *image_bytes = gdk_pixbuf_get_pixels(img);
g_object_unref(img);

DBusMessageIter dict_entry_sub;
dbus_message_iter_open_container (&sub, DBUS_TYPE_DICT_ENTRY, 0, &dict_entry_sub);
Expand Down Expand Up @@ -416,7 +413,7 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep
&data_sub,
DBUS_TYPE_BYTE,
&image_bytes,
width * height * 4);
stride * height);
}

dbus_message_iter_close_container (&image_sub, &data_sub);
Expand All @@ -436,8 +433,6 @@ show_notification (DB_playItem_t *track, char *image_filename, dbus_uint32_t rep
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &v_timeout);

replaces_id = notify_send (msg, replaces_id);

free (image_bytes);
}

if (should_wait_for_cover) {
Expand Down

0 comments on commit b4684e2

Please sign in to comment.