summaryrefslogtreecommitdiff
path: root/gtk/stock_icons.c
blob: 7a825e3daf2418da18dd36db90e6c5534e03f896 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/* stock_icons.c
 * Wireshark specific stock icons
 * Copyright 2003-2008, Ulf Lamping <ulf.lamping@web.de>
 *
 * $Id$
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * 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; either version 2
 * of the License, or (at your option) any later version.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gtk/gtk.h>

#include "gtk/stock_icons.h"

/* these icons are derived from the original stock icons */
#include "../image/toolbar/capture_interfaces_24.xpm"
#include "../image/toolbar/capture_options_24.xpm"
#include "../image/toolbar/capture_start_24.xpm"
#include "../image/toolbar/capture_stop_24.xpm"
#include "../image/toolbar/capture_restart_24.xpm"
#include "../image/toolbar/capture_filter_24.xpm"
#include "../image/toolbar/capture_details_24.xpm"
#include "../image/toolbar/display_filter_24.xpm"
#include "../image/wsicon16.xpm"
#include "../image/toolbar/colorize_24.xpm"
#include "../image/toolbar/autoscroll_24.xpm"
#include "../image/toolbar/resize_columns_24.xpm"
#include "../image/toolbar/time_24.xpm"
#include "../image/toolbar/internet_24.xpm"
#include "../image/toolbar/web_support_24.xpm"
#include "../image/toolbar/wiki_24.xpm"
#include "../image/toolbar/conversations_16.xpm"
#include "../image/toolbar/endpoints_16.xpm"
#include "../image/toolbar/expert_info_16.xpm"
#include "../image/toolbar/flow_graph_16.xpm"
#include "../image/toolbar/graphs_16.xpm"
#include "../image/toolbar/telephony_16.xpm"
#include "../image/toolbar/decode_as_16.xpm"
#include "../image/toolbar/checkbox_16.xpm"
#include "../image/toolbar/file_set_list_16.xpm"
#include "../image/toolbar/file_set_next_16.xpm"
#include "../image/toolbar/file_set_previous_16.xpm"
#include "../image/toolbar/icon_color_1.xpm"
#include "../image/toolbar/icon_color_2.xpm"
#include "../image/toolbar/icon_color_3.xpm"
#include "../image/toolbar/icon_color_4.xpm"
#include "../image/toolbar/icon_color_5.xpm"
#include "../image/toolbar/icon_color_6.xpm"
#include "../image/toolbar/icon_color_7.xpm"
#include "../image/toolbar/icon_color_8.xpm"
#include "../image/toolbar/icon_color_9.xpm"
#include "../image/toolbar/icon_color_0.xpm"
#include "../image/toolbar/decode_24.xpm"
#include "../image/toolbar/audio_player_24.xpm"
#include "../image/toolbar/voip_flow_24.xpm"
#include "../image/toolbar/telephone_16.xpm"
#include "../image/toolbar/analyze_24.xpm"
#include "../image/WiresharkDoc_24.xpm"

typedef struct stock_pixmap_tag{
    const char *    name;
    const char **   xpm_data;
} stock_pixmap_t;

