static gboolean _notify_daemon_process_icon_data(NotifyDaemon *daemon, GtkWindow *nw, GValue *icon_data) { const guchar *data = NULL; gboolean has_alpha; int bits_per_sample; int width; int height; int rowstride; int n_channels; gsize expected_len; GdkPixbuf *pixbuf; GValueArray *image_struct; GValue *value; GArray *tmp_array; if (!G_VALUE_HOLDS(icon_data, G_TYPE_VALUE_ARRAY)) { g_warning("_notify_daemon_process_icon_data expected a " "GValue of type GValueArray"); return FALSE; } image_struct = (GValueArray *)g_value_get_boxed(icon_data); value = g_value_array_get_nth(image_struct, 0); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected position " "0 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, G_TYPE_INT)) { g_warning("_notify_daemon_process_icon_data expected " "position 0 of the GValueArray to be of type int"); return FALSE; } width = g_value_get_int(value); value = g_value_array_get_nth(image_struct, 1); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected " "position 1 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, G_TYPE_INT)) { g_warning("_notify_daemon_process_icon_data expected " "position 1 of the GValueArray to be of type int"); return FALSE; } height = g_value_get_int(value); value = g_value_array_get_nth(image_struct, 2); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected " "position 2 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, G_TYPE_INT)) { g_warning("_notify_daemon_process_icon_data expected " "position 2 of the GValueArray to be of type int"); return FALSE; } rowstride = g_value_get_int(value); value = g_value_array_get_nth(image_struct, 3); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected " "position 3 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, G_TYPE_BOOLEAN)) { g_warning("_notify_daemon_process_icon_data expected " "position 3 of the GValueArray to be of type gboolean"); return FALSE; } has_alpha = g_value_get_boolean(value); value = g_value_array_get_nth(image_struct, 4); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected " "position 4 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, G_TYPE_INT)) { g_warning("_notify_daemon_process_icon_data expected " "position 4 of the GValueArray to be of type int"); return FALSE; } bits_per_sample = g_value_get_int(value); value = g_value_array_get_nth(image_struct, 5); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected " "position 5 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, G_TYPE_INT)) { g_warning("_notify_daemon_process_icon_data expected " "position 5 of the GValueArray to be of type int"); return FALSE; } n_channels = g_value_get_int(value); value = g_value_array_get_nth(image_struct, 6); if (value == NULL) { g_warning("_notify_daemon_process_icon_data expected " "position 6 of the GValueArray to exist"); return FALSE; } if (!G_VALUE_HOLDS(value, dbus_g_type_get_collection("GArray", G_TYPE_UCHAR))) { g_warning("_notify_daemon_process_icon_data expected " "position 6 of the GValueArray to be of type GArray"); return FALSE; } tmp_array = (GArray *)g_value_get_boxed(value); expected_len = (height - 1) * rowstride + width * ((n_channels * bits_per_sample + 7) / 8); if (expected_len != tmp_array->len) { g_warning("_notify_daemon_process_icon_data expected image " "data to be of length %i but got a length of %i", expected_len, tmp_array->len); return FALSE; } data = (guchar *)g_memdup(tmp_array->data, tmp_array->len); pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, has_alpha, bits_per_sample, width, height, rowstride, (GdkPixbufDestroyNotify)g_free, NULL); theme_set_notification_icon(nw, pixbuf); g_object_unref(G_OBJECT(pixbuf)); return TRUE; }