From c486ddada03f392b2d9e6e577914f48f18194e03 Mon Sep 17 00:00:00 2001 From: "Leandro A. F. Pereira" Date: Mon, 23 Jan 2006 22:38:33 +0000 Subject: Initial import --- hardinfo2/stock.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 hardinfo2/stock.c (limited to 'hardinfo2/stock.c') diff --git a/hardinfo2/stock.c b/hardinfo2/stock.c new file mode 100644 index 00000000..614d1b8f --- /dev/null +++ b/hardinfo2/stock.c @@ -0,0 +1,81 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 Leandro A. F. Pereira + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include + +static struct { + gchar *filename; + gchar *stock_id; +} stock_icons[] = { + { "report.png", HI_STOCK_REPORT}, + { "module.png", HI_STOCK_MODULE} +}; + +static GtkIconFactory *icon_factory; + +void stock_icon_register(gchar *filename, gchar *stock_id) +{ + GtkIconSet *icon_set; + GtkIconSource *icon_source; + + icon_set = gtk_icon_set_new(); + icon_source = gtk_icon_source_new(); + + gtk_icon_source_set_pixbuf(icon_source, icon_cache_get_pixbuf(filename)); + gtk_icon_set_add_source(icon_set, icon_source); + gtk_icon_source_free(icon_source); + + gtk_icon_factory_add(icon_factory, stock_id, icon_set); + + gtk_icon_set_unref(icon_set); +} + +void stock_icon_register_pixbuf(GdkPixbuf *pixbuf, gchar *stock_id) +{ + GtkIconSet *icon_set; + GtkIconSource *icon_source; + + icon_set = gtk_icon_set_new(); + icon_source = gtk_icon_source_new(); + + gtk_icon_source_set_pixbuf(icon_source, pixbuf); + gtk_icon_set_add_source(icon_set, icon_source); + gtk_icon_source_free(icon_source); + + gtk_icon_factory_add(icon_factory, stock_id, icon_set); + + gtk_icon_set_unref(icon_set); +} + +void stock_icons_init(void) +{ + gint i; + guint n_stock_icons = G_N_ELEMENTS(stock_icons); + + icon_factory = gtk_icon_factory_new(); + + for (i = 0; i < n_stock_icons; i++) { + stock_icon_register(stock_icons[i].filename, stock_icons[i].stock_id); + } + + gtk_icon_factory_add_default(icon_factory); + + g_object_unref(icon_factory); +} -- cgit v1.2.3