/* generate application specific stock items */
void stock_icons_init(void) {
    GtkIconFactory * factory;
    gint32 i;
    GdkPixbuf * pixbuf;
    GtkIconSet *icon_set;


    /* register non-standard pixmaps with the gtk-stock engine */
    static const GtkStockItem stock_items[] = {
        { WIRESHARK_STOCK_CAPTURE_INTERFACES,    "_Interfaces",    0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_OPTIONS,       "_Options",       0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_START,         "_Start",         0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_STOP,          "S_top",          0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_RESTART,       "_Restart",       0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_FILTER,        "_Capture Filter",   0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY,  "_Capture Filter:",  0, 0, NULL },
        { WIRESHARK_STOCK_CAPTURE_DETAILS,       "_Details",       0, 0, NULL },
#ifdef HAVE_GEOIP
        { WIRESHARK_STOCK_MAP,                   "Map",                   0, 0, NULL },
#endif
        { WIRESHARK_STOCK_FOLLOW_STREAM,         "Follow Stream",         0, 0, NULL },
        { WIRESHARK_STOCK_DISPLAY_FILTER,        "Display _Filter",       0, 0, NULL },
        { WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY,  "F_ilter:",  0, 0, NULL },
        { WIRESHARK_STOCK_BROWSE,                "_Browse...",                0, 0, NULL },
        { WIRESHARK_STOCK_CREATE_STAT,           "Create _Stat",           0, 0, NULL },
        { WIRESHARK_STOCK_EXPORT,                "_Export...",                0, 0, NULL },
        { WIRESHARK_STOCK_IMPORT,                "_Import...",                0, 0, NULL },
        { WIRESHARK_STOCK_EDIT,                  "_Edit...",                  0, 0, NULL },
        { WIRESHARK_STOCK_ADD_EXPRESSION,        "E_xpression..." ,        0, 0, NULL }, /* plus sign coming from icon */
        { WIRESHARK_STOCK_CLEAR_EXPRESSION,      "Clea_r" ,                   0, 0, NULL },
        { WIRESHARK_STOCK_APPLY_EXPRESSION,      "App_ly" ,                   0, 0, NULL },
        { WIRESHARK_STOCK_SAVE_ALL,              "Save A_ll",             0, 0, NULL },
        { WIRESHARK_STOCK_DONT_SAVE,             "Continue _without Saving",             0, 0, NULL },
        { WIRESHARK_STOCK_QUIT_DONT_SAVE,        "Quit _without Saving",             0, 0, NULL },
        { WIRESHARK_STOCK_ABOUT,                 "_About",                 0, 0, NULL },
        { WIRESHARK_STOCK_COLORIZE,              "_Colorize",              0, 0, NULL },
        { WIRESHARK_STOCK_AUTOSCROLL,            "_Auto Scroll",            0, 0, NULL },
        { WIRESHARK_STOCK_RESIZE_COLUMNS,        "Resize Columns",        0, 0, NULL },
        { WIRESHARK_STOCK_TIME,                  "Time",                  0, 0, NULL },
        { WIRESHARK_STOCK_INTERNET,              "Internet",              0, 0, NULL },
        { WIRESHARK_STOCK_WEB_SUPPORT,           "Web Support",           0, 0, NULL },
        { WIRESHARK_STOCK_WIKI,                  "Wiki",                  0, 0, NULL },
        { WIRESHARK_STOCK_CONVERSATIONS,         "Conversations",         0, 0, NULL },
        { WIRESHARK_STOCK_ENDPOINTS,             "Endpoints",             0, 0, NULL },
        { WIRESHARK_STOCK_EXPERT_INFO,           "Expert Info",           0, 0, NULL },
        { WIRESHARK_STOCK_GRAPHS,                "Graphs",                0, 0, NULL },
        { WIRESHARK_STOCK_FLOW_GRAPH,            "Flow Graph",            0, 0, NULL },
        { WIRESHARK_STOCK_TELEPHONY,             "Telephony",             0, 0, NULL },
        { WIRESHARK_STOCK_DECODE_AS,             "Decode As",             0, 0, NULL },
        { WIRESHARK_STOCK_CHECKBOX,              "Checkbox",              0, 0, NULL },
        { WIRESHARK_STOCK_FILE_SET_LIST,         "List Files",         0, 0, NULL },
        { WIRESHARK_STOCK_FILE_SET_NEXT,         "Next File",         0, 0, NULL },
        { WIRESHARK_STOCK_FILE_SET_PREVIOUS,     "Previous File",     0, 0, NULL },
        { WIRESHARK_STOCK_FILTER_OUT_STREAM,     "Filter Out This Stream",     0, 0, NULL },
        { WIRESHARK_STOCK_ENABLE,                "Enable",                0, 0, NULL },
        { WIRESHARK_STOCK_DISABLE,               "Disable",               0, 0, NULL },
        { WIRESHARK_STOCK_COLOR1,                "Color 1",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR2,                "Color 2",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR3,                "Color 3",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR4,                "Color 4",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR5,                "Color 5",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR6,                "Color 6",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR7,                "Color 7",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR8,                "Color 8",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR9,                "Color 9",                0, 0, NULL },
        { WIRESHARK_STOCK_COLOR0,                "Color 10",               0, 0, NULL },
        { WIRESHARK_STOCK_DECODE,                "Decode",                 0, 0, NULL },
        { WIRESHARK_STOCK_AUDIO_PLAYER,          "Player",                 0, 0, NULL },
        { WIRESHARK_STOCK_VOIP_FLOW,             "Flow",                   0, 0, NULL },
        { WIRESHARK_STOCK_TELEPHONE,             "Telephone",              0, 0, NULL },
        { WIRESHARK_STOCK_PREPARE_FILTER,        "Prepare Filter",         0, 0, NULL },
        { WIRESHARK_STOCK_ANALYZE,               "Analyze",                0, 0, NULL },
		{ WIRESHARK_STOCK_FILE,                  "File",                   0, 0, NULL }
    };

    static const stock_pixmap_t pixmaps[] = {
        { WIRESHARK_STOCK_CAPTURE_INTERFACES,    capture_interfaces_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_OPTIONS,       capture_options_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_START,         capture_start_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_STOP,          capture_stop_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_RESTART,       capture_restart_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_FILTER,        capture_filter_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY,  capture_filter_24_xpm },
        { WIRESHARK_STOCK_CAPTURE_DETAILS,       capture_details_24_xpm },
#ifdef HAVE_GEOIP
        { WIRESHARK_STOCK_MAP,                   internet_24_xpm},
#endif
        { WIRESHARK_STOCK_DISPLAY_FILTER,        display_filter_24_xpm },
        { WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY,  display_filter_24_xpm },
        { WIRESHARK_STOCK_ABOUT,                 wsicon16_xpm },
        { WIRESHARK_STOCK_COLORIZE,              colorize_24_xpm },
        { WIRESHARK_STOCK_AUTOSCROLL,            autoscroll_24_xpm },
        { WIRESHARK_STOCK_RESIZE_COLUMNS,        resize_columns_24_xpm},
        { WIRESHARK_STOCK_TIME,                  time_24_xpm},
        { WIRESHARK_STOCK_INTERNET,              internet_24_xpm},
        { WIRESHARK_STOCK_WEB_SUPPORT,           web_support_24_xpm},
        { WIRESHARK_STOCK_WIKI,                  wiki_24_xpm},
        { WIRESHARK_STOCK_CONVERSATIONS,         conversations_16_xpm},
        { WIRESHARK_STOCK_ENDPOINTS,             endpoints_16_xpm},
        { WIRESHARK_STOCK_EXPERT_INFO,           expert_info_16_xpm},
        { WIRESHARK_STOCK_GRAPHS,                graphs_16_xpm},
        { WIRESHARK_STOCK_FLOW_GRAPH,            flow_graph_16_xpm},
        { WIRESHARK_STOCK_TELEPHONY,             telephony_16_xpm},
        { WIRESHARK_STOCK_DECODE_AS,             decode_as_16_xpm},
        { WIRESHARK_STOCK_CHECKBOX,              checkbox_16_xpm},
        { WIRESHARK_STOCK_FILE_SET_LIST,         file_set_list_16_xpm},
        { WIRESHARK_STOCK_FILE_SET_NEXT,         file_set_next_16_xpm},
        { WIRESHARK_STOCK_FILE_SET_PREVIOUS,     file_set_previous_16_xpm},
        { WIRESHARK_STOCK_FILTER_OUT_STREAM,     display_filter_24_xpm},
        { WIRESHARK_STOCK_ENABLE,                checkbox_16_xpm},
        { WIRESHARK_STOCK_COLOR1,                icon_color_1_xpm},
        { WIRESHARK_STOCK_COLOR2,                icon_color_2_xpm},
        { WIRESHARK_STOCK_COLOR3,                icon_color_3_xpm},
        { WIRESHARK_STOCK_COLOR4,                icon_color_4_xpm},
        { WIRESHARK_STOCK_COLOR5,                icon_color_5_xpm},
        { WIRESHARK_STOCK_COLOR6,                icon_color_6_xpm},
        { WIRESHARK_STOCK_COLOR7,                icon_color_7_xpm},
        { WIRESHARK_STOCK_COLOR8,                icon_color_8_xpm},
        { WIRESHARK_STOCK_COLOR9,                icon_color_9_xpm},
        { WIRESHARK_STOCK_COLOR0,                icon_color_0_xpm},
        { WIRESHARK_STOCK_DECODE,                decode_24_xpm},
        { WIRESHARK_STOCK_AUDIO_PLAYER,          audio_player_24_xpm},
        { WIRESHARK_STOCK_VOIP_FLOW,             voip_flow_24_xpm},
        { WIRESHARK_STOCK_TELEPHONE,             telephone_16_xpm},
        { WIRESHARK_STOCK_PREPARE_FILTER,        display_filter_24_xpm},
        { WIRESHARK_STOCK_ANALYZE,               analyze_24_xpm},
		{ WIRESHARK_STOCK_FILE,                  WiresharkDoc_24_xpm},
        { NULL, NULL }
    };

    /* Register our stock items */
    gtk_stock_add (stock_items, G_N_ELEMENTS (stock_items));

    /* Add our custom icon factory to the list of defaults */
    factory = gtk_icon_factory_new();
    gtk_icon_factory_add_default(factory);

    /* Create the stock items to add into our icon factory */
    for (i = 0; pixmaps[i].name != NULL; i++) {
        /* The default icon */
        pixbuf = gdk_pixbuf_new_from_xpm_data((const char **) (pixmaps[i].xpm_data));
        g_assert(pixbuf);
        icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);

        /* XXX - add different sized icons here (some 16*16 icons look a bit blurred) */
        /*gtk_icon_set_add_source(icon_set, const GtkIconSource *source);*/

        gtk_icon_factory_add (factory, pixmaps[i].name, icon_set);
        gtk_icon_set_unref (icon_set);
        g_object_unref (G_OBJECT (pixbuf));
    }

    /* use default stock icons for Wireshark specifics where the icon metapher makes sense */
    /* PLEASE DON'T REUSE STOCK ICONS IF THEY ARE USUALLY USED FOR SOME DIFFERENT MEANING!!!) */
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_OPEN);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_BROWSE, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_OK);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_CREATE_STAT, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_SAVE);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_EXPORT, icon_set);    /* XXX: needs a better icon */
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_OPEN);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_IMPORT, icon_set);    /* XXX: needs a better icon */
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_PROPERTIES);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_EDIT, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_ADD);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_ADD_EXPRESSION, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_CLEAR);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_CLEAR_EXPRESSION, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_APPLY);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_APPLY_EXPRESSION, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_CLEAR);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_DONT_SAVE, icon_set);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_QUIT_DONT_SAVE, icon_set);
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_SAVE);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_SAVE_ALL, icon_set);  /* XXX: needs a better icon */
    icon_set = gtk_icon_factory_lookup_default(GTK_STOCK_CLOSE);
    gtk_icon_factory_add(factory, WIRESHARK_STOCK_DISABLE, icon_set);

    /* Drop our reference to the factory, GTK will hold a reference.*/
    g_object_unref (G_OBJECT (factory));
}