1 /*
2  * TilEm II
3  *
4  * Copyright (c) 2011 Benjamin Moody
5  *
6  * This program is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 
24 #include <stdio.h>
25 #include <gtk/gtk.h>
26 
27 #include "icons.h"
28 #include "files.h"
29 
30 static const char * const custom_icons[] = {
31 	/* Disassembly icons */
32 	"tilem-disasm-pc",
33 	"tilem-disasm-break",
34 	"tilem-disasm-break-pc",
35 
36 	/* Debugger actions */
37 	"tilem-db-step",
38 	"tilem-db-step-over",
39 	"tilem-db-finish"
40 };
41 
42 /* Set up custom icons. */
init_custom_icons()43 void init_custom_icons()
44 {
45 	GtkIconTheme *theme;
46 	GtkIconFactory *factory;
47 	GtkIconSet *set;
48 	GtkIconSource *source;
49 	char *path;
50 	gsize i;
51 
52 	path = get_shared_dir_path("icons", NULL);
53 	if (path) {
54 		theme = gtk_icon_theme_get_default();
55 		gtk_icon_theme_append_search_path(theme, path);
56 		g_free(path);
57 	}
58 
59 	factory = gtk_icon_factory_new();
60 	for (i = 0; i < G_N_ELEMENTS(custom_icons); i++) {
61 		set = gtk_icon_set_new();
62 		source = gtk_icon_source_new();
63 		gtk_icon_source_set_icon_name(source, custom_icons[i]);
64 		gtk_icon_set_add_source(set, source);
65 		gtk_icon_source_free(source);
66 		gtk_icon_factory_add(factory, custom_icons[i], set);
67 		gtk_icon_set_unref(set);
68 	}
69 	gtk_icon_factory_add_default(factory);
70 	g_object_unref(factory);
71 }
72