]> git.sur5r.net Git - glabels/blob - glabels2/src/stock.c
Initial revision
[glabels] / glabels2 / src / stock.c
1 /*
2  *  (GLABELS) Label and Business Card Creation program for GNOME
3  *
4  *  stock.h:  Stock image module header file
5  *
6  *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 #include <config.h>
24 #include <gnome.h>
25 #include <gdk-pixbuf/gdk-pixdata.h>
26 #include "stock.h"
27 #include "stock-pixmaps/stockpixbufs.h"
28
29 void
30 gl_stock_init (void)
31 {
32         GdkPixbuf *pixbuf;
33         GtkIconFactory *factory;
34         GtkIconSet *icon_set;
35         GdkPixdata *pixdata;
36
37         static GtkStockItem items[] = {
38                 { GL_STOCK_ARROW,   "Arrow",   0, 0, NULL },
39                 { GL_STOCK_TEXT,    "Text",    0, 0, NULL },
40                 { GL_STOCK_LINE,    "Line",    0, 0, NULL },
41                 { GL_STOCK_BOX,     "Box",     0, 0, NULL },
42                 { GL_STOCK_ELLIPSE, "Ellipse", 0, 0, NULL },
43                 { GL_STOCK_IMAGE,   "Image",   0, 0, NULL },
44                 { GL_STOCK_BARCODE, "Barcode", 0, 0, NULL },
45                 { GL_STOCK_MERGE,   "Merge",   0, 0, NULL },
46         };
47
48         gtk_stock_add (items, G_N_ELEMENTS (items));
49
50         factory = gtk_icon_factory_new ();
51         gtk_icon_factory_add_default (factory);
52
53         pixdata = g_new0 (GdkPixdata, 1);
54
55         /* Arrow */
56         gdk_pixdata_deserialize (pixdata,
57                                  sizeof(stock_arrow_24), stock_arrow_24,
58                                  NULL);
59         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
60         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
61         gtk_icon_factory_add (factory, GL_STOCK_ARROW, icon_set);
62         gtk_icon_set_unref (icon_set);
63         g_object_unref (G_OBJECT(pixbuf));
64
65         /* Text */
66         gdk_pixdata_deserialize (pixdata,
67                                  sizeof(stock_text_24), stock_text_24,
68                                  NULL);
69         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
70         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
71         gtk_icon_factory_add (factory, GL_STOCK_TEXT, icon_set);
72         gtk_icon_set_unref (icon_set);
73         g_object_unref (G_OBJECT(pixbuf));
74
75         /* Line */
76         gdk_pixdata_deserialize (pixdata,
77                                  sizeof(stock_line_24), stock_line_24,
78                                  NULL);
79         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
80         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
81         gtk_icon_factory_add (factory, GL_STOCK_LINE, icon_set);
82         gtk_icon_set_unref (icon_set);
83         g_object_unref (G_OBJECT(pixbuf));
84
85         /* Box */
86         gdk_pixdata_deserialize (pixdata,
87                                  sizeof(stock_box_24), stock_box_24,
88                                  NULL);
89         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
90         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
91         gtk_icon_factory_add (factory, GL_STOCK_BOX, icon_set);
92         gtk_icon_set_unref (icon_set);
93         g_object_unref (G_OBJECT(pixbuf));
94
95         /* Ellipse */
96         gdk_pixdata_deserialize (pixdata,
97                                  sizeof(stock_ellipse_24), stock_ellipse_24,
98                                  NULL);
99         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
100         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
101         gtk_icon_factory_add (factory, GL_STOCK_ELLIPSE, icon_set);
102         gtk_icon_set_unref (icon_set);
103         g_object_unref (G_OBJECT(pixbuf));
104
105         /* Image */
106         gdk_pixdata_deserialize (pixdata,
107                                  sizeof(stock_image_24), stock_image_24,
108                                  NULL);
109         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
110         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
111         gtk_icon_factory_add (factory, GL_STOCK_IMAGE, icon_set);
112         gtk_icon_set_unref (icon_set);
113         g_object_unref (G_OBJECT(pixbuf));
114
115         /* Barcode */
116         gdk_pixdata_deserialize (pixdata,
117                                  sizeof(stock_barcode_24), stock_barcode_24,
118                                  NULL);
119         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
120         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
121         gtk_icon_factory_add (factory, GL_STOCK_BARCODE, icon_set);
122         gtk_icon_set_unref (icon_set);
123         g_object_unref (G_OBJECT(pixbuf));
124
125         /* Merge */
126         gdk_pixdata_deserialize (pixdata,
127                                  sizeof(stock_merge_24), stock_merge_24,
128                                  NULL);
129         pixbuf = gdk_pixbuf_from_pixdata (pixdata, FALSE, NULL);
130         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
131         gtk_icon_factory_add (factory, GL_STOCK_MERGE, icon_set);
132         gtk_icon_set_unref (icon_set);
133         g_object_unref (G_OBJECT(pixbuf));
134
135         g_free (pixdata);
136         g_object_unref (G_OBJECT(factory));
137 }