aboutsummaryrefslogtreecommitdiff
path: root/shell/stock.c
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2024-04-22 00:35:56 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2024-04-22 00:35:56 -0300
commit754b5d1114f096778e483f8a6f3a5dc333225e26 (patch)
tree30911ec9da4cfd2f5572c27f7288fcbfa4cd212d /shell/stock.c
parent35c2857da302ab8b3c308052f2cd1674fb4141a6 (diff)
parent5f01c706267c595de92406a32e7f31ef5056c2d0 (diff)
Update upstream source from tag 'upstream/2.0.3pre'
Update to upstream version '2.0.3pre' with Debian dir 6683980bf6b5c02f6847fd56765833301f75f4f3
Diffstat (limited to 'shell/stock.c')
-rw-r--r--shell/stock.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/shell/stock.c b/shell/stock.c
new file mode 100644
index 00000000..27b2eedb
--- /dev/null
+++ b/shell/stock.c
@@ -0,0 +1,93 @@
+/*
+ * HardInfo - Displays System Information
+ * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br>
+ *
+ * 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 or later.
+ *
+ * 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 <config.h>
+#include <gtk/gtk.h>
+#include <stock.h>
+#include <iconcache.h>
+
+static struct {
+ gchar *filename;
+ gchar *stock_id;
+} stock_icons[] = {
+ { "clipboard.png", HI_STOCK_CLIPBOARD},
+ { "refresh.png", HI_STOCK_REFRESH},
+ { "report.png", HI_STOCK_REPORT},
+ { "internet.png", HI_STOCK_INTERNET},
+ { "module.png", HI_STOCK_MODULE},
+ { "about-modules.png", HI_STOCK_ABOUT_MODULES},
+ { "server_sync.png", HI_STOCK_SYNC_MENU},
+ { "face-grin.png", HI_STOCK_DONATE},
+ { "server.png", HI_STOCK_SERVER},
+};
+
+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)
+{
+ guint i;
+ guint n_stock_icons = G_N_ELEMENTS(stock_icons);
+
+ DEBUG("initializing 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);
+}