File: item-pixbuf.c

package info (click to toggle)
vala-panel-appmenu 0.7.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,336 kB
  • sloc: ansic: 2,309; xml: 83; makefile: 56; sh: 7
file content (22 lines) | stat: -rw-r--r-- 661 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>

G_GNUC_INTERNAL GIcon *g_icon_new_pixbuf_from_variant(GVariant *variant)
{
	gsize length;
	const unsigned char *data =
	    (const unsigned char *)g_variant_get_fixed_array(variant, &length, sizeof(guchar));
	if (length == 0)
		return NULL;

	g_autoptr(GInputStream) stream = g_memory_input_stream_new_from_data(data, length, NULL);
	if (stream == NULL)
		return NULL;

	g_autoptr(GError) error = NULL;
	GdkPixbuf *pixbuf       = gdk_pixbuf_new_from_stream(stream, NULL, &error);
	if (error != NULL)
		g_warning("Unable to build GdkPixbuf from icon data: %s", error->message);

	return G_ICON(pixbuf);
}