summaryrefslogtreecommitdiffstats
path: root/gtk/src/icons.c
blob: af7d84e05923ad30421874ee661f5beb64b24b78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <gtk/gtk.h>
#include "icon_tools.h"
#include "values.h"
#include "resources.h"

void
ghb_load_icons()
{
	GdkPixbuf *pb;
	GHashTableIter iter;
	gchar *name;
	GValue *gval;
	ghb_rawdata_t *rd;
	gint size;

	GValue *icons = ghb_resource_get("icons");
	ghb_dict_iter_init(&iter, icons);
	// middle (void*) cast prevents gcc warning "defreferencing type-punned
	// pointer will break strict-aliasing rules"
	while (g_hash_table_iter_next(
			&iter, (gpointer*)(void*)&name, (gpointer*)(void*)&gval))
	{
		rd = g_value_get_boxed(gval);
		pb = icon_deserialize(rd->data, rd->size);
		size = gdk_pixbuf_get_height(pb);
		gtk_icon_theme_add_builtin_icon(name, size, pb);
		gdk_pixbuf_unref(pb);
	}
}