Be a little more explicit in our description of tvb_get_ptr.
[metze/wireshark/wip.git] / gtk / stock_icons.c
1 /* stock_icons.c
2  * Wireshark specific stock icons
3  * Copyright 2003-2008, Ulf Lamping <ulf.lamping@web.de>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <gtk/gtk.h>
31
32 #include "gtk/stock_icons.h"
33
34 /* these icons are derived from the original stock icons */
35 #ifdef HAVE_LIBPCAP
36 #include "../image/toolbar/capture_interfaces_24.xpm"
37 #include "../image/toolbar/capture_options_24.xpm"
38 #include "../image/toolbar/capture_start_24.xpm"
39 #include "../image/toolbar/capture_stop_24.xpm"
40 #include "../image/toolbar/capture_restart_24.xpm"
41 #include "../image/toolbar/capture_filter_24.xpm"
42 #include "../image/toolbar/capture_details_24.xpm"
43 #endif /* HAVE_LIBPCAP */
44 #include "../image/toolbar/display_filter_24.xpm"
45 #include "../image/wsicon16.xpm"
46 #include "../image/toolbar/colorize_24.xpm"
47 #include "../image/toolbar/autoscroll_24.xpm"
48 #include "../image/toolbar/resize_columns_24.xpm"
49 #include "../image/toolbar/time_24.xpm"
50 #include "../image/toolbar/internet_24.xpm"
51 #include "../image/toolbar/web_support_24.xpm"
52 #include "../image/toolbar/wiki_24.xpm"
53 #include "../image/toolbar/conversations_16.xpm"
54 #include "../image/toolbar/endpoints_16.xpm"
55 #include "../image/toolbar/expert_info_16.xpm"
56 #include "../image/toolbar/flow_graph_16.xpm"
57 #include "../image/toolbar/graphs_16.xpm"
58 #include "../image/toolbar/telephony_16.xpm"
59 #include "../image/toolbar/decode_as_16.xpm"
60 #include "../image/toolbar/checkbox_16.xpm"
61 #include "../image/toolbar/file_set_list_16.xpm"
62 #include "../image/toolbar/file_set_next_16.xpm"
63 #include "../image/toolbar/file_set_previous_16.xpm"
64 #include "../image/toolbar/icon_color_1.xpm"
65 #include "../image/toolbar/icon_color_2.xpm"
66 #include "../image/toolbar/icon_color_3.xpm"
67 #include "../image/toolbar/icon_color_4.xpm"
68 #include "../image/toolbar/icon_color_5.xpm"
69 #include "../image/toolbar/icon_color_6.xpm"
70 #include "../image/toolbar/icon_color_7.xpm"
71 #include "../image/toolbar/icon_color_8.xpm"
72 #include "../image/toolbar/icon_color_9.xpm"
73 #include "../image/toolbar/icon_color_0.xpm"
74
75
76 typedef struct stock_pixmap_tag{
77     const char *    name;
78     const char **   xpm_data;
79 } stock_pixmap_t;
80
81 /* generate application specific stock items */
82 void stock_icons_init(void) {
83     GtkIconFactory * factory;
84     gint32 i;
85     GdkPixbuf * pixbuf;
86     GtkIconSet *icon_set;
87
88
89     /* register non-standard pixmaps with the gtk-stock engine */
90     static const GtkStockItem stock_items[] = {
91 #ifdef HAVE_LIBPCAP
92         { WIRESHARK_STOCK_CAPTURE_INTERFACES,    "_Interfaces",    0, 0, NULL },
93         { WIRESHARK_STOCK_CAPTURE_OPTIONS,       "_Options",       0, 0, NULL },
94         { WIRESHARK_STOCK_CAPTURE_START,         "_Start",         0, 0, NULL },
95         { WIRESHARK_STOCK_CAPTURE_STOP,          "S_top",          0, 0, NULL },
96         { WIRESHARK_STOCK_CAPTURE_RESTART,       "_Restart",       0, 0, NULL },
97         { WIRESHARK_STOCK_CAPTURE_FILTER,        "_CFilter",        0, 0, NULL },
98         { WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY,  "_Capture Filter:",  0, 0, NULL },
99         { WIRESHARK_STOCK_CAPTURE_DETAILS,       "_Details",       0, 0, NULL },
100 #endif
101 #ifdef HAVE_GEOIP
102         { WIRESHARK_STOCK_MAP,                   "Map",                   0, 0, NULL },
103 #endif
104         { WIRESHARK_STOCK_DISPLAY_FILTER,        "_Filter",        0, 0, NULL },
105         { WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY,  "F_ilter:",  0, 0, NULL },
106         { WIRESHARK_STOCK_BROWSE,                "_Browse...",                0, 0, NULL },
107         { WIRESHARK_STOCK_CREATE_STAT,           "Create _Stat",           0, 0, NULL },
108         { WIRESHARK_STOCK_EXPORT,                "_Export...",                0, 0, NULL },
109         { WIRESHARK_STOCK_IMPORT,                "_Import...",                0, 0, NULL },
110         { WIRESHARK_STOCK_EDIT,                  "_Edit...",                  0, 0, NULL },
111         { WIRESHARK_STOCK_ADD_EXPRESSION,        "E_xpression..." ,        0, 0, NULL }, /* plus sign coming from icon */
112         { WIRESHARK_STOCK_CLEAR_EXPRESSION,      "Clea_r" ,                   0, 0, NULL },
113         { WIRESHARK_STOCK_APPLY_EXPRESSION,      "App_ly" ,                   0, 0, NULL },
114         { WIRESHARK_STOCK_SAVE_ALL,              "Save A_ll",             0, 0, NULL },
115         { WIRESHARK_STOCK_DONT_SAVE,             "Continue _without Saving",             0, 0, NULL },
116         { WIRESHARK_STOCK_QUIT_DONT_SAVE,        "Quit _without Saving",             0, 0, NULL },
117         { WIRESHARK_STOCK_ABOUT,                 "_About",                 0, 0, NULL },
118         { WIRESHARK_STOCK_COLORIZE,              "_Colorize",              0, 0, NULL },
119         { WIRESHARK_STOCK_AUTOSCROLL,            "_Auto Scroll in Live Capture",            0, 0, NULL },
120         { WIRESHARK_STOCK_RESIZE_COLUMNS,        "Resize Columns",        0, 0, NULL },
121         { WIRESHARK_STOCK_TIME,                  "Time",                  0, 0, NULL },
122         { WIRESHARK_STOCK_INTERNET,              "Internet",              0, 0, NULL },
123         { WIRESHARK_STOCK_WEB_SUPPORT,           "Web Support",           0, 0, NULL },
124         { WIRESHARK_STOCK_WIKI,                  "Wiki",                  0, 0, NULL },
125         { WIRESHARK_STOCK_CONVERSATIONS,         "Conversations",         0, 0, NULL },
126         { WIRESHARK_STOCK_ENDPOINTS,             "Endpoints",             0, 0, NULL },
127         { WIRESHARK_STOCK_EXPERT_INFO,           "Expert Info",           0, 0, NULL },
128         { WIRESHARK_STOCK_GRAPHS,                "Graphs",                0, 0, NULL },
129         { WIRESHARK_STOCK_FLOW_GRAPH,            "Flow Graph",            0, 0, NULL },
130         { WIRESHARK_STOCK_TELEPHONY,             "Telephony",             0, 0, NULL },
131         { WIRESHARK_STOCK_DECODE_AS,             "Decode As",             0, 0, NULL },
132         { WIRESHARK_STOCK_CHECKBOX,              "Checkbox",              0, 0, NULL },
133         { WIRESHARK_STOCK_FILE_SET_LIST,         "List Files",         0, 0, NULL },
134         { WIRESHARK_STOCK_FILE_SET_NEXT,         "Next File",         0, 0, NULL },
135         { WIRESHARK_STOCK_FILE_SET_PREVIOUS,     "Previous File",     0, 0, NULL },
136         { WIRESHARK_STOCK_FILTER_OUT_STREAM,     "Filter Out This Stream",     0, 0, NULL },
137         { WIRESHARK_STOCK_ENABLE,                "Enable",                0, 0, NULL },
138         { WIRESHARK_STOCK_DISABLE,               "Disable",               0, 0, NULL },
139         { WIRESHARK_STOCK_COLOR1,                "Color 1",                0, 0, NULL },
140         { WIRESHARK_STOCK_COLOR2,                "Color 2",                0, 0, NULL },
141         { WIRESHARK_STOCK_COLOR3,                "Color 3",                0, 0, NULL },
142         { WIRESHARK_STOCK_COLOR4,                "Color 4",                0, 0, NULL },
143         { WIRESHARK_STOCK_COLOR5,                "Color 5",                0, 0, NULL },
144         { WIRESHARK_STOCK_COLOR6,                "Color 6",                0, 0, NULL },
145         { WIRESHARK_STOCK_COLOR7,                "Color 7",                0, 0, NULL },
146         { WIRESHARK_STOCK_COLOR8,                "Color 8",                0, 0, NULL },
147         { WIRESHARK_STOCK_COLOR9,                "Color 9",                0, 0, NULL },
148         { WIRESHARK_STOCK_COLOR0,                "Color 10",                0, 0, NULL }
149     };
150
151     static const stock_pixmap_t pixmaps[] = {
152 #ifdef HAVE_LIBPCAP
153         { WIRESHARK_STOCK_CAPTURE_INTERFACES,    capture_interfaces_24_xpm },
154         { WIRESHARK_STOCK_CAPTURE_OPTIONS,       capture_options_24_xpm },
155         { WIRESHARK_STOCK_CAPTURE_START,         capture_start_24_xpm },
156         { WIRESHARK_STOCK_CAPTURE_STOP,          capture_stop_24_xpm },
157         { WIRESHARK_STOCK_CAPTURE_RESTART,       capture_restart_24_xpm },
158         { WIRESHARK_STOCK_CAPTURE_FILTER,        capture_filter_24_xpm },
159         { WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY,  capture_filter_24_xpm },
160         { WIRESHARK_STOCK_CAPTURE_DETAILS,       capture_details_24_xpm },
161 #endif
162 #ifdef HAVE_GEOIP
163         { WIRESHARK_STOCK_MAP,                   internet_24_xpm},
164 #endif
165         { WIRESHARK_STOCK_DISPLAY_FILTER,        display_filter_24_xpm },
166         { WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY,  display_filter_24_xpm },
167         { WIRESHARK_STOCK_ABOUT,                 wsicon16_xpm },
168         { WIRESHARK_STOCK_COLORIZE,              colorize_24_xpm },
169         { WIRESHARK_STOCK_AUTOSCROLL,            autoscroll_24_xpm },
170         { WIRESHARK_STOCK_RESIZE_COLUMNS,        resize_columns_24_xpm},
171         { WIRESHARK_STOCK_TIME,                  time_24_xpm},
172         { WIRESHARK_STOCK_INTERNET,              internet_24_xpm},
173         { WIRESHARK_STOCK_WEB_SUPPORT,           web_support_24_xpm},
174         { WIRESHARK_STOCK_WIKI,                  wiki_24_xpm},
175         { WIRESHARK_STOCK_CONVERSATIONS,         conversations_16_xpm},
176         { WIRESHARK_STOCK_ENDPOINTS,             endpoints_16_xpm},
177         { WIRESHARK_STOCK_EXPERT_INFO,           expert_info_16_xpm},
178         { WIRESHARK_STOCK_GRAPHS,                graphs_16_xpm},
179         { WIRESHARK_STOCK_FLOW_GRAPH,            flow_graph_16_xpm},
180         { WIRESHARK_STOCK_TELEPHONY,             telephony_16_xpm},
181         { WIRESHARK_STOCK_DECODE_AS,             decode_as_16_xpm},
182         { WIRESHARK_STOCK_CHECKBOX,              checkbox_16_xpm},
183         { WIRESHARK_STOCK_FILE_SET_LIST,         file_set_list_16_xpm},
184         { WIRESHARK_STOCK_FILE_SET_NEXT,         file_set_next_16_xpm},
185         { WIRESHARK_STOCK_FILE_SET_PREVIOUS,     file_set_previous_16_xpm},
186         { WIRESHARK_STOCK_FILTER_OUT_STREAM,     display_filter_24_xpm},
187         { WIRESHARK_STOCK_ENABLE,                checkbox_16_xpm},
188         { WIRESHARK_STOCK_COLOR1,                icon_color_1_xpm},
189         { WIRESHARK_STOCK_COLOR2,                icon_color_2_xpm},
190         { WIRESHARK_STOCK_COLOR3,                icon_color_3_xpm},
191         { WIRESHARK_STOCK_COLOR4,                icon_color_4_xpm},
192         { WIRESHARK_STOCK_COLOR5,                icon_color_5_xpm},
193         { WIRESHARK_STOCK_COLOR6,                icon_color_6_xpm},
194         { WIRESHARK_STOCK_COLOR7,                icon_color_7_xpm},
195         { WIRESHARK_STOCK_COLOR8,                icon_color_8_xpm},
196         { WIRESHARK_STOCK_COLOR9,                icon_color_9_xpm},
197         { WIRESHARK_STOCK_COLOR0,                icon_color_0_xpm},
198         { NULL, NULL }
199     };
200
201     /* Register our stock items */
202     gtk_stock_add (stock_items, G_N_ELEMENTS (stock_items));
203
204     /* Add our custom icon factory to the list of defaults */
205     factory = gtk_icon_factory_new();
206     gtk_icon_factory_add_default(factory);
207
208     /* Create the stock items to add into our icon factory */
209     for (i = 0; pixmaps[i].name != NULL; i++) {
210         /* The default icon */
211         pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) (pixmaps[i].xpm_data));
212         g_assert(pixbuf);
213         icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
214
215         /* XXX - add different sized icons here (some 16*16 icons look a bit blurred) */
216         /*gtk_icon_set_add_source(icon_set, const GtkIconSource *source);*/
217
218         gtk_icon_factory_add (factory, pixmaps[i].name, icon_set);
219         gtk_icon_set_unref (icon_set);
220         g_object_unref (G_OBJECT (pixbuf));
221     }
222
223     /* use default stock icons for Wireshark specifics where the icon metapher makes sense */
224     /* PLEASE DON'T REUSE STOCK ICONS IF THEY ARE USUALLY USED FOR SOME DIFFERENT MEANING!!!) */
225     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_OPEN);
226     gtk_icon_factory_add(factory, WIRESHARK_STOCK_BROWSE, icon_set);
227     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_OK);
228     gtk_icon_factory_add(factory, WIRESHARK_STOCK_CREATE_STAT, icon_set);
229     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_SAVE);
230     gtk_icon_factory_add(factory, WIRESHARK_STOCK_EXPORT, icon_set);    /* XXX: needs a better icon */
231     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_OPEN);
232     gtk_icon_factory_add(factory, WIRESHARK_STOCK_IMPORT, icon_set);    /* XXX: needs a better icon */
233     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_PROPERTIES);
234     gtk_icon_factory_add(factory, WIRESHARK_STOCK_EDIT, icon_set);
235     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_ADD);
236     gtk_icon_factory_add(factory, WIRESHARK_STOCK_ADD_EXPRESSION, icon_set);
237     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_CLEAR);
238     gtk_icon_factory_add(factory, WIRESHARK_STOCK_CLEAR_EXPRESSION, icon_set);
239     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_APPLY);
240     gtk_icon_factory_add(factory, WIRESHARK_STOCK_APPLY_EXPRESSION, icon_set);
241     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_CLEAR);
242     gtk_icon_factory_add(factory, WIRESHARK_STOCK_DONT_SAVE, icon_set);
243     gtk_icon_factory_add(factory, WIRESHARK_STOCK_QUIT_DONT_SAVE, icon_set);
244     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_SAVE);
245     gtk_icon_factory_add(factory, WIRESHARK_STOCK_SAVE_ALL, icon_set);  /* XXX: needs a better icon */
246     icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_CLOSE);
247     gtk_icon_factory_add(factory, WIRESHARK_STOCK_DISABLE, icon_set);
248
249     /* Drop our reference to the factory, GTK will hold a reference.*/
250     g_object_unref (G_OBJECT (factory));
251 }
252
253