6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/packet.h>
34 #include <epan/addr_resolv.h>
35 #include <epan/prefs.h>
36 #include <epan/prefs-int.h>
38 #include <epan/timestamp.h>
39 #include <epan/etypes.h>
40 #include <epan/ipproto.h>
41 #include <epan/dissector_filters.h>
42 #include <epan/strutil.h>
43 #include <epan/plugins.h>
44 #include <epan/epan_dissect.h>
47 #include "../register.h"
48 #include "../ui_util.h"
49 #include "../simple_dialog.h"
50 #include "../color_filters.h"
51 #include "../stat_menu.h"
53 #include "gtk/about_dlg.h"
54 #include "gtk/capture_dlg.h"
55 #include "gtk/capture_if_dlg.h"
56 #include "gtk/color_dlg.h"
57 #include "gtk/filter_dlg.h"
58 #include "gtk/profile_dlg.h"
59 #include "gtk/dlg_utils.h"
60 #include "gtk/capture_file_dlg.h"
61 #include "gtk/fileset_dlg.h"
62 #include "gtk/find_dlg.h"
63 #include "gtk/goto_dlg.h"
64 #include "gtk/summary_dlg.h"
65 #include "gtk/prefs_dlg.h"
66 #include "gtk/packet_win.h"
67 #include "gtk/follow_tcp.h"
68 #include "gtk/follow_udp.h"
69 #include "gtk/follow_ssl.h"
70 #include "gtk/decode_as_dlg.h"
71 #include "gtk/help_dlg.h"
72 #include "gtk/supported_protos_dlg.h"
73 #include "gtk/proto_dlg.h"
74 #include "gtk/proto_hier_stats_dlg.h"
76 #include "gtk/stock_icons.h"
77 #include "gtk/gtkglobals.h"
78 #include "gtk/recent.h"
79 #include "gtk/main_proto_draw.h"
80 #include "gtk/conversations_table.h"
81 #include "gtk/hostlist_table.h"
82 #include "gtk/packet_history.h"
83 #include "gtk/sctp_stat.h"
84 #include "gtk/firewall_dlg.h"
86 #include "gtk/macros_dlg.h"
87 #include "gtk/export_object.h"
88 #include "gtk/gui_stat_menu.h"
90 #include "gtk/main_menu.h"
91 #include "gtk/main_packet_list.h"
92 #include "gtk/main_toolbar.h"
93 #include "gtk/main_welcome.h"
94 #include "gtk/uat_gui.h"
96 #ifdef HAVE_IGE_MAC_INTEGRATION
97 #include <ige-mac-menu.h>
100 typedef struct _menu_item {
103 const char *stock_id;
105 GtkItemFactoryCallback callback;
106 gpointer callback_data;
107 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data);
108 gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data);
112 static GList *tap_menu_tree_root = NULL;
114 GtkWidget *popup_menu_object;
117 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
119 static void merge_all_tap_menus(GList *node);
120 static void clear_menu_recent_capture_file_cmd_cb(GtkWidget *w, gpointer unused _U_);
122 static void menus_init(void);
123 static void set_menu_sensitivity (GtkItemFactory *, const gchar *, gint);
124 static void show_hide_cb(GtkWidget *w, gpointer data, gint action);
125 static void timestamp_format_cb(GtkWidget *w, gpointer d, gint action);
126 static void timestamp_precision_cb(GtkWidget *w, gpointer d, gint action);
127 static void name_resolution_cb(GtkWidget *w, gpointer d, gint action);
129 static void auto_scroll_live_cb(GtkWidget *w, gpointer d);
131 static void colorize_cb(GtkWidget *w, gpointer d);
134 /* This is the GtkItemFactoryEntry structure used to generate new menus.
135 Item 1: The menu path. The letter after the underscore indicates an
136 accelerator key once the menu is open.
137 Item 2: The accelerator key for the entry
138 Item 3: The callback function.
139 Item 4: The callback action. This changes the parameters with
140 which the function is called. The default is 0.
141 Item 5: The item type, used to define what kind of an item it is.
142 Here are the possible values:
146 "<Title>" -> create a title item
147 "<Item>" -> create a simple item
148 "<ImageItem>" -> create an item holding an image (gtk2)
149 "<StockItem>" -> create an item holding a stock image (gtk2)
150 "<CheckItem>" -> create a check item
151 "<ToggleItem>" -> create a toggle item
152 "<RadioItem>" -> create a radio item
153 <path> -> path of a radio item to link against
154 "<Separator>" -> create a separator
155 "<Tearoff>" -> create a tearoff separator (gtk2)
156 "<Branch>" -> create an item to hold sub items (optional)
157 "<LastBranch>" -> create a right justified branch
158 Item 6: extra data needed for ImageItem and StockItem (gtk2)
161 /* As a general GUI guideline, we try to follow the Gnome Human Interface Guidelines, which can be found at:
162 http://developer.gnome.org/projects/gup/hig/1.0/index.html
164 Please note: there are some differences between the Gnome HIG menu suggestions and our implementation:
166 File/Open Recent: the Gnome HIG suggests putting the list of recently used files as elements into the File menuitem.
167 As this is ok for only a few items, this will become unhandy for 10 or even more list entries.
168 For this reason, we use a submenu for this.
170 File/Close: the Gnome HIG suggests putting this item just above the Quit item.
171 This results in unintuitive behaviour as both Close and Quit items are very near together.
172 By putting the Close item near the open item(s), it better suggests that it will close the
173 currently opened/captured file only.
177 SHOW_HIDE_MAIN_TOOLBAR = 1,
178 SHOW_HIDE_FILTER_TOOLBAR,
179 SHOW_HIDE_AIRPCAP_TOOLBAR,
181 SHOW_HIDE_PACKET_LIST,
184 } show_hide_values_e;
195 build_conversation_filter(int action, gboolean show_dialog)
197 packet_info *pi = &cfile.edt->pi;
203 if (pi->profinet_type == 0) {
205 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
206 "Error filtering conversation. Please make\n"
207 "sure you have a PROFINET CBA packet selected.");
212 if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4
213 && pi->ipproto == IP_PROTO_TCP ) {
215 switch(pi->profinet_type) {
217 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 0)",
218 ip_to_str( pi->net_dst.data),
219 ip_to_str( pi->net_src.data),
220 ip_to_str( pi->net_src.data),
221 ip_to_str( pi->net_dst.data));
224 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.dcom == 0)",
225 ip_to_str( pi->net_src.data),
226 ip_to_str( pi->net_dst.data),
227 ip_to_str( pi->net_dst.data),
228 ip_to_str( pi->net_src.data));
231 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.srt == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.srt == 0)",
232 ip_to_str( pi->net_dst.data),
233 ip_to_str( pi->net_src.data),
234 ip_to_str( pi->net_src.data),
235 ip_to_str( pi->net_dst.data));
238 buf = g_strdup_printf("(ip.src eq %s and ip.dst eq %s and cba.acco.srt == 1) || (ip.src eq %s and ip.dst eq %s and cba.acco.srt == 0)",
239 ip_to_str( pi->net_src.data),
240 ip_to_str( pi->net_dst.data),
241 ip_to_str( pi->net_dst.data),
242 ip_to_str( pi->net_src.data));
252 if (pi->ipproto != IP_PROTO_TCP) {
254 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
255 "Error filtering conversation. Please make\n"
256 "sure you have a TCP packet selected.");
261 if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
263 buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
264 ip_to_str( pi->net_src.data),
265 ip_to_str( pi->net_dst.data),
266 pi->srcport, pi->destport );
267 } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
269 buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
270 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
271 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
272 pi->srcport, pi->destport );
278 if (pi->ipproto != IP_PROTO_UDP) {
280 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
281 "Error filtering conversation. Please make\n"
282 "sure you have a UDP packet selected.");
287 if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
289 buf = g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (udp.port eq %d and udp.port eq %d)",
290 ip_to_str( pi->net_src.data),
291 ip_to_str( pi->net_dst.data),
292 pi->srcport, pi->destport );
293 } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
295 buf = g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (udp.port eq %d and udp.port eq %d)",
296 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
297 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
298 pi->srcport, pi->destport );
304 if ((pi->ethertype != ETHERTYPE_IP) && (pi->ethertype != ETHERTYPE_IPv6)) {
306 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
307 "Error filtering conversation. Please make\n"
308 "sure you have a IP packet selected.");
313 if( pi->net_src.type == AT_IPv4 && pi->net_dst.type == AT_IPv4 ) {
315 buf = g_strdup_printf("ip.addr eq %s and ip.addr eq %s",
316 ip_to_str( pi->net_src.data),
317 ip_to_str( pi->net_dst.data));
318 } else if( pi->net_src.type == AT_IPv6 && pi->net_dst.type == AT_IPv6 ) {
320 buf = g_strdup_printf("ipv6.addr eq %s and ipv6.addr eq %s",
321 ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
322 ip6_to_str((const struct e_in6_addr *)pi->net_dst.data));
328 /* XXX - is this the right way to check for Ethernet? */
329 /* check for the data link address type */
330 /* (ethertype will be 0 when used as length field) */
331 if (pi->dl_src.type != AT_ETHER) {
333 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
334 "Error filtering conversation. Please make\n"
335 "sure you have a Ethernet packet selected.");
340 if( pi->dl_src.type == AT_ETHER && pi->dl_dst.type == AT_ETHER ) {
342 buf = g_strdup_printf("eth.addr eq %s and eth.addr eq %s",
343 ether_to_str( pi->dl_src.data),
344 ether_to_str( pi->dl_dst.data));
357 conversation_cb(GtkWidget * w, gpointer data _U_, int action)
360 GtkWidget *filter_te;
362 if (cfile.current_frame) {
363 /* create a filter-string based on the selected packet and action */
364 filter = build_conversation_filter(action, TRUE);
366 /* Run the display filter so it goes in effect - even if it's the
367 same as the previous display filter. */
368 filter_te = g_object_get_data(G_OBJECT(w), E_DFILTER_TE_KEY);
369 gtk_entry_set_text(GTK_ENTRY(filter_te), filter);
370 main_filter_packets(&cfile, filter, TRUE);
377 colorize_conversation_cb(GtkWidget * w _U_, gpointer data _U_, int action)
379 gchar *filter = NULL;
381 if( (action>>8) == 255 ) {
382 color_filters_reset_tmp();
383 cf_colorize_packets(&cfile);
384 } else if (cfile.current_frame) {
385 if( (action&0xff) == 0 ) {
386 /* colorize_conversation_cb was called from the window-menu
387 * or through an accelerator key. Try to build a conversation
388 * filter in the order TCP, UDP, IP, Ethernet and apply the
390 filter = build_conversation_filter(CONV_TCP,FALSE);
392 filter = build_conversation_filter(CONV_UDP,FALSE);
394 filter = build_conversation_filter(CONV_IP,FALSE);
396 filter = build_conversation_filter(CONV_ETHER,FALSE);
397 if( filter == NULL ) {
398 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Unable to build conversation filter.");
402 /* create a filter-string based on the selected packet and action */
403 filter = build_conversation_filter(action&0xff, TRUE);
406 if( (action>>8) == 0) {
407 /* Open the "new coloring filter" dialog with the filter */
408 color_display_with_filter(filter);
410 /* Set one of the temporary coloring filters */
411 color_filters_set_tmp((guint8)(action>>8),filter,FALSE);
412 cf_colorize_packets(&cfile);
420 static GtkItemFactoryEntry menu_items[] =
422 {"/_File", NULL, NULL, 0, "<Branch>", NULL,},
423 {"/File/_Open...", "<control>O", GTK_MENU_FUNC(file_open_cmd_cb),
424 0, "<StockItem>", GTK_STOCK_OPEN,},
425 {"/File/Open _Recent", NULL, NULL, 0, "<Branch>", NULL,},
426 {"/File/_Merge...", NULL, GTK_MENU_FUNC(file_merge_cmd_cb), 0, NULL, NULL,},
427 {"/File/_Close", "<control>W", GTK_MENU_FUNC(file_close_cmd_cb),
428 0, "<StockItem>", GTK_STOCK_CLOSE,},
429 {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
430 {"/File/_Save", "<control>S", GTK_MENU_FUNC(file_save_cmd_cb),
431 0, "<StockItem>", GTK_STOCK_SAVE,},
432 {"/File/Save _As...", "<shift><control>S", GTK_MENU_FUNC(file_save_as_cmd_cb),
433 0, "<StockItem>", GTK_STOCK_SAVE_AS,},
434 {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
435 {"/File/File Set", NULL, NULL, 0, "<Branch>", NULL,},
436 {"/File/File Set/List Files", NULL, GTK_MENU_FUNC(fileset_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_LIST,},
437 {"/File/File Set/Next File", NULL, GTK_MENU_FUNC(fileset_next_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_NEXT,},
438 {"/File/File Set/Previous File", NULL, GTK_MENU_FUNC(fileset_previous_cb), 0, "<StockItem>", WIRESHARK_STOCK_FILE_SET_PREVIOUS,},
439 {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
440 {"/File/_Export", NULL, NULL, 0, "<Branch>", NULL,},
442 {"/File/Export/File...", NULL, GTK_MENU_FUNC(export_text_cmd_cb),
445 {"/File/Export/as \"Plain _Text\" file...", NULL, GTK_MENU_FUNC(export_text_cmd_cb),
447 {"/File/Export/as \"_PostScript\" file...", NULL, GTK_MENU_FUNC(export_ps_cmd_cb),
449 {"/File/Export/as \"_CSV\" (Comma Separated Values packet summary) file...",
450 NULL, GTK_MENU_FUNC(export_csv_cmd_cb), 0, NULL, NULL,},
451 {"/File/Export/as \"C _Arrays\" (packet bytes) file...", NULL, GTK_MENU_FUNC(export_carrays_cmd_cb),
453 {"/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
454 {"/File/Export/as XML - \"P_SML\" (packet summary) file...", NULL, GTK_MENU_FUNC(export_psml_cmd_cb),
456 {"/File/Export/as XML - \"P_DML\" (packet details) file...", NULL, GTK_MENU_FUNC(export_pdml_cmd_cb),
458 {"/File/Export/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
460 {"/File/Export/Selected Packet _Bytes...", "<control>H", GTK_MENU_FUNC(savehex_cb),
462 {"/File/Export/_Objects/_HTTP", NULL, GTK_MENU_FUNC(eo_http_cb), 0, NULL, NULL,},
463 {"/File/Export/_Objects/_DICOM", NULL, GTK_MENU_FUNC(eo_dicom_cb), 0, NULL, NULL,},
465 {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
466 {"/File/_Print...", "<control>P", GTK_MENU_FUNC(file_print_cmd_cb),
467 0, "<StockItem>", GTK_STOCK_PRINT,},
468 {"/File/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
469 {"/File/_Quit", "<control>Q", GTK_MENU_FUNC(file_quit_cmd_cb),
470 0, "<StockItem>", GTK_STOCK_QUIT,},
471 {"/_Edit", NULL, NULL, 0, "<Branch>", NULL,},
472 {"/Edit/Copy", NULL, NULL, 0, "<Branch>", NULL,},
473 {"/Edit/Copy/As Filter", "<shift><control>C", GTK_MENU_FUNC(match_selected_ptree_cb),
474 MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,},
476 /* Un-#if this when we actually implement Cut/Copy/Paste. */
477 {"/Edit/Cut", "<control>X", NULL,
478 0, "<StockItem>", GTK_STOCK_CUT,},
479 {"/Edit/Copy", "<control>C", NULL,
480 0, "<StockItem>", GTK_STOCK_COPY,},
481 {"/Edit/Paste", "<control>V", NULL,
482 0, "<StockItem>", GTK_STOCK_PASTE,},
484 {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
485 {"/Edit/_Find Packet...", "<control>F",
486 GTK_MENU_FUNC(find_frame_cb), 0, "<StockItem>", GTK_STOCK_FIND,},
487 {"/Edit/Find Ne_xt", "<control>N", GTK_MENU_FUNC(find_next_cb), 0, NULL, NULL,},
488 {"/Edit/Find Pre_vious", "<control>B", GTK_MENU_FUNC(find_previous_cb), 0, NULL, NULL,},
489 {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
490 {"/Edit/_Mark Packet (toggle)", "<control>M", GTK_MENU_FUNC(packet_list_mark_frame_cb),
492 {"/Edit/Find Next Mark", "<shift><control>N", GTK_MENU_FUNC(find_next_mark_cb),
494 {"/Edit/Find Previous Mark", "<shift><control>B", GTK_MENU_FUNC(find_prev_mark_cb),
496 {"/Edit/Mark _All Packets", "<control>A", GTK_MENU_FUNC(packet_list_mark_all_frames_cb),
498 {"/Edit/_Unmark All Packets", "<control>D", GTK_MENU_FUNC(packet_list_unmark_all_frames_cb),
500 {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
501 {"/Edit/Set Time Reference (toggle)", "<control>T", GTK_MENU_FUNC(reftime_frame_cb),
502 REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
503 {"/Edit/Find Next Reference", "<alt><shift><control>N", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_NEXT, NULL, NULL,},
504 {"/Edit/Find Previous Reference", "<alt><shift><control>B", GTK_MENU_FUNC(reftime_frame_cb), REFTIME_FIND_PREV, NULL, NULL,},
505 {"/Edit/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
506 {"/Edit/_Configuration Profiles...", "<shift><control>A", GTK_MENU_FUNC(profile_dialog_cb), 0, NULL, NULL,},
507 {"/Edit/_Preferences...", "<shift><control>P", GTK_MENU_FUNC(prefs_cb),
508 0, "<StockItem>", GTK_STOCK_PREFERENCES,},
509 {"/_View", NULL, NULL, 0, "<Branch>", NULL,},
510 {"/View/_Main Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_MAIN_TOOLBAR, "<CheckItem>", NULL,},
511 {"/View/_Filter Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_FILTER_TOOLBAR, "<CheckItem>", NULL,},
513 {"/View/_Wireless Toolbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_AIRPCAP_TOOLBAR, "<CheckItem>", NULL,},
515 {"/View/_Statusbar", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_STATUSBAR, "<CheckItem>", NULL,},
516 {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
517 {"/View/Packet _List", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_PACKET_LIST, "<CheckItem>", NULL,},
518 {"/View/Packet _Details", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_TREE_VIEW, "<CheckItem>", NULL,},
519 {"/View/Packet _Bytes", NULL, GTK_MENU_FUNC(show_hide_cb), SHOW_HIDE_BYTE_VIEW, "<CheckItem>", NULL,},
520 {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
521 {"/View/_Time Display Format", NULL, NULL, 0, "<Branch>", NULL,},
522 {"/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", "<control>1", GTK_MENU_FUNC(timestamp_format_cb),
523 TS_ABSOLUTE_WITH_DATE, "<RadioItem>", NULL,},
524 {"/View/Time Display Format/Time of Day: 01:02:03.123456", "<control>2", GTK_MENU_FUNC(timestamp_format_cb),
525 TS_ABSOLUTE, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,},
526 {"/View/Time Display Format/Seconds Since Epoch (1970-01-01): 1234567890.123456", "<control>3", GTK_MENU_FUNC(timestamp_format_cb),
527 TS_EPOCH, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,},
528 {"/View/Time Display Format/Seconds Since Beginning of Capture: 123.123456", "<control>4", GTK_MENU_FUNC(timestamp_format_cb),
529 TS_RELATIVE, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,},
530 {"/View/Time Display Format/Seconds Since Previous Captured Packet: 1.123456", "<control>5", GTK_MENU_FUNC(timestamp_format_cb),
531 TS_DELTA, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,},
532 {"/View/Time Display Format/Seconds Since Previous Displayed Packet: 1.123456", "<control>6", GTK_MENU_FUNC(timestamp_format_cb),
533 TS_DELTA_DIS, "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456", NULL,},
534 {"/View/Time Display Format/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
535 {"/View/Time Display Format/Automatic (File Format Precision)", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
536 TS_PREC_AUTO, "<RadioItem>", NULL,},
537 {"/View/Time Display Format/Seconds: 0", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
538 TS_PREC_FIXED_SEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
539 {"/View/Time Display Format/Deciseconds: 0.1", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
540 TS_PREC_FIXED_DSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
541 {"/View/Time Display Format/Centiseconds: 0.12", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
542 TS_PREC_FIXED_CSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
543 {"/View/Time Display Format/Milliseconds: 0.123", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
544 TS_PREC_FIXED_MSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
545 {"/View/Time Display Format/Microseconds: 0.123456", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
546 TS_PREC_FIXED_USEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
547 {"/View/Time Display Format/Nanoseconds: 0.123456789", NULL, GTK_MENU_FUNC(timestamp_precision_cb),
548 TS_PREC_FIXED_NSEC, "/View/Time Display Format/Automatic (File Format Precision)", NULL,},
549 {"/View/Name Resol_ution", NULL, NULL, 0, "<Branch>", NULL,},
550 {"/View/Name Resolution/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,},
551 {"/View/Name Resolution/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
552 {"/View/Name Resolution/Enable for _MAC Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_MAC, "<CheckItem>", NULL,},
553 {"/View/Name Resolution/Enable for _Network Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_NETWORK, "<CheckItem>", NULL,},
554 {"/View/Name Resolution/Enable for _Transport Layer", NULL, GTK_MENU_FUNC(name_resolution_cb), RESOLV_TRANSPORT, "<CheckItem>", NULL,},
555 {"/View/Colorize Packet List", NULL, colorize_cb, 0, "<CheckItem>", NULL,},
557 {"/View/Auto Scroll in Li_ve Capture", NULL, GTK_MENU_FUNC(auto_scroll_live_cb), 0, "<CheckItem>", NULL,},
559 {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
560 {"/View/_Zoom In", "<control>plus", GTK_MENU_FUNC(view_zoom_in_cb),
561 0, "<StockItem>", GTK_STOCK_ZOOM_IN,},
562 {"/View/Zoom _Out", "<control>minus", GTK_MENU_FUNC(view_zoom_out_cb),
563 0, "<StockItem>", GTK_STOCK_ZOOM_OUT,},
564 {"/View/_Normal Size", "<control>equal", GTK_MENU_FUNC(view_zoom_100_cb),
565 0, "<StockItem>", GTK_STOCK_ZOOM_100,},
566 {"/View/Resize All Columns", "<shift><control>R", GTK_MENU_FUNC(packet_list_resize_columns_cb),
567 0, "<StockItem>", WIRESHARK_STOCK_RESIZE_COLUMNS,},
568 {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
569 {"/View/E_xpand Subtrees", "<shift>Right", GTK_MENU_FUNC(expand_tree_cb), 0, NULL, NULL,},
570 {"/View/_Expand All", "<control>Right", GTK_MENU_FUNC(expand_all_cb),
572 {"/View/Collapse _All", "<control>Left", GTK_MENU_FUNC(collapse_all_cb),
574 {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
575 {"/View/Colorize Conversation", NULL, NULL, 0, "<Branch>",NULL,},
576 {"/View/Colorize Conversation/Color 1", "<control>1",
577 GTK_MENU_FUNC(colorize_conversation_cb), 1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
578 {"/View/Colorize Conversation/Color 2", "<control>2",
579 GTK_MENU_FUNC(colorize_conversation_cb), 2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
580 {"/View/Colorize Conversation/Color 3", "<control>3",
581 GTK_MENU_FUNC(colorize_conversation_cb), 3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
582 {"/View/Colorize Conversation/Color 4", "<control>4",
583 GTK_MENU_FUNC(colorize_conversation_cb), 4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
584 {"/View/Colorize Conversation/Color 5", "<control>5",
585 GTK_MENU_FUNC(colorize_conversation_cb), 5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
586 {"/View/Colorize Conversation/Color 6", "<control>6",
587 GTK_MENU_FUNC(colorize_conversation_cb), 6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
588 {"/View/Colorize Conversation/Color 7", "<control>7",
589 GTK_MENU_FUNC(colorize_conversation_cb), 7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
590 {"/View/Colorize Conversation/Color 8", "<control>8",
591 GTK_MENU_FUNC(colorize_conversation_cb), 8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
592 {"/View/Colorize Conversation/Color 9", "<control>9",
593 GTK_MENU_FUNC(colorize_conversation_cb), 9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
594 {"/View/Colorize Conversation/Color 10", "<control>0",
595 GTK_MENU_FUNC(colorize_conversation_cb), 10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
596 {"/View/Colorize Conversation/<separator>", NULL,
597 NULL, 0, "<Separator>",NULL,},
598 {"/View/Colorize Conversation/New Coloring Rule...", NULL,
599 GTK_MENU_FUNC(colorize_conversation_cb), 0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
600 {"/View/Reset Coloring 1-10", "<control>space",
601 GTK_MENU_FUNC(colorize_conversation_cb), 255*256, NULL, NULL,},
602 {"/View/_Coloring Rules...", NULL, color_display_cb,
603 0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
604 {"/View/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
607 {"/View/Show Packet in New _Window", NULL,
608 GTK_MENU_FUNC(new_window_cb), 0, NULL, NULL,},
609 {"/View/_Reload", "<control>R", GTK_MENU_FUNC(file_reload_cmd_cb),
610 0, "<StockItem>", GTK_STOCK_REFRESH,},
611 {"/_Go", NULL, NULL, 0, "<Branch>", NULL,},
612 {"/Go/_Back", "<alt>Left",
613 GTK_MENU_FUNC(history_back_cb), 0, "<StockItem>", GTK_STOCK_GO_BACK,},
614 {"/Go/_Forward", "<alt>Right",
615 GTK_MENU_FUNC(history_forward_cb), 0, "<StockItem>", GTK_STOCK_GO_FORWARD,},
616 {"/Go/_Go to Packet...", "<control>G",
617 GTK_MENU_FUNC(goto_frame_cb), 0, "<StockItem>", GTK_STOCK_JUMP_TO,},
618 {"/Go/Go to _Corresponding Packet", NULL, GTK_MENU_FUNC(goto_framenum_cb),
620 {"/Go/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
621 {"/Go/Previous Packet", "<control>Up",
622 GTK_MENU_FUNC(packet_list_prev), 0, "<StockItem>", GTK_STOCK_GO_UP,},
623 {"/Go/Next Packet", "<control>Down",
624 GTK_MENU_FUNC(packet_list_next), 0, "<StockItem>", GTK_STOCK_GO_DOWN,},
625 {"/Go/F_irst Packet", "Home",
626 GTK_MENU_FUNC(goto_top_frame_cb), 0, "<StockItem>", GTK_STOCK_GOTO_TOP,},
627 {"/Go/_Last Packet", "End",
628 GTK_MENU_FUNC(goto_bottom_frame_cb), 0, "<StockItem>", GTK_STOCK_GOTO_BOTTOM,},
630 {"/_Capture", NULL, NULL, 0, "<Branch>", NULL,},
631 {"/Capture/_Interfaces...", "<control>I",
632 GTK_MENU_FUNC(capture_if_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_INTERFACES,},
633 {"/Capture/_Options...", "<control>K",
634 GTK_MENU_FUNC(capture_prep_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_OPTIONS,},
635 {"/Capture/_Start", "<control>E",
636 GTK_MENU_FUNC(capture_start_cb), 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_START,},
637 {"/Capture/S_top", "<control>E", GTK_MENU_FUNC(capture_stop_cb),
638 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_STOP,},
639 {"/Capture/_Restart", "<control>R", GTK_MENU_FUNC(capture_restart_cb),
640 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_RESTART,},
641 {"/Capture/Capture _Filters...", NULL, GTK_MENU_FUNC(cfilter_dialog_cb),
642 0, "<StockItem>", WIRESHARK_STOCK_CAPTURE_FILTER,},
643 #endif /* HAVE_LIBPCAP */
644 {"/_Analyze", NULL, NULL, 0, "<Branch>", NULL,},
645 {"/Analyze/_Display Filters...", NULL, GTK_MENU_FUNC(dfilter_dialog_cb),
646 0, "<StockItem>", WIRESHARK_STOCK_DISPLAY_FILTER,},
647 {"/Analyze/Display Filter _Macros...", NULL, GTK_MENU_FUNC(macros_dialog_cb), 0, NULL, NULL,},
648 {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
649 {"/Analyze/Appl_y as Filter", NULL, NULL, 0, "<Branch>", NULL,},
650 {"/Analyze/Apply as Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
651 MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
652 {"/Analyze/Apply as Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
653 MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
654 {"/Analyze/Apply as Filter/... _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
655 MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
656 {"/Analyze/Apply as Filter/... _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
657 MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
658 {"/Analyze/Apply as Filter/... a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
659 MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
660 {"/Analyze/Apply as Filter/... o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
661 MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
662 {"/Analyze/_Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
663 {"/Analyze/Prepare a Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
664 MATCH_SELECTED_REPLACE, NULL, NULL,},
665 {"/Analyze/Prepare a Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
666 MATCH_SELECTED_NOT, NULL, NULL,},
667 {"/Analyze/Prepare a Filter/... _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
668 MATCH_SELECTED_AND, NULL, NULL,},
669 {"/Analyze/Prepare a Filter/... _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
670 MATCH_SELECTED_OR, NULL, NULL,},
671 {"/Analyze/Prepare a Filter/... a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
672 MATCH_SELECTED_AND_NOT, NULL, NULL,},
673 {"/Analyze/Prepare a Filter/... o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
674 MATCH_SELECTED_OR_NOT, NULL, NULL,},
675 {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
676 {"/Analyze/_Enabled Protocols...", "<shift><control>E", GTK_MENU_FUNC(proto_cb),
677 0, "<StockItem>", WIRESHARK_STOCK_CHECKBOX,},
678 {"/Analyze/Decode _As...", NULL, GTK_MENU_FUNC(decode_as_cb),
679 0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
680 {"/Analyze/_User Specified Decodes...", NULL,
681 GTK_MENU_FUNC(decode_show_cb), 0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
682 {"/Analyze/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
683 {"/Analyze/_Follow TCP Stream", NULL,
684 GTK_MENU_FUNC(follow_tcp_stream_cb), 0, NULL, NULL,},
685 {"/Analyze/_Follow UDP Stream", NULL,
686 GTK_MENU_FUNC(follow_udp_stream_cb), 0, NULL, NULL,},
687 {"/Analyze/_Follow SSL Stream", NULL,
688 GTK_MENU_FUNC(follow_ssl_stream_cb), 0, NULL, NULL,},
689 {"/_Statistics", NULL, NULL, 0, "<Branch>", NULL,},
690 {"/Statistics/_Summary", NULL, GTK_MENU_FUNC(summary_open_cb), 0, "<StockItem>", GTK_STOCK_PROPERTIES,},
691 {"/Statistics/_Protocol Hierarchy", NULL,
692 GTK_MENU_FUNC(proto_hier_stats_cb), 0, NULL, NULL,},
693 {"/Statistics/Conversations", NULL,
694 GTK_MENU_FUNC(init_conversation_notebook_cb), 0, "<StockItem>", WIRESHARK_STOCK_CONVERSATIONS,},
695 {"/Statistics/Endpoints", NULL,
696 GTK_MENU_FUNC(init_hostlist_notebook_cb), 0, "<StockItem>", WIRESHARK_STOCK_ENDPOINTS,},
697 {"/Telephon_y", NULL, NULL, 0, "<Branch>", NULL,},
698 {"/_Tools", NULL, NULL, 0, "<Branch>", NULL,},
699 {"/Tools/Firewall ACL Rules", NULL,
700 firewall_rule_cb, 0, NULL, NULL,},
701 {"/_Help", NULL, NULL, 0, "<Branch>", NULL,},
702 {"/Help/_Contents", "F1", GTK_MENU_FUNC(topic_menu_cb), HELP_CONTENT, "<StockItem>", GTK_STOCK_HELP,},
703 {"/Help/FAQ's", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_FAQ, NULL, NULL,},
704 {"/Help/Manual Pages", NULL, NULL, 0, "<Branch>", NULL,},
705 {"/Help/Manual Pages/Wireshark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_WIRESHARK, NULL, NULL,},
706 {"/Help/Manual Pages/Wireshark Filter", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_WIRESHARK_FILTER, NULL, NULL,},
707 {"/Help/Manual Pages/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
708 {"/Help/Manual Pages/TShark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_TSHARK, NULL, NULL,},
709 {"/Help/Manual Pages/RawShark", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_RAWSHARK, NULL, NULL,},
710 {"/Help/Manual Pages/Dumpcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_DUMPCAP, NULL, NULL,},
711 {"/Help/Manual Pages/Mergecap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_MERGECAP, NULL, NULL,},
712 {"/Help/Manual Pages/Editcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_EDITCAP, NULL, NULL,},
713 {"/Help/Manual Pages/Text2pcap", NULL, GTK_MENU_FUNC(topic_menu_cb), LOCALPAGE_MAN_TEXT2PCAP, NULL, NULL,},
714 {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
715 {"/Help/Website", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_HOME, "<StockItem>", GTK_STOCK_HOME,},
716 {"/Help/Wiki", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_WIKI, "<StockItem>", WIRESHARK_STOCK_WIKI,},
717 {"/Help/Downloads", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_DOWNLOAD, NULL, NULL,},
718 {"/Help/Sample Captures", NULL, GTK_MENU_FUNC(topic_menu_cb), ONLINEPAGE_SAMPLE_FILES, NULL, NULL,},
719 {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
720 {"/Help/_Supported Protocols (slow!)", NULL, GTK_MENU_FUNC(supported_cb), 0, NULL, NULL,},
721 {"/Help/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
722 {"/Help/_About Wireshark", NULL, GTK_MENU_FUNC(about_wireshark_cb),
723 0, "<StockItem>", WIRESHARK_STOCK_ABOUT}
727 /* calculate the number of menu_items */
728 static int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
730 /* packet list popup */
731 static GtkItemFactoryEntry packet_list_menu_items[] =
733 {"/Mark Packet (toggle)", NULL, GTK_MENU_FUNC(packet_list_mark_frame_cb), 0, NULL, NULL,},
734 {"/Set Time Reference (toggle)", NULL, GTK_MENU_FUNC(reftime_frame_cb), REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
736 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
738 {"/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL,},
739 {"/Apply as Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
740 MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
741 {"/Apply as Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
742 MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
743 {"/Apply as Filter/... _and Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
744 MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
745 {"/Apply as Filter/... _or Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
746 MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
747 {"/Apply as Filter/... a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
748 MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
749 {"/Apply as Filter/... o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
750 MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
752 {"/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
753 {"/Prepare a Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
754 MATCH_SELECTED_REPLACE, NULL, NULL,},
755 {"/Prepare a Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
756 MATCH_SELECTED_NOT, NULL, NULL,},
757 {"/Prepare a Filter/... _and Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
758 MATCH_SELECTED_AND, NULL, NULL,},
759 {"/Prepare a Filter/... _or Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
760 MATCH_SELECTED_OR, NULL, NULL,},
761 {"/Prepare a Filter/... a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
762 MATCH_SELECTED_AND_NOT, NULL, NULL,},
763 {"/Prepare a Filter/... o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
764 MATCH_SELECTED_OR_NOT, NULL, NULL,},
766 {"/Conversation Filter", NULL, NULL, 0, "<Branch>",NULL,},
767 {"/Conversation Filter/Ethernet", NULL, GTK_MENU_FUNC(conversation_cb),
768 CONV_ETHER, NULL, NULL,},
769 {"/Conversation Filter/IP", NULL, GTK_MENU_FUNC(conversation_cb),
770 CONV_IP, NULL, NULL,},
771 {"/Conversation Filter/TCP", NULL, GTK_MENU_FUNC(conversation_cb),
772 CONV_TCP, NULL, NULL,},
773 {"/Conversation Filter/UDP", NULL, GTK_MENU_FUNC(conversation_cb),
774 CONV_UDP, NULL, NULL,},
775 {"/Conversation Filter/PN-CBA Server", NULL, GTK_MENU_FUNC(conversation_cb),
776 CONV_CBA, NULL, NULL,},
778 {"/Colorize Conversation", NULL, NULL, 0, "<Branch>",NULL,},
779 {"/Colorize Conversation/Ethernet", NULL, NULL, 0, "<Branch>",NULL,},
780 {"/Colorize Conversation/Ethernet/Color 1", NULL,
781 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
782 {"/Colorize Conversation/Ethernet/Color 2", NULL,
783 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
784 {"/Colorize Conversation/Ethernet/Color 3", NULL,
785 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
786 {"/Colorize Conversation/Ethernet/Color 4", NULL,
787 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
788 {"/Colorize Conversation/Ethernet/Color 5", NULL,
789 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
790 {"/Colorize Conversation/Ethernet/Color 6", NULL,
791 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
792 {"/Colorize Conversation/Ethernet/Color 7", NULL,
793 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
794 {"/Colorize Conversation/Ethernet/Color 8", NULL,
795 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
796 {"/Colorize Conversation/Ethernet/Color 9", NULL,
797 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
798 {"/Colorize Conversation/Ethernet/Color 10", NULL,
799 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER+10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
800 {"/Colorize Conversation/Ethernet/<separator>", NULL,
801 NULL, 0, "<Separator>",NULL,},
802 {"/Colorize Conversation/Ethernet/New Coloring Rule...", NULL,
803 GTK_MENU_FUNC(colorize_conversation_cb), CONV_ETHER, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
804 {"/Colorize Conversation/IP", NULL, NULL, 0, "<Branch>",NULL,},
805 {"/Colorize Conversation/IP/Color 1", NULL,
806 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
807 {"/Colorize Conversation/IP/Color 2", NULL,
808 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
809 {"/Colorize Conversation/IP/Color 3", NULL,
810 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
811 {"/Colorize Conversation/IP/Color 4", NULL,
812 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
813 {"/Colorize Conversation/IP/Color 5", NULL,
814 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
815 {"/Colorize Conversation/IP/Color 6", NULL,
816 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
817 {"/Colorize Conversation/IP/Color 7", NULL,
818 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
819 {"/Colorize Conversation/IP/Color 8", NULL,
820 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
821 {"/Colorize Conversation/IP/Color 9", NULL,
822 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
823 {"/Colorize Conversation/IP/Color 10", NULL,
824 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP+10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
825 {"/Colorize Conversation/IP/<separator>", NULL,
826 NULL, 0, "<Separator>",NULL,},
827 {"/Colorize Conversation/IP/New Coloring Rule...", NULL,
828 GTK_MENU_FUNC(colorize_conversation_cb), CONV_IP, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
829 {"/Colorize Conversation/TCP", NULL, NULL, 0, "<Branch>",NULL,},
830 {"/Colorize Conversation/TCP/Color 1", NULL,
831 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
832 {"/Colorize Conversation/TCP/Color 2", NULL,
833 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
834 {"/Colorize Conversation/TCP/Color 3", NULL,
835 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
836 {"/Colorize Conversation/TCP/Color 4", NULL,
837 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
838 {"/Colorize Conversation/TCP/Color 5", NULL,
839 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
840 {"/Colorize Conversation/TCP/Color 6", NULL,
841 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
842 {"/Colorize Conversation/TCP/Color 7", NULL,
843 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
844 {"/Colorize Conversation/TCP/Color 8", NULL,
845 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
846 {"/Colorize Conversation/TCP/Color 9", NULL,
847 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
848 {"/Colorize Conversation/TCP/Color 10", NULL,
849 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP+10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
850 {"/Colorize Conversation/TCP/<separator>", NULL,
851 NULL, 0, "<Separator>",NULL,},
852 {"/Colorize Conversation/TCP/New Coloring Rule...", NULL,
853 GTK_MENU_FUNC(colorize_conversation_cb), CONV_TCP, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
854 {"/Colorize Conversation/UDP", NULL, NULL, 0, "<Branch>",NULL,},
855 {"/Colorize Conversation/UDP/Color 1", NULL,
856 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
857 {"/Colorize Conversation/UDP/Color 2", NULL,
858 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
859 {"/Colorize Conversation/UDP/Color 3", NULL,
860 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
861 {"/Colorize Conversation/UDP/Color 4", NULL,
862 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
863 {"/Colorize Conversation/UDP/Color 5", NULL,
864 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
865 {"/Colorize Conversation/UDP/Color 6", NULL,
866 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
867 {"/Colorize Conversation/UDP/Color 7", NULL,
868 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
869 {"/Colorize Conversation/UDP/Color 8", NULL,
870 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
871 {"/Colorize Conversation/UDP/Color 9", NULL,
872 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
873 {"/Colorize Conversation/UDP/Color 10", NULL,
874 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP+10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
875 {"/Colorize Conversation/UDP/<separator>", NULL,
876 NULL, 0, "<Separator>",NULL,},
877 {"/Colorize Conversation/UDP/New Coloring Rule...", NULL,
878 GTK_MENU_FUNC(colorize_conversation_cb), CONV_UDP, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
879 {"/Colorize Conversation/PN-CBA Server", NULL, NULL, 0, "<Branch>",NULL,},
880 {"/Colorize Conversation/PN-CBA Server/Color 1", NULL,
881 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+1*256, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
882 {"/Colorize Conversation/PN-CBA Server/Color 2", NULL,
883 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+2*256, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
884 {"/Colorize Conversation/PN-CBA Server/Color 3", NULL,
885 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+3*256, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
886 {"/Colorize Conversation/PN-CBA Server/Color 4", NULL,
887 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+4*256, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
888 {"/Colorize Conversation/PN-CBA Server/Color 5", NULL,
889 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+5*256, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
890 {"/Colorize Conversation/PN-CBA Server/Color 6", NULL,
891 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+6*256, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
892 {"/Colorize Conversation/PN-CBA Server/Color 7", NULL,
893 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+7*256, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
894 {"/Colorize Conversation/PN-CBA Server/Color 8", NULL,
895 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+8*256, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
896 {"/Colorize Conversation/PN-CBA Server/Color 9", NULL,
897 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+9*256, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
898 {"/Colorize Conversation/PN-CBA Server/Color 10", NULL,
899 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA+10*256, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
900 {"/Colorize Conversation/PN-CBA Server/<separator>", NULL,
901 NULL, 0, "<Separator>",NULL,},
902 {"/Colorize Conversation/PN-CBA Server/New Coloring Rule...", NULL,
903 GTK_MENU_FUNC(colorize_conversation_cb), CONV_CBA, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
905 {"/SCTP", NULL, NULL, 0, "<Branch>",NULL,},
906 {"/SCTP/Analyse this Association", NULL, GTK_MENU_FUNC(sctp_analyse_start),
908 {"/SCTP/Prepare Filter for this Association", NULL, (sctp_set_assoc_filter),
911 {"/Follow TCP Stream", NULL, (follow_tcp_stream_cb),
913 {"/Follow UDP Stream", NULL, (follow_udp_stream_cb),
915 {"/Follow SSL Stream", NULL, (follow_ssl_stream_cb),
918 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
920 {"/Copy", NULL, NULL, 0, "<Branch>", NULL,},
921 {"/Copy/Summary (Text)", NULL, GTK_MENU_FUNC(packet_list_copy_summary_cb), CS_TEXT, NULL, NULL,},
922 {"/Copy/Summary (CSV)", NULL, GTK_MENU_FUNC(packet_list_copy_summary_cb), CS_CSV, NULL, NULL,},
923 {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
924 {"/Copy/As Filter", NULL, GTK_MENU_FUNC(match_selected_plist_cb),
925 MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,},
926 {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
927 {"/Copy/Bytes (Offset Hex Text)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_ALLINFO, NULL, NULL,},
928 {"/Copy/Bytes (Offset Hex)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_HEXCOLUMNS, NULL, NULL,},
929 {"/Copy/Bytes (Printable Text Only)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_TEXTONLY, NULL, NULL,},
930 {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
931 {"/Copy/Bytes (Hex Stream)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_HEX, NULL, NULL,},
932 {"/Copy/Bytes (Binary Stream)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_BINARY, NULL, NULL,},
934 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
936 {"/Decode As...", NULL, GTK_MENU_FUNC(decode_as_cb), 0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
937 {"/Print...", NULL, GTK_MENU_FUNC(file_print_selected_cmd_cb), 0, "<StockItem>", GTK_STOCK_PRINT,},
938 {"/Show Packet in New Window", NULL, GTK_MENU_FUNC(new_window_cb),
942 static GtkItemFactoryEntry tree_view_menu_items[] =
945 {"/Expand Subtrees", NULL, GTK_MENU_FUNC(expand_tree_cb), 0, NULL, NULL,},
946 {"/Expand All", NULL, GTK_MENU_FUNC(expand_all_cb), 0, NULL, NULL,},
947 {"/Collapse All", NULL, GTK_MENU_FUNC(collapse_all_cb), 0, NULL, NULL,},
949 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
951 {"/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL,},
952 {"/Apply as Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
953 MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
954 {"/Apply as Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
955 MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
956 {"/Apply as Filter/... _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
957 MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
958 {"/Apply as Filter/... _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
959 MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
960 {"/Apply as Filter/... a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
961 MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
962 {"/Apply as Filter/... o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
963 MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW, NULL, NULL,},
965 {"/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
966 {"/Prepare a Filter/_Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
967 MATCH_SELECTED_REPLACE, NULL, NULL,},
968 {"/Prepare a Filter/_Not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
969 MATCH_SELECTED_NOT, NULL, NULL,},
970 {"/Prepare a Filter/... _and Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
971 MATCH_SELECTED_AND, NULL, NULL,},
972 {"/Prepare a Filter/... _or Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
973 MATCH_SELECTED_OR, NULL, NULL,},
974 {"/Prepare a Filter/... a_nd not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
975 MATCH_SELECTED_AND_NOT, NULL, NULL,},
976 {"/Prepare a Filter/... o_r not Selected", NULL, GTK_MENU_FUNC(match_selected_ptree_cb),
977 MATCH_SELECTED_OR_NOT, NULL, NULL,},
979 {"/Colorize with Filter", NULL, NULL, 0, "<Branch>", NULL,},
980 {"/Colorize with Filter/Color 1", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 1, "<StockItem>", WIRESHARK_STOCK_COLOR1,},
981 {"/Colorize with Filter/Color 2", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 2, "<StockItem>", WIRESHARK_STOCK_COLOR2,},
982 {"/Colorize with Filter/Color 3", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 3, "<StockItem>", WIRESHARK_STOCK_COLOR3,},
983 {"/Colorize with Filter/Color 4", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 4, "<StockItem>", WIRESHARK_STOCK_COLOR4,},
984 {"/Colorize with Filter/Color 5", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 5, "<StockItem>", WIRESHARK_STOCK_COLOR5,},
985 {"/Colorize with Filter/Color 6", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 6, "<StockItem>", WIRESHARK_STOCK_COLOR6,},
986 {"/Colorize with Filter/Color 7", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 7, "<StockItem>", WIRESHARK_STOCK_COLOR7,},
987 {"/Colorize with Filter/Color 8", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 8, "<StockItem>", WIRESHARK_STOCK_COLOR8,},
988 {"/Colorize with Filter/Color 9", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 9, "<StockItem>", WIRESHARK_STOCK_COLOR9,},
989 {"/Colorize with Filter/Color 10", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 10, "<StockItem>", WIRESHARK_STOCK_COLOR0,},
990 {"/Colorize with Filter/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
991 {"/Colorize with Filter/New Coloring Rule...", NULL, GTK_MENU_FUNC(colorize_selected_ptree_cb), 0, "<StockItem>", GTK_STOCK_SELECT_COLOR,},
993 {"/Follow TCP Stream", NULL, GTK_MENU_FUNC(follow_tcp_stream_cb),
995 {"/Follow UDP Stream", NULL, GTK_MENU_FUNC(follow_udp_stream_cb),
997 {"/Follow SSL Stream", NULL, GTK_MENU_FUNC(follow_ssl_stream_cb),
1000 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1002 {"/Copy", NULL, NULL, 0, "<Branch>", NULL,},
1003 {"/Copy/Description", NULL, GTK_MENU_FUNC(copy_selected_plist_cb), 0, NULL, NULL,},
1004 {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1005 {"/Copy/As Filter", NULL, GTK_MENU_FUNC(match_selected_ptree_cb), MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,},
1006 {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1007 {"/Copy/Bytes (Offset Hex Text)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_ALLINFO | CD_FLAGS_SELECTEDONLY, NULL, NULL,},
1008 {"/Copy/Bytes (Offset Hex)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_HEXCOLUMNS | CD_FLAGS_SELECTEDONLY, NULL, NULL,},
1009 {"/Copy/Bytes (Printable Text Only)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_TEXTONLY | CD_FLAGS_SELECTEDONLY, NULL, NULL,},
1010 {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1011 {"/Copy/Bytes (Hex Stream)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_HEX | CD_FLAGS_SELECTEDONLY, NULL, NULL,},
1012 {"/Copy/Bytes (Binary Stream)", NULL, GTK_MENU_FUNC(copy_hex_cb), CD_BINARY | CD_FLAGS_SELECTEDONLY, NULL, NULL,},
1014 {"/Export Selected Packet Bytes...", NULL, GTK_MENU_FUNC(savehex_cb),
1017 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1019 {"/Wiki Protocol Page", NULL, GTK_MENU_FUNC(selected_ptree_info_cb),
1020 0, "<StockItem>", WIRESHARK_STOCK_WIKI,},
1021 {"/Filter Field Reference", NULL, GTK_MENU_FUNC(selected_ptree_ref_cb),
1022 0, "<StockItem>", WIRESHARK_STOCK_INTERNET,},
1023 {"/Protocol Preferences", NULL, NULL, 0, NULL, NULL,},
1024 {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,},
1025 {"/Decode As...", NULL, GTK_MENU_FUNC(decode_as_cb), 0, "<StockItem>", WIRESHARK_STOCK_DECODE_AS,},
1026 {"/Disable Protocol...", NULL, GTK_MENU_FUNC(proto_disable_cb), 0, "<StockItem>", WIRESHARK_STOCK_CHECKBOX,},
1027 {"/_Resolve Name", NULL, GTK_MENU_FUNC(resolve_name_cb), 0, NULL, NULL,},
1028 {"/_Go to Corresponding Packet", NULL, GTK_MENU_FUNC(goto_framenum_cb), 0, NULL, NULL,}
1032 static int initialize = TRUE;
1033 static GtkItemFactory *main_menu_factory = NULL;
1034 static GtkItemFactory *packet_list_menu_factory = NULL;
1035 static GtkItemFactory *tree_view_menu_factory = NULL;
1036 static GtkItemFactory *hexdump_menu_factory = NULL;
1038 static GSList *popup_menu_list = NULL;
1040 static GtkAccelGroup *grp;
1043 main_menu_new(GtkAccelGroup ** table) {
1045 #ifdef HAVE_IGE_MAC_INTEGRATION
1046 GtkWidget *quit_item, *about_item, *preferences_item;
1047 IgeMacMenuGroup *group;
1050 grp = gtk_accel_group_new();
1055 menubar = main_menu_factory->widget;
1057 #ifdef HAVE_IGE_MAC_INTEGRATION
1058 if(prefs.gui_macosx_style) {
1059 ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar));
1060 ige_mac_menu_set_global_key_handler_enabled(TRUE);
1062 /* Create menu items to populate the application menu with. We have to
1063 * do this because we are still using the old GtkItemFactory API for
1065 group = ige_mac_menu_add_app_menu_group();
1066 about_item = gtk_menu_item_new_with_label("About");
1067 g_signal_connect(about_item, "activate", G_CALLBACK(about_wireshark_cb),
1069 ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(about_item), NULL);
1071 group = ige_mac_menu_add_app_menu_group();
1072 preferences_item = gtk_menu_item_new_with_label("Preferences");
1073 g_signal_connect(preferences_item, "activate", G_CALLBACK(prefs_cb),
1075 ige_mac_menu_add_app_menu_item(group, GTK_MENU_ITEM(preferences_item),
1079 /* The quit item in the application menu shows up whenever ige mac
1080 * integration is enabled, even if the OS X UI style in Wireshark isn't
1082 quit_item = gtk_menu_item_new_with_label("Quit");
1083 g_signal_connect(quit_item, "activate", G_CALLBACK(file_quit_cmd_cb),
1085 ige_mac_menu_set_quit_menu_item(GTK_MENU_ITEM(quit_item));
1095 void menu_dissector_filter_cb( GtkWidget *widget _U_,
1096 gpointer callback_data,
1097 guint callback_action _U_)
1099 dissector_filter_t *filter_entry = callback_data;
1100 GtkWidget *filter_te;
1104 filter_te = g_object_get_data(G_OBJECT(popup_menu_object), E_DFILTER_TE_KEY);
1106 /* XXX - this gets the packet_info of the last dissected packet, */
1107 /* which is not necessarily the last selected packet */
1108 /* e.g. "Update list of packets in real time" won't work correct */
1109 buf = filter_entry->build_filter_string(&cfile.edt->pi);
1111 gtk_entry_set_text(GTK_ENTRY(filter_te), buf);
1113 /* Run the display filter so it goes in effect - even if it's the
1114 same as the previous display filter. */
1115 main_filter_packets(&cfile, buf, TRUE);
1117 g_free( (void *) buf);
1120 gboolean menu_dissector_filter_spe_cb(frame_data *fd _U_, epan_dissect_t *edt, gpointer callback_data) {
1121 dissector_filter_t *filter_entry = callback_data;
1123 /* XXX - this gets the packet_info of the last dissected packet, */
1124 /* which is not necessarily the last selected packet */
1125 /* e.g. "Update list of packets in real time" won't work correct */
1126 return (edt != NULL) ? filter_entry->is_filter_valid(&edt->pi) : FALSE;
1129 void menu_dissector_filter(void) {
1130 GList *list_entry = dissector_filter_list;
1131 dissector_filter_t *filter_entry;
1133 while(list_entry != NULL) {
1134 filter_entry = list_entry->data;
1136 register_stat_menu_item(filter_entry->name, REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER,
1137 menu_dissector_filter_cb,
1138 menu_dissector_filter_spe_cb,
1139 NULL /* selected_tree_row_enabled */,
1142 list_entry = g_list_next(list_entry);
1153 packet_list_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
1154 popup_menu_object = gtk_menu_new();
1155 gtk_item_factory_create_items_ac(packet_list_menu_factory, sizeof(packet_list_menu_items)/sizeof(packet_list_menu_items[0]), packet_list_menu_items, popup_menu_object, 2);
1156 g_object_set_data(G_OBJECT(popup_menu_object), PM_PACKET_LIST_KEY,
1157 packet_list_menu_factory->widget);
1158 popup_menu_list = g_slist_append((GSList *)popup_menu_list, packet_list_menu_factory);
1160 tree_view_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
1161 gtk_item_factory_create_items_ac(tree_view_menu_factory, sizeof(tree_view_menu_items)/sizeof(tree_view_menu_items[0]), tree_view_menu_items, popup_menu_object, 2);
1162 g_object_set_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY,
1163 tree_view_menu_factory->widget);
1164 popup_menu_list = g_slist_append((GSList *)popup_menu_list, tree_view_menu_factory);
1166 hexdump_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
1167 g_object_set_data(G_OBJECT(popup_menu_object), PM_HEXDUMP_KEY,
1168 hexdump_menu_factory->widget);
1169 popup_menu_list = g_slist_append((GSList *)popup_menu_list, hexdump_menu_factory);
1171 main_menu_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", grp);
1172 gtk_item_factory_create_items_ac(main_menu_factory, nmenu_items, menu_items, NULL, 2);
1174 menu_dissector_filter();
1175 merge_all_tap_menus(tap_menu_tree_root);
1177 /* Initialize enabled/disabled state of menu items */
1178 set_menus_for_capture_file(NULL);
1180 /* Un-#if this when we actually implement Cut/Copy/Paste.
1181 Then make sure you enable them when they can be done. */
1182 set_menu_sensitivity(main_menu_factory, "/Edit/Cut", FALSE);
1183 set_menu_sensitivity(main_menu_factory, "/Edit/Copy", FALSE);
1184 set_menu_sensitivity(main_menu_factory, "/Edit/Paste", FALSE);
1187 set_menus_for_captured_packets(FALSE);
1188 set_menus_for_selected_packet(&cfile);
1189 set_menus_for_selected_tree_row(&cfile);
1190 set_menus_for_capture_in_progress(FALSE);
1191 set_menus_for_file_set(/* dialog */TRUE, /* previous file */ FALSE, /* next_file */ FALSE);
1193 /* init with an empty recent files list */
1194 clear_menu_recent_capture_file_cmd_cb(NULL, NULL);
1200 static gint tap_menu_item_add_compare(gconstpointer a, gconstpointer b)
1203 ((const menu_item_t *) a)->name,
1204 ((const menu_item_t *) b)->name);
1208 /* add a menuitem below the current node */
1209 static GList * tap_menu_item_add(
1212 const char *stock_id,
1213 GtkItemFactoryCallback callback,
1214 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
1215 gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
1216 gpointer callback_data,
1223 child = g_malloc(sizeof (menu_item_t));
1225 child->group = group;
1226 child->stock_id = stock_id;
1227 child->callback = callback;
1228 child->selected_packet_enabled = selected_packet_enabled;
1229 child->selected_tree_row_enabled = selected_tree_row_enabled;
1230 child->callback_data = callback_data;
1231 child->enabled = FALSE;
1232 child->children = NULL;
1234 /* insert the new child node into the parent */
1235 curr = curnode->data;
1236 curr->children = g_list_insert_sorted(curr->children, child, tap_menu_item_add_compare);
1238 /* return the new node */
1239 /* XXX: improve this */
1240 return g_list_find(curr->children, child);
1244 * Add a new menu item for a tap.
1245 * This must be called after we've created the main menu, so it can't
1246 * be called from the routine that registers taps - we have to introduce
1247 * another per-tap registration routine.
1249 * "callback" gets called when the menu item is selected; it should do
1250 * the work of creating the tap window.
1252 * "selected_packet_enabled" gets called by "set_menus_for_selected_packet()";
1253 * it's passed a Boolean that's TRUE if a packet is selected and FALSE
1254 * otherwise, and should return TRUE if the tap will work now (which
1255 * might depend on whether a packet is selected and, if one is, on the
1256 * packet) and FALSE if not.
1258 * "selected_tree_row_enabled" gets called by
1259 * "set_menus_for_selected_tree_row()"; it's passed a Boolean that's TRUE if
1260 * a protocol tree row is selected and FALSE otherwise, and should return
1261 * TRUE if the tap will work now (which might depend on whether a tree row
1262 * is selected and, if one is, on the tree row) and FALSE if not.
1265 register_stat_menu_item_stock(
1267 register_stat_group_t group,
1268 const char *stock_id,
1269 GtkItemFactoryCallback callback,
1270 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
1271 gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
1272 gpointer callback_data)
1274 /*static const char toolspath[] = "/Statistics/";*/
1275 const char *toolspath;
1284 * The menu path must be relative.
1286 g_assert(*name != '/');
1289 case(REGISTER_STAT_GROUP_GENERIC): toolspath = "/Statistics/"; break;
1290 case(REGISTER_STAT_GROUP_CONVERSATION_LIST): toolspath = "/Statistics/_Conversation List/"; break;
1291 case(REGISTER_STAT_GROUP_ENDPOINT_LIST): toolspath = "/Statistics/_Endpoint List/"; break;
1292 case(REGISTER_STAT_GROUP_RESPONSE_TIME): toolspath = "/Statistics/Service _Response Time/"; break;
1293 case(REGISTER_STAT_GROUP_UNSORTED): toolspath = "/Statistics/"; break;
1294 case(REGISTER_ANALYZE_GROUP_UNSORTED): toolspath = "/Analyze/"; break;
1295 case(REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER): toolspath = "/Analyze/Conversation Filter/"; break;
1296 case(REGISTER_STAT_GROUP_TELEPHONY): toolspath = "/Telephony/"; break;
1297 case(REGISTER_TOOLS_GROUP_UNSORTED): toolspath = "/Tools/"; break;
1299 g_assert(!"no such menu group");
1303 /* add the (empty) root node, if not already done */
1304 if(tap_menu_tree_root == NULL) {
1305 child = g_malloc0(sizeof (menu_item_t));
1306 tap_menu_tree_root = g_list_append(NULL, child);
1310 * Create any submenus required.
1312 curnode = tap_menu_tree_root;
1314 while ((p = strchr(p, '/')) != NULL) {
1316 * OK, everything between "name" and "p" is
1317 * a menu relative subtree into which the menu item
1320 * Construct the absolute path name of that subtree.
1322 menupathlen = strlen(toolspath) + 1 + (p - name);
1323 menupath = g_malloc(menupathlen);
1324 g_strlcpy(menupath, toolspath, menupathlen);
1325 g_strlcat(menupath, name, menupathlen);
1328 * Does there exist an entry with that path at this
1329 * level of the Analyze menu tree?
1331 child = curnode->data;
1332 for (childnode = child->children; childnode != NULL; childnode = childnode->next) {
1333 child = childnode->data;
1334 if (strcmp(child->name, menupath) == 0)
1337 if (childnode == NULL) {
1339 * No. Create such an item as a subtree, and
1340 * add it to the Tools menu tree.
1342 childnode = tap_menu_item_add(
1343 menupath, group, "", NULL, NULL ,NULL, NULL, curnode);
1346 * Yes. We don't need this "menupath" any longer.
1350 curnode = childnode;
1353 * Skip over the '/' we found.
1359 * Construct the main menu path for the menu item.
1361 menupathlen = strlen(toolspath) + 1 + strlen(name);
1362 menupath = g_malloc(menupathlen);
1363 g_strlcpy(menupath, toolspath, menupathlen);
1364 g_strlcat(menupath, name, menupathlen);
1367 * Construct an item factory entry for the item, and add it to
1371 menupath, group, stock_id, callback,
1372 selected_packet_enabled, selected_tree_row_enabled,
1373 callback_data, curnode);
1378 register_stat_menu_item(
1380 register_stat_group_t group,
1381 GtkItemFactoryCallback callback,
1382 gboolean (*selected_packet_enabled)(frame_data *, epan_dissect_t *, gpointer callback_data),
1383 gboolean (*selected_tree_row_enabled)(field_info *, gpointer callback_data),
1384 gpointer callback_data)
1386 register_stat_menu_item_stock(
1391 selected_packet_enabled,
1392 selected_tree_row_enabled,
1396 static guint merge_tap_menus_layered(GList *node, gint group) {
1397 GtkItemFactoryEntry *entry;
1400 menu_item_t *node_data = node->data;
1403 * Is this a leaf node or an interior node?
1405 if (node_data->children == NULL) {
1411 * The root node doesn't correspond to a menu tree item; it
1412 * has a null name pointer.
1414 if (node_data->name != NULL && group == node_data->group) {
1415 entry = g_malloc0(sizeof (GtkItemFactoryEntry));
1416 entry->path = node_data->name;
1417 entry->callback = node_data->callback;
1419 case(REGISTER_STAT_GROUP_UNSORTED):
1421 case(REGISTER_STAT_GROUP_GENERIC):
1423 case(REGISTER_STAT_GROUP_CONVERSATION_LIST):
1424 entry->item_type = "<StockItem>";
1425 entry->extra_data = WIRESHARK_STOCK_CONVERSATIONS;
1427 case(REGISTER_STAT_GROUP_ENDPOINT_LIST):
1428 entry->item_type = "<StockItem>";
1429 entry->extra_data = WIRESHARK_STOCK_ENDPOINTS;
1431 case(REGISTER_STAT_GROUP_RESPONSE_TIME):
1432 entry->item_type = "<StockItem>";
1433 entry->extra_data = WIRESHARK_STOCK_TIME;
1435 case(REGISTER_STAT_GROUP_TELEPHONY):
1437 case(REGISTER_ANALYZE_GROUP_UNSORTED):
1439 case(REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER):
1441 case(REGISTER_TOOLS_GROUP_UNSORTED):
1444 g_assert_not_reached();
1446 if(node_data->stock_id!= NULL) {
1447 entry->item_type = "<StockItem>";
1448 entry->extra_data = node_data->stock_id;
1450 gtk_item_factory_create_item(main_menu_factory, entry, node_data->callback_data, /* callback_type */ 2);
1451 set_menu_sensitivity(main_menu_factory, node_data->name, FALSE); /* no capture file yet */
1457 * It's an interior node; call
1458 * "merge_tap_menus_layered()" on all its children
1462 * The root node doesn't correspond to a menu tree item; it
1463 * has a null name pointer.
1465 if (node_data->name != NULL && group == node_data->group) {
1466 entry = g_malloc0(sizeof (GtkItemFactoryEntry));
1467 entry->path = node_data->name;
1468 entry->item_type = "<Branch>";
1469 gtk_item_factory_create_item(main_menu_factory, entry,
1471 set_menu_sensitivity(main_menu_factory, node_data->name,
1472 FALSE); /* no children yet */
1477 for (child = node_data->children; child != NULL; child =
1479 added += merge_tap_menus_layered(child, group);
1487 void merge_all_tap_menus(GList *node) {
1488 GtkItemFactoryEntry *sep_entry;
1490 sep_entry = g_malloc0(sizeof (GtkItemFactoryEntry));
1491 sep_entry->item_type = "<Separator>";
1492 sep_entry->path = "/Statistics/";
1495 * merge only the menu items of the specific group,
1496 * and then append a seperator
1498 if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_GENERIC)) {
1499 gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);
1501 if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_CONVERSATION_LIST)) {
1502 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1504 if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_ENDPOINT_LIST)) {
1505 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1507 if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_RESPONSE_TIME)) {
1508 gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);
1510 if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_TELEPHONY)) {
1511 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1513 if (merge_tap_menus_layered(node, REGISTER_STAT_GROUP_UNSORTED)) {
1514 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1516 if (merge_tap_menus_layered(node, REGISTER_ANALYZE_GROUP_UNSORTED)) {
1517 sep_entry->path = "/Analyze/";
1518 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1520 if (merge_tap_menus_layered(node, REGISTER_ANALYZE_GROUP_CONVERSATION_FILTER)) {
1521 sep_entry->path = "/Analyze/Conversation Filter/";
1522 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1524 if (merge_tap_menus_layered(node, REGISTER_TOOLS_GROUP_UNSORTED)) {
1525 /*gtk_item_factory_create_item(main_menu_factory, sep_entry, NULL, 2);*/
1532 * Enable/disable menu sensitivity.
1535 set_menu_sensitivity(GtkItemFactory *ifactory, const gchar *path, gint val)
1538 GtkWidget *menu_item;
1543 /* the underscore character regularly confuses things, as it will prevent finding
1544 * the menu_item, so it has to be removed first */
1545 dup = g_strdup(path);
1556 if (ifactory == NULL) {
1558 * Do it for all pop-up menus.
1560 for (menu_list = popup_menu_list; menu_list != NULL;
1561 menu_list = g_slist_next(menu_list))
1562 set_menu_sensitivity(menu_list->data, dup, val);
1565 * Do it for that particular menu.
1567 if ((menu_item = gtk_item_factory_get_widget(ifactory, dup)) != NULL) {
1568 if (GTK_IS_MENU(menu_item)) {
1570 * "dup" refers to a submenu; "gtk_item_factory_get_widget()"
1571 * gets the menu, not the item that, when selected, pops up
1574 * We have to change the latter item's sensitivity, so that
1575 * it shows up normally if sensitive and grayed-out if
1578 menu_item = gtk_menu_get_attach_widget(GTK_MENU(menu_item));
1580 gtk_widget_set_sensitive(menu_item, val);
1582 /* be sure this menu item *is* existing */
1583 g_assert_not_reached();
1591 set_menu_object_data_meat(GtkItemFactory *ifactory, const gchar *path, const gchar *key, gpointer data)
1593 GtkWidget *menu = NULL;
1595 if ((menu = gtk_item_factory_get_widget(ifactory, path)) != NULL)
1596 g_object_set_data(G_OBJECT(menu), key, data);
1600 set_menu_object_data (const gchar *path, const gchar *key, gpointer data) {
1601 GSList *menu_list = popup_menu_list;
1602 gchar *shortpath = strrchr(path, '/');
1604 set_menu_object_data_meat(main_menu_factory, path, key, data);
1605 while (menu_list != NULL) {
1606 set_menu_object_data_meat(menu_list->data, shortpath, key, data);
1607 set_menu_object_data_meat(menu_list->data, path, key, data);
1608 menu_list = g_slist_next(menu_list);
1613 /* Recently used capture files submenu:
1614 * Submenu containing the recently used capture files.
1615 * The capture filenames are always kept with the absolute path, to be independant
1616 * of the current path.
1617 * They are only stored inside the labels of the submenu (no separate list). */
1619 #define MENU_RECENT_FILES_PATH "/File/Open Recent"
1620 #define MENU_RECENT_FILES_KEY "Recent File Name"
1625 update_menu_recent_capture_file1(GtkWidget *widget, gpointer cnt) {
1626 gchar *widget_cf_name;
1628 widget_cf_name = g_object_get_data(G_OBJECT(widget), MENU_RECENT_FILES_KEY);
1630 /* if this menu item is a file, count it */
1631 if (widget_cf_name) {
1633 main_welcome_add_recent_capture_files(widget_cf_name);
1639 /* update the menu */
1641 update_menu_recent_capture_file(GtkWidget *submenu_recent_files) {
1645 main_welcome_reset_recent_capture_files();
1647 gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
1648 update_menu_recent_capture_file1, &cnt);
1650 /* make parent menu item sensitive only, if we have any valid files in the list */
1651 set_menu_sensitivity(main_menu_factory, MENU_RECENT_FILES_PATH, cnt);
1656 /* remove the capture filename from the "Recent Files" menu */
1658 remove_menu_recent_capture_filename(gchar *cf_name) {
1659 GtkWidget *submenu_recent_files;
1661 GList* child_list_item;
1662 GtkWidget *menu_item_child;
1663 gchar *menu_item_cf_name;
1666 /* get the submenu container item */
1667 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1669 /* find the corresponding menu item to be removed */
1670 child_list = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
1671 child_list_item = child_list;
1672 while(child_list_item) {
1673 menu_item_child = (GTK_BIN(child_list_item->data))->child;
1674 gtk_label_get(GTK_LABEL(menu_item_child), &menu_item_cf_name);
1675 if(strcmp(menu_item_cf_name, cf_name) == 0) {
1676 /* XXX: is this all we need to do, to free the menu item and its label?
1677 The reference count of widget will go to 0, so it'll be freed;
1678 will that free the label? */
1679 gtk_container_remove(GTK_CONTAINER(submenu_recent_files), child_list_item->data);
1681 child_list_item = g_list_next(child_list_item);
1683 g_list_free(child_list);
1685 update_menu_recent_capture_file(submenu_recent_files);
1689 /* remove the capture filename from the "Recent Files" menu */
1691 remove_menu_recent_capture_file(GtkWidget *widget, gpointer unused _U_) {
1692 GtkWidget *submenu_recent_files;
1693 gchar *widget_cf_name;
1696 widget_cf_name = g_object_get_data(G_OBJECT(widget), MENU_RECENT_FILES_KEY);
1697 g_free(widget_cf_name);
1699 /* get the submenu container item */
1700 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1702 /* XXX: is this all we need to do, to free the menu item and its label?
1703 The reference count of widget will go to 0, so it'll be freed;
1704 will that free the label? */
1705 gtk_container_remove(GTK_CONTAINER(submenu_recent_files), widget);
1709 /* callback, if the user pushed the <Clear> menu item */
1711 clear_menu_recent_capture_file_cmd_cb(GtkWidget *w _U_, gpointer unused _U_) {
1712 GtkWidget *submenu_recent_files;
1715 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1717 gtk_container_foreach(GTK_CONTAINER(submenu_recent_files),
1718 remove_menu_recent_capture_file, NULL);
1720 update_menu_recent_capture_file(submenu_recent_files);
1724 /* Open a file by it's name
1725 (Beware: will not ask to close existing capture file!) */
1727 menu_open_filename(gchar *cf_name)
1729 GtkWidget *submenu_recent_files;
1732 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1734 /* open and read the capture file (this will close an existing file) */
1735 if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
1738 /* the capture file isn't existing any longer, remove menu item */
1739 /* XXX: ask user to remove item, it's maybe only a temporary problem */
1740 remove_menu_recent_capture_filename(cf_name);
1743 update_menu_recent_capture_file(submenu_recent_files);
1747 /* callback, if the user pushed a recent file submenu item */
1749 menu_open_recent_file_cmd(GtkWidget *w)
1751 GtkWidget *submenu_recent_files;
1752 GtkWidget *menu_item_child;
1756 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1758 /* get capture filename from the menu item label */
1759 menu_item_child = (GTK_BIN(w))->child;
1760 gtk_label_get(GTK_LABEL(menu_item_child), &cf_name);
1762 /* open and read the capture file (this will close an existing file) */
1763 if (cf_open(&cfile, cf_name, FALSE, &err) == CF_OK) {
1766 /* the capture file isn't existing any longer, remove menu item */
1767 /* XXX: ask user to remove item, it's maybe only a temporary problem */
1768 remove_menu_recent_capture_file(w, NULL);
1771 update_menu_recent_capture_file(submenu_recent_files);
1774 static void menu_open_recent_file_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
1778 /* save file first */
1779 file_save_as_cmd(after_save_open_recent_file, data);
1783 menu_open_recent_file_cmd(data);
1785 case(ESD_BTN_CANCEL):
1788 g_assert_not_reached();
1793 menu_open_recent_file_cmd_cb(GtkWidget *widget, gpointer data _U_) {
1797 if((cfile.state != FILE_CLOSED) && !cfile.user_saved && prefs.gui_ask_unsaved) {
1798 /* user didn't saved his current file, ask him */
1799 dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO_CANCEL,
1800 "%sSave capture file before opening a new one?%s\n\n"
1801 "If you open a new capture file without saving, your current capture data will be discarded.",
1802 simple_dialog_primary_start(), simple_dialog_primary_end());
1803 simple_dialog_set_cb(dialog, menu_open_recent_file_answered_cb, widget);
1805 /* unchanged file */
1806 menu_open_recent_file_cmd(widget);
1810 /* add the capture filename (with an absolute path) to the "Recent Files" menu */
1812 add_menu_recent_capture_file_absolute(gchar *cf_name) {
1813 GtkWidget *submenu_recent_files;
1814 GList *menu_item_list;
1816 gchar *widget_cf_name;
1817 gchar *normalized_cf_name;
1818 GtkWidget *menu_item;
1823 normalized_cf_name = g_strdup(cf_name);
1825 /* replace all slashes by backslashes */
1826 g_strdelimit(normalized_cf_name, "/", '\\');
1829 /* get the submenu container item */
1830 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1832 /* convert container to a GList */
1833 menu_item_list = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
1835 /* iterate through list items of menu_item_list,
1836 * removing special items, a maybe duplicate entry and every item above count_max */
1838 for (li = g_list_first(menu_item_list); li; li = li->next, cnt++) {
1839 /* get capture filename */
1840 menu_item = GTK_WIDGET(li->data);
1841 widget_cf_name = g_object_get_data(G_OBJECT(menu_item), MENU_RECENT_FILES_KEY);
1843 /* if this element string is one of our special items (seperator, ...) or
1844 * already in the list or
1845 * this element is above maximum count (too old), remove it */
1846 if (!widget_cf_name ||
1848 /* do a case insensitive compare on win32 */
1849 g_ascii_strncasecmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
1851 /* do a case sensitive compare on unix */
1852 strncmp(widget_cf_name, normalized_cf_name, 1000) == 0 ||
1854 cnt >= prefs.gui_recent_files_count_max) {
1855 remove_menu_recent_capture_file(li->data, NULL);
1860 g_list_free(menu_item_list);
1862 /* add new item at latest position */
1863 menu_item = gtk_menu_item_new_with_label(normalized_cf_name);
1864 g_object_set_data(G_OBJECT(menu_item), MENU_RECENT_FILES_KEY, normalized_cf_name);
1865 gtk_menu_shell_prepend (GTK_MENU_SHELL(submenu_recent_files), menu_item);
1866 g_signal_connect_swapped(GTK_OBJECT(menu_item), "activate",
1867 G_CALLBACK(menu_open_recent_file_cmd_cb), (GtkObject *) menu_item);
1868 gtk_widget_show (menu_item);
1870 /* add seperator at last position */
1871 menu_item = gtk_menu_item_new();
1872 gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
1873 gtk_widget_show (menu_item);
1875 /* add new "clear list" item at last position */
1876 menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLEAR, NULL);
1877 gtk_menu_append (GTK_MENU(submenu_recent_files), menu_item);
1878 g_signal_connect_swapped(GTK_OBJECT(menu_item), "activate",
1879 G_CALLBACK(clear_menu_recent_capture_file_cmd_cb), (GtkObject *) menu_item);
1880 gtk_widget_show (menu_item);
1882 update_menu_recent_capture_file(submenu_recent_files);
1886 /* add the capture filename to the "Recent Files" menu */
1887 /* (will change nothing, if this filename is already in the menu) */
1889 * XXX - We might want to call SHAddToRecentDocs under Windows 7:
1890 * http://stackoverflow.com/questions/437212/how-do-you-register-a-most-recently-used-list-with-windows-in-preparation-for-win
1893 add_menu_recent_capture_file(gchar *cf_name) {
1898 /* if this filename is an absolute path, we can use it directly */
1899 if (g_path_is_absolute(cf_name)) {
1900 add_menu_recent_capture_file_absolute(cf_name);
1904 /* this filename is not an absolute path, prepend the current dir */
1905 curr = g_get_current_dir();
1906 absolute = g_strdup_printf("%s%s%s", curr, G_DIR_SEPARATOR_S, cf_name);
1907 add_menu_recent_capture_file_absolute(absolute);
1913 /* write all capture filenames of the menu to the user's recent file */
1915 menu_recent_file_write_all(FILE *rf) {
1916 GtkWidget *submenu_recent_files;
1922 submenu_recent_files = gtk_item_factory_get_widget(main_menu_factory, MENU_RECENT_FILES_PATH);
1924 /* we have to iterate backwards through the children's list,
1925 * so we get the latest item last in the file.
1926 * (don't use gtk_container_foreach() here, it will return the wrong iteration order) */
1927 children = gtk_container_get_children(GTK_CONTAINER(submenu_recent_files));
1928 child = g_list_last(children);
1929 while(child != NULL) {
1930 /* get capture filename from the menu item label */
1931 cf_name = g_object_get_data(G_OBJECT(child->data), MENU_RECENT_FILES_KEY);
1934 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", u3_contract_device_path(cf_name));
1936 fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name);
1939 child = g_list_previous(child);
1942 g_list_free(children);
1947 show_hide_cb(GtkWidget *w, gpointer data _U_, gint action)
1950 /* save current setting in recent */
1952 case(SHOW_HIDE_MAIN_TOOLBAR):
1953 recent.main_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1955 case(SHOW_HIDE_FILTER_TOOLBAR):
1956 recent.filter_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1959 case(SHOW_HIDE_AIRPCAP_TOOLBAR):
1960 recent.airpcap_toolbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1963 case(SHOW_HIDE_STATUSBAR):
1964 recent.statusbar_show = GTK_CHECK_MENU_ITEM(w)->active;
1966 case(SHOW_HIDE_PACKET_LIST):
1967 recent.packet_list_show = GTK_CHECK_MENU_ITEM(w)->active;
1969 case(SHOW_HIDE_TREE_VIEW):
1970 recent.tree_view_show = GTK_CHECK_MENU_ITEM(w)->active;
1972 case(SHOW_HIDE_BYTE_VIEW):
1973 recent.byte_view_show = GTK_CHECK_MENU_ITEM(w)->active;
1976 g_assert_not_reached();
1979 main_widgets_show_or_hide();
1984 timestamp_format_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
1986 if (recent.gui_time_format != action) {
1987 timestamp_set_type(action);
1988 recent.gui_time_format = action;
1989 cf_change_time_formats(&cfile);
1995 timestamp_precision_cb(GtkWidget *w _U_, gpointer d _U_, gint action)
1997 if (recent.gui_time_precision != action) {
1998 /* the actual precision will be set in cf_change_time_formats() below */
1999 if (action == TS_PREC_AUTO) {
2000 timestamp_set_precision(TS_PREC_AUTO_SEC);
2002 timestamp_set_precision(action);
2004 recent.gui_time_precision = action;
2005 cf_change_time_formats(&cfile);
2011 menu_name_resolution_changed(void)
2013 GtkWidget *menu = NULL;
2015 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for MAC Layer");
2016 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_MAC);
2018 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Network Layer");
2019 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_NETWORK);
2021 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Name Resolution/Enable for Transport Layer");
2022 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), g_resolv_flags & RESOLV_TRANSPORT);
2026 name_resolution_cb(GtkWidget *w, gpointer d _U_, gint action)
2028 if (GTK_CHECK_MENU_ITEM(w)->active) {
2029 g_resolv_flags |= action;
2031 g_resolv_flags &= ~action;
2037 menu_auto_scroll_live_changed(gboolean auto_scroll_live_in) {
2041 /* tell menu about it */
2042 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
2043 if( ((gboolean) GTK_CHECK_MENU_ITEM(menu)->active) != auto_scroll_live_in) {
2044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live_in);
2047 /* tell toolbar about it */
2048 toolbar_auto_scroll_live_changed(auto_scroll_live_in);
2050 /* change auto scroll */
2051 if(auto_scroll_live_in != auto_scroll_live) {
2052 auto_scroll_live = auto_scroll_live_in;
2057 auto_scroll_live_cb(GtkWidget *w _U_, gpointer d _U_)
2059 menu_auto_scroll_live_changed(GTK_CHECK_MENU_ITEM(w)->active);
2065 menu_colorize_changed(gboolean packet_list_colorize) {
2069 /* tell menu about it */
2070 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
2071 if( ((gboolean) GTK_CHECK_MENU_ITEM(menu)->active) != packet_list_colorize) {
2072 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), packet_list_colorize);
2075 /* tell toolbar about it */
2076 toolbar_colorize_changed(packet_list_colorize);
2078 /* change colorization */
2079 if(packet_list_colorize != recent.packet_list_colorize) {
2080 recent.packet_list_colorize = packet_list_colorize;
2081 color_filters_enable(packet_list_colorize);
2082 cf_colorize_packets(&cfile);
2087 colorize_cb(GtkWidget *w, gpointer d _U_)
2089 menu_colorize_changed(GTK_CHECK_MENU_ITEM(w)->active);
2093 /* the recent file read has finished, update the menu corresponding */
2095 menu_recent_read_finished(void) {
2096 GtkWidget *menu = NULL;
2098 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Main Toolbar");
2099 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.main_toolbar_show);
2101 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Filter Toolbar");
2102 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.filter_toolbar_show);
2105 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Wireless Toolbar");
2106 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.airpcap_toolbar_show);
2109 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Statusbar");
2110 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.statusbar_show);
2112 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet List");
2113 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_show);
2115 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Details");
2116 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.tree_view_show);
2118 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Packet Bytes");
2119 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.byte_view_show);
2121 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Colorize Packet List");
2122 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), recent.packet_list_colorize);
2124 menu_name_resolution_changed();
2127 menu = gtk_item_factory_get_widget(main_menu_factory, "/View/Auto Scroll in Live Capture");
2128 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), auto_scroll_live);
2131 main_widgets_rearrange();
2133 /* don't change the time format, if we had a command line value */
2134 if (timestamp_get_type() != TS_NOT_SET) {
2135 recent.gui_time_format = timestamp_get_type();
2138 switch(recent.gui_time_format) {
2139 case(TS_ABSOLUTE_WITH_DATE):
2140 menu = gtk_item_factory_get_widget(main_menu_factory,
2141 "/View/Time Display Format/Date and Time of Day: 1970-01-01 01:02:03.123456");
2142 /* set_active will not trigger the callback when activating an active item! */
2143 recent.gui_time_format = -1;
2144 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
2145 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2148 menu = gtk_item_factory_get_widget(main_menu_factory,
2149 "/View/Time Display Format/Time of Day: 01:02:03.123456");
2150 /* set_active will not trigger the callback when activating an active item! */
2151 recent.gui_time_format = -1;
2152 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2155 menu = gtk_item_factory_get_widget(main_menu_factory,
2156 "/View/Time Display Format/Seconds Since Beginning of Capture: 123.123456");
2157 recent.gui_time_format = -1;
2158 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2161 menu = gtk_item_factory_get_widget(main_menu_factory,
2162 "/View/Time Display Format/Seconds Since Previous Captured Packet: 1.123456");
2163 recent.gui_time_format = -1;
2164 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2167 menu = gtk_item_factory_get_widget(main_menu_factory,
2168 "/View/Time Display Format/Seconds Since Previous Displayed Packet: 1.123456");
2169 recent.gui_time_format = -1;
2170 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2173 menu = gtk_item_factory_get_widget(main_menu_factory,
2174 "/View/Time Display Format/Seconds Since Epoch (1970-01-01): 1234567890.123456");
2175 recent.gui_time_format = -1;
2176 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2179 g_assert_not_reached();
2182 switch(recent.gui_time_precision) {
2184 menu = gtk_item_factory_get_widget(main_menu_factory,
2185 "/View/Time Display Format/Automatic (File Format Precision)");
2186 /* set_active will not trigger the callback when activating an active item! */
2187 recent.gui_time_precision = -1;
2188 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), FALSE);
2189 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2191 case(TS_PREC_FIXED_SEC):
2192 menu = gtk_item_factory_get_widget(main_menu_factory,
2193 "/View/Time Display Format/Seconds: 0");
2194 recent.gui_time_precision = -1;
2195 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2197 case(TS_PREC_FIXED_DSEC):
2198 menu = gtk_item_factory_get_widget(main_menu_factory,
2199 "/View/Time Display Format/Deciseconds: 0.1");
2200 recent.gui_time_precision = -1;
2201 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2203 case(TS_PREC_FIXED_CSEC):
2204 menu = gtk_item_factory_get_widget(main_menu_factory,
2205 "/View/Time Display Format/Centiseconds: 0.12");
2206 recent.gui_time_precision = -1;
2207 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2209 case(TS_PREC_FIXED_MSEC):
2210 menu = gtk_item_factory_get_widget(main_menu_factory,
2211 "/View/Time Display Format/Milliseconds: 0.123");
2212 recent.gui_time_precision = -1;
2213 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2215 case(TS_PREC_FIXED_USEC):
2216 menu = gtk_item_factory_get_widget(main_menu_factory,
2217 "/View/Time Display Format/Microseconds: 0.123456");
2218 recent.gui_time_precision = -1;
2219 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2221 case(TS_PREC_FIXED_NSEC):
2222 menu = gtk_item_factory_get_widget(main_menu_factory,
2223 "/View/Time Display Format/Nanoseconds: 0.123456789");
2224 recent.gui_time_precision = -1;
2225 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
2228 g_assert_not_reached();
2231 menu_colorize_changed(recent.packet_list_colorize);
2236 popup_menu_handler(GtkWidget *widget, GdkEvent *event, gpointer data)
2238 GtkWidget *menu = (GtkWidget *)data;
2239 GdkEventButton *event_button = NULL;
2242 if(widget == NULL || event == NULL || data == NULL) {
2247 * If we ever want to make the menu differ based on what row
2248 * and/or column we're above, we'd use "eth_clist_get_selection_info()"
2249 * to find the row and column number for the coordinates; a CTree is,
2250 * I guess, like a CList with one column(?) and the expander widget
2253 /* Check if we are on packet_list object */
2254 if (widget == g_object_get_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY) &&
2255 ((GdkEventButton *)event)->button != 1) {
2256 if (packet_list_get_event_row_column(widget, (GdkEventButton *)event,
2258 g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_ROW_KEY,
2259 GINT_TO_POINTER(row));
2260 g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_COL_KEY,
2261 GINT_TO_POINTER(column));
2262 packet_list_set_selected_row(row);
2266 /* Check if we are on tree_view object */
2267 if (widget == tree_view) {
2268 tree_view_select(widget, (GdkEventButton *) event);
2271 /* Check if we are on byte_view object */
2272 if(widget == get_notebook_bv_ptr(byte_nb_ptr)) {
2273 byte_view_select(widget, (GdkEventButton *) event);
2276 /* context menu handler */
2277 if(event->type == GDK_BUTTON_PRESS) {
2278 event_button = (GdkEventButton *) event;
2280 /* To qoute the "Gdk Event Structures" doc:
2281 * "Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button" */
2282 if(event_button->button == 3) {
2283 /* No popup window in the byte view */
2284 if(widget != get_notebook_bv_ptr(byte_nb_ptr)) {
2285 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
2286 event_button->button,
2287 event_button->time);
2289 g_signal_stop_emission_by_name(widget, "button_press_event");
2293 /* GDK_2BUTTON_PRESS is a doubleclick -> expand/collapse tree row */
2294 /* GTK version 1 seems to be doing this automatically */
2295 if (widget == tree_view && event->type == GDK_2BUTTON_PRESS) {
2298 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
2299 (gint) (((GdkEventButton *)event)->x),
2300 (gint) (((GdkEventButton *)event)->y),
2301 &path, NULL, NULL, NULL))
2303 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
2304 gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
2306 gtk_tree_view_expand_row(GTK_TREE_VIEW(widget), path,
2308 gtk_tree_path_free(path);
2314 /* Enable or disable menu items based on whether you have a capture file
2315 you've finished reading and, if you have one, whether it's been saved
2316 and whether it could be saved except by copying the raw packet data. */
2318 set_menus_for_capture_file(capture_file *cf)
2321 /* We have no capture file */
2322 set_menu_sensitivity(main_menu_factory, "/File/Merge...", FALSE);
2323 set_menu_sensitivity(main_menu_factory, "/File/Close", FALSE);
2324 set_menu_sensitivity(main_menu_factory, "/File/Save", FALSE);
2325 set_menu_sensitivity(main_menu_factory, "/File/Save As...", FALSE);
2326 set_menu_sensitivity(main_menu_factory, "/File/Export", FALSE);
2327 set_menu_sensitivity(main_menu_factory, "/View/Reload", FALSE);
2328 set_toolbar_for_capture_file(FALSE);
2329 set_toolbar_for_unsaved_capture_file(FALSE);
2331 set_menu_sensitivity(main_menu_factory, "/File/Merge...", TRUE);
2332 set_menu_sensitivity(main_menu_factory, "/File/Close", TRUE);
2333 set_menu_sensitivity(main_menu_factory, "/File/Save", !cf->user_saved);
2335 * "Save As..." works only if we can write the file out in at least
2336 * one format (so we can save the whole file or just a subset) or
2337 * if we have an unsaved capture (so writing the whole file out
2338 * with a raw data copy makes sense).
2340 set_menu_sensitivity(main_menu_factory, "/File/Save As...",
2341 cf_can_save_as(cf) || !cf->user_saved);
2342 set_menu_sensitivity(main_menu_factory, "/File/Export", TRUE);
2343 set_menu_sensitivity(main_menu_factory, "/View/Reload", TRUE);
2344 set_toolbar_for_unsaved_capture_file(!cf->user_saved);
2345 set_toolbar_for_capture_file(TRUE);
2349 /* Enable or disable menu items based on whether there's a capture in
2352 set_menus_for_capture_in_progress(gboolean capture_in_progress)
2354 set_menu_sensitivity(main_menu_factory, "/File/Open...",
2355 !capture_in_progress);
2356 set_menu_sensitivity(main_menu_factory, "/File/Open Recent",
2357 !capture_in_progress);
2358 set_menu_sensitivity(main_menu_factory, "/File/Export",
2359 capture_in_progress);
2361 set_menu_sensitivity(main_menu_factory, "/Capture/Options...",
2362 !capture_in_progress);
2363 set_menu_sensitivity(main_menu_factory, "/Capture/Start",
2364 !capture_in_progress);
2365 set_menu_sensitivity(main_menu_factory, "/Capture/Stop",
2366 capture_in_progress);
2367 set_menu_sensitivity(main_menu_factory, "/Capture/Restart",
2368 capture_in_progress);
2369 set_toolbar_for_capture_in_progress(capture_in_progress);
2371 set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
2372 #endif /* HAVE_LIBPCAP */
2375 /* Enable or disable menu items based on whether you have some captured
2378 walk_menu_tree_for_captured_packets(GList *node,
2379 gboolean have_captured_packets)
2381 gboolean is_enabled;
2383 menu_item_t *node_data = node->data;
2386 * Is this a leaf node or an interior node?
2388 if (node_data->children == NULL) {
2392 * If it has no "selected_packet_enabled()" or
2393 * "selected_tree_row_enabled()" routines, we enable
2394 * it. This allows tap windows to be popped up even
2395 * if you have no capture file; this is done to let
2396 * the user pop up multiple tap windows before reading
2397 * in a capture file, so that they can be processed in
2398 * parallel while the capture file is being read rather
2399 * than one at at time as you pop up the windows, and to
2400 * let the user pop up tap windows before starting an
2401 * "Update list of packets in real time" capture, so that
2402 * the statistics can be displayed while the capture is
2405 * If it has either of those routines, we disable it for
2406 * now - as long as, when a capture is first available,
2407 * we don't get called after a packet or tree row is
2408 * selected, that's OK.
2409 * XXX - that should be done better.
2411 if (node_data->selected_packet_enabled == NULL &&
2412 node_data->selected_tree_row_enabled == NULL)
2413 node_data->enabled = TRUE;
2415 node_data->enabled = FALSE;
2418 * It's an interior node; call
2419 * "walk_menu_tree_for_captured_packets()" on all its
2420 * children and, if any of them are enabled, enable
2421 * this node, otherwise disable it.
2423 * XXX - should we just leave all interior nodes enabled?
2424 * Which is a better UI choice?
2427 for (child = node_data->children; child != NULL; child =
2429 if (walk_menu_tree_for_captured_packets(child,
2430 have_captured_packets))
2433 node_data->enabled = is_enabled;
2437 * The root node doesn't correspond to a menu tree item; it
2438 * has a null name pointer.
2440 if (node_data->name != NULL) {
2441 set_menu_sensitivity(main_menu_factory, node_data->name,
2442 node_data->enabled);
2444 return node_data->enabled;
2448 set_menus_for_captured_packets(gboolean have_captured_packets)
2450 set_menu_sensitivity(main_menu_factory, "/File/Print...",
2451 have_captured_packets);
2452 set_menu_sensitivity(packet_list_menu_factory, "/Print...",
2453 have_captured_packets);
2454 set_menu_sensitivity(main_menu_factory, "/Edit/Find Packet...",
2455 have_captured_packets);
2456 set_menu_sensitivity(main_menu_factory, "/Edit/Find Next",
2457 have_captured_packets);
2458 set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous",
2459 have_captured_packets);
2460 set_menu_sensitivity(main_menu_factory, "/View/Zoom In",
2461 have_captured_packets);
2462 set_menu_sensitivity(main_menu_factory, "/View/Zoom Out",
2463 have_captured_packets);
2464 set_menu_sensitivity(main_menu_factory, "/View/Normal Size",
2465 have_captured_packets);
2466 set_menu_sensitivity(main_menu_factory, "/Go/Go to Packet...",
2467 have_captured_packets);
2468 set_menu_sensitivity(main_menu_factory, "/Go/Previous Packet",
2469 have_captured_packets);
2470 set_menu_sensitivity(main_menu_factory, "/Go/Next Packet",
2471 have_captured_packets);
2472 set_menu_sensitivity(main_menu_factory, "/Go/First Packet",
2473 have_captured_packets);
2474 set_menu_sensitivity(main_menu_factory, "/Go/Last Packet",
2475 have_captured_packets);
2476 set_menu_sensitivity(main_menu_factory, "/Statistics/Summary",
2477 have_captured_packets);
2478 set_menu_sensitivity(main_menu_factory, "/Statistics/Protocol Hierarchy",
2479 have_captured_packets);
2481 walk_menu_tree_for_captured_packets(tap_menu_tree_root,
2482 have_captured_packets);
2483 set_toolbar_for_captured_packets(have_captured_packets);
2486 /* Enable or disable menu items based on whether a packet is selected and,
2487 if so, on the properties of the packet. */
2489 walk_menu_tree_for_selected_packet(GList *node, frame_data *fd,
2490 epan_dissect_t *edt)
2492 gboolean is_enabled;
2494 menu_item_t *node_data = node->data;
2497 * Is this a leaf node or an interior node?
2499 if (node_data->children == NULL) {
2503 * If it has no "selected_packet_enabled()" routine,
2504 * leave its enabled/disabled status alone - it
2505 * doesn't depend on whether we have a packet selected
2506 * or not or on the selected packet.
2508 * If it has a "selected_packet_enabled()" routine,
2509 * call it and set the item's enabled/disabled status
2510 * based on its return value.
2512 if (node_data->selected_packet_enabled != NULL)
2513 node_data->enabled = node_data->selected_packet_enabled(fd, edt, node_data->callback_data);
2516 * It's an interior node; call
2517 * "walk_menu_tree_for_selected_packet()" on all its
2518 * children and, if any of them are enabled, enable
2519 * this node, otherwise disable it.
2521 * XXX - should we just leave all interior nodes enabled?
2522 * Which is a better UI choice?
2525 for (child = node_data->children; child != NULL; child =
2527 if (walk_menu_tree_for_selected_packet(child, fd, edt))
2530 node_data->enabled = is_enabled;
2534 * The root node doesn't correspond to a menu tree item; it
2535 * has a null name pointer.
2537 if (node_data->name != NULL) {
2538 set_menu_sensitivity(main_menu_factory, node_data->name,
2539 node_data->enabled);
2541 return node_data->enabled;
2545 packet_is_ssl(epan_dissect_t* edt)
2551 if (!edt || !edt->tree)
2553 ssl_id = proto_get_id_by_filter_name("ssl");
2556 array = proto_find_finfo(edt->tree, ssl_id);
2557 is_ssl = (array->len > 0) ? TRUE : FALSE;
2558 g_ptr_array_free(array, FALSE);
2563 set_menus_for_selected_packet(capture_file *cf)
2565 gboolean is_ssl = packet_is_ssl(cf->edt);
2566 set_menu_sensitivity(main_menu_factory, "/Edit/Mark Packet (toggle)",
2567 cf->current_frame != NULL);
2568 set_menu_sensitivity(packet_list_menu_factory, "/Mark Packet (toggle)",
2569 cf->current_frame != NULL);
2570 set_menu_sensitivity(main_menu_factory, "/Edit/Find Next Mark",
2571 cf->current_frame != NULL);
2572 set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous Mark",
2573 cf->current_frame != NULL);
2574 set_menu_sensitivity(main_menu_factory, "/Edit/Mark All Packets",
2575 cf->current_frame != NULL);
2576 set_menu_sensitivity(main_menu_factory, "/Edit/Unmark All Packets",
2577 cf->current_frame != NULL);
2578 set_menu_sensitivity(main_menu_factory, "/Edit/Set Time Reference (toggle)",
2579 cf->current_frame != NULL);
2580 set_menu_sensitivity(packet_list_menu_factory, "/Set Time Reference (toggle)",
2581 cf->current_frame != NULL);
2582 set_menu_sensitivity(main_menu_factory, "/Edit/Find Next Reference",
2583 cf->current_frame != NULL);
2584 set_menu_sensitivity(main_menu_factory, "/Edit/Find Previous Reference",
2585 cf->current_frame != NULL);
2586 set_menu_sensitivity(main_menu_factory, "/View/Resize All Columns",
2587 cf->current_frame != NULL);
2588 set_menu_sensitivity(main_menu_factory, "/View/Collapse All",
2589 cf->current_frame != NULL);
2590 set_menu_sensitivity(tree_view_menu_factory, "/Collapse All",
2591 cf->current_frame != NULL);
2592 set_menu_sensitivity(main_menu_factory, "/View/Expand All",
2593 cf->current_frame != NULL);
2594 set_menu_sensitivity(tree_view_menu_factory, "/Expand All",
2595 cf->current_frame != NULL);
2596 set_menu_sensitivity(main_menu_factory, "/View/Colorize Conversation",
2597 cf->current_frame != NULL);
2598 set_menu_sensitivity(main_menu_factory, "/View/Reset Coloring 1-10",
2599 tmp_color_filters_used());
2600 set_menu_sensitivity(main_menu_factory, "/View/Show Packet in New Window",
2601 cf->current_frame != NULL);
2602 set_menu_sensitivity(packet_list_menu_factory, "/Show Packet in New Window",
2603 cf->current_frame != NULL);
2604 set_menu_sensitivity(packet_list_menu_factory, "/SCTP",
2605 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_SCTP) : FALSE);
2606 set_menu_sensitivity(main_menu_factory, "/Analyze/Follow TCP Stream",
2607 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
2608 set_menu_sensitivity(packet_list_menu_factory, "/Follow TCP Stream",
2609 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
2610 set_menu_sensitivity(tree_view_menu_factory, "/Follow TCP Stream",
2611 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
2612 set_menu_sensitivity(main_menu_factory, "/Analyze/Follow UDP Stream",
2613 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
2614 set_menu_sensitivity(packet_list_menu_factory, "/Follow UDP Stream",
2615 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
2616 set_menu_sensitivity(tree_view_menu_factory, "/Follow UDP Stream",
2617 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
2618 set_menu_sensitivity(main_menu_factory, "/Analyze/Follow SSL Stream",
2619 cf->current_frame != NULL ? is_ssl : FALSE);
2620 set_menu_sensitivity(packet_list_menu_factory, "/Follow SSL Stream",
2621 cf->current_frame != NULL ? is_ssl : FALSE);
2622 set_menu_sensitivity(tree_view_menu_factory, "/Follow SSL Stream",
2623 cf->current_frame != NULL ? is_ssl : FALSE);
2624 set_menu_sensitivity(packet_list_menu_factory, "/Conversation Filter",
2625 cf->current_frame != NULL);
2626 set_menu_sensitivity(packet_list_menu_factory, "/Conversation Filter/Ethernet",
2627 cf->current_frame != NULL ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
2628 set_menu_sensitivity(packet_list_menu_factory, "/Conversation Filter/IP",
2629 cf->current_frame != NULL ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
2630 set_menu_sensitivity(packet_list_menu_factory, "/Conversation Filter/TCP",
2631 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
2632 set_menu_sensitivity(packet_list_menu_factory, "/Conversation Filter/UDP",
2633 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
2634 set_menu_sensitivity(packet_list_menu_factory, "/Conversation Filter/PN-CBA Server",
2635 cf->current_frame != NULL ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
2636 set_menu_sensitivity(packet_list_menu_factory, "/Colorize Conversation",
2637 cf->current_frame != NULL);
2638 set_menu_sensitivity(packet_list_menu_factory, "/Colorize Conversation/Ethernet",
2639 cf->current_frame != NULL ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
2640 set_menu_sensitivity(packet_list_menu_factory, "/Colorize Conversation/IP",
2641 cf->current_frame != NULL ? ((cf->edt->pi.ethertype == ETHERTYPE_IP)||(cf->edt->pi.ethertype == ETHERTYPE_IPv6)) : FALSE);
2642 set_menu_sensitivity(packet_list_menu_factory, "/Colorize Conversation/TCP",
2643 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_TCP) : FALSE);
2644 set_menu_sensitivity(packet_list_menu_factory, "/Colorize Conversation/UDP",
2645 cf->current_frame != NULL ? (cf->edt->pi.ipproto == IP_PROTO_UDP) : FALSE);
2646 set_menu_sensitivity(packet_list_menu_factory, "/Colorize Conversation/PN-CBA Server",
2647 cf->current_frame != NULL ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
2648 set_menu_sensitivity(main_menu_factory, "/Analyze/Decode As...",
2649 cf->current_frame != NULL && decode_as_ok());
2650 set_menu_sensitivity(packet_list_menu_factory, "/Decode As...",
2651 cf->current_frame != NULL && decode_as_ok());
2652 set_menu_sensitivity(tree_view_menu_factory, "/Decode As...",
2653 cf->current_frame != NULL && decode_as_ok());
2654 set_menu_sensitivity(main_menu_factory, "/View/Name Resolution/Resolve Name",
2655 cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
2656 set_menu_sensitivity(tree_view_menu_factory, "/Resolve Name",
2657 cf->current_frame != NULL && (g_resolv_flags & RESOLV_ALL_ADDRS) != RESOLV_ALL_ADDRS);
2658 set_menu_sensitivity(packet_list_menu_factory, "/Copy",
2659 cf->current_frame != NULL);
2660 set_menu_sensitivity(packet_list_menu_factory, "/Apply as Filter",
2661 cf->current_frame != NULL);
2662 set_menu_sensitivity(packet_list_menu_factory, "/Prepare a Filter",
2663 cf->current_frame != NULL);
2664 set_menu_sensitivity(main_menu_factory, "/Tools/Firewall ACL Rules",
2665 cf->current_frame != NULL);
2667 walk_menu_tree_for_selected_packet(tap_menu_tree_root, cf->current_frame,
2671 /* Enable or disable menu items based on whether a tree row is selected
2672 and, if so, on the properties of the tree row. */
2674 walk_menu_tree_for_selected_tree_row(GList *node, field_info *fi)
2676 gboolean is_enabled;
2678 menu_item_t *node_data = node->data;
2681 * Is this a leaf node or an interior node?
2683 if (node_data->children == NULL) {
2687 * If it has no "selected_tree_row_enabled()" routine,
2688 * leave its enabled/disabled status alone - it
2689 * doesn't depend on whether we have a tree row selected
2690 * or not or on the selected tree row.
2692 * If it has a "selected_tree_row_enabled()" routine,
2693 * call it and set the item's enabled/disabled status
2694 * based on its return value.
2696 if (node_data->selected_tree_row_enabled != NULL)
2697 node_data->enabled = node_data->selected_tree_row_enabled(fi, node_data->callback_data);
2700 * It's an interior node; call
2701 * "walk_menu_tree_for_selected_tree_row()" on all its
2702 * children and, if any of them are enabled, enable
2703 * this node, otherwise disable it.
2705 * XXX - should we just leave all interior nodes enabled?
2706 * Which is a better UI choice?
2709 for (child = node_data->children; child != NULL; child =
2711 if (walk_menu_tree_for_selected_tree_row(child, fi))
2714 node_data->enabled = is_enabled;
2718 * The root node doesn't correspond to a menu tree item; it
2719 * has a null name pointer.
2721 if (node_data->name != NULL) {
2722 set_menu_sensitivity(main_menu_factory, node_data->name,
2723 node_data->enabled);
2725 return node_data->enabled;
2729 menu_prefs_toggle_bool (GtkWidget *w, gpointer data)
2731 gboolean *value = data;
2732 module_t *module = g_object_get_data (G_OBJECT(w), "module");
2734 module->prefs_changed = TRUE;
2737 prefs_apply (module);
2738 if (!prefs.gui_use_pref_save) {
2741 cf_redissect_packets(&cfile);
2745 menu_prefs_change_enum (GtkWidget *w, gpointer data)
2748 module_t *module = g_object_get_data (G_OBJECT(w), "module");
2749 gint new_value = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(w), "enumval"));
2751 if (*value != new_value) {
2752 module->prefs_changed = TRUE;
2755 prefs_apply (module);
2756 if (!prefs.gui_use_pref_save) {
2759 cf_redissect_packets(&cfile);
2764 add_protocol_prefs_menu (pref_t *pref, gpointer data)
2766 GtkWidget *menu_preferences;
2767 GtkWidget *menu_item, *menu_sub_item, *sub_menu;
2768 module_t *module = data;
2769 const enum_val_t *enum_valp;
2772 switch (pref->type) {
2774 label = g_strdup_printf ("%s: %u", pref->title, *pref->varp.uint);
2775 menu_item = gtk_menu_item_new_with_label(label);
2776 gtk_widget_set_sensitive (menu_item, FALSE);
2780 menu_item = gtk_check_menu_item_new_with_label(pref->title);
2781 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_item), *pref->varp.boolp);
2782 gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM(menu_item), TRUE);
2783 g_object_set_data (G_OBJECT(menu_item), "module", module);
2784 g_signal_connect(menu_item, "activate", G_CALLBACK(menu_prefs_toggle_bool), pref->varp.boolp);
2787 menu_item = gtk_menu_item_new_with_label(pref->title);
2788 sub_menu = gtk_menu_new();
2789 gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_item), sub_menu);
2790 enum_valp = pref->info.enum_info.enumvals;
2791 while (enum_valp->name != NULL) {
2792 menu_sub_item = gtk_check_menu_item_new_with_label(enum_valp->description);
2793 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_sub_item), enum_valp->value == *pref->varp.enump);
2794 gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM(menu_sub_item), TRUE);
2795 g_object_set_data (G_OBJECT(menu_sub_item), "module", module);
2796 g_object_set_data (G_OBJECT(menu_sub_item), "enumval", GINT_TO_POINTER(enum_valp->value));
2797 g_object_set (G_OBJECT(menu_sub_item), "draw-as-radio", TRUE, NULL);
2798 g_signal_connect(menu_sub_item, "activate", G_CALLBACK(menu_prefs_change_enum), pref->varp.enump);
2799 gtk_menu_append (sub_menu, menu_sub_item);
2800 gtk_widget_show (menu_sub_item);
2805 label = g_strdup_printf ("%s: %s", pref->title, *pref->varp.string);
2806 menu_item = gtk_menu_item_new_with_label(label);
2807 gtk_widget_set_sensitive (menu_item, FALSE);
2811 label = g_strdup_printf ("%s: %s", pref->title, range_convert_range (*pref->varp.range));
2812 menu_item = gtk_menu_item_new_with_label(label);
2813 gtk_widget_set_sensitive (menu_item, FALSE);
2817 label = g_strdup_printf ("%s...", pref->title);
2818 menu_item = gtk_menu_item_new_with_label(label);
2819 g_signal_connect (menu_item, "activate", G_CALLBACK(uat_window_cb), pref->varp.uat);
2822 case PREF_STATIC_TEXT:
2825 /* Nothing to add */
2829 menu_preferences = gtk_item_factory_get_widget(tree_view_menu_factory, "/Protocol Preferences");
2830 sub_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(menu_preferences));
2831 gtk_menu_append (sub_menu, menu_item);
2832 gtk_widget_show (menu_item);
2838 rebuild_protocol_prefs_menu (module_t *prefs, gboolean preferences)
2840 GtkWidget *menu_preferences, *menu_item;
2841 GtkWidget *sub_menu;
2844 menu_preferences = gtk_item_factory_get_widget(tree_view_menu_factory, "/Protocol Preferences");
2847 sub_menu = gtk_menu_new();
2848 gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), sub_menu);
2850 label = g_strdup_printf ("%s Preferences...", prefs->description);
2851 menu_item = gtk_image_menu_item_new_with_label (label);
2852 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menu_item),
2853 gtk_image_new_from_stock(GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU));
2854 gtk_menu_append (sub_menu, menu_item);
2855 g_signal_connect_swapped(GTK_OBJECT(menu_item), "activate",
2856 G_CALLBACK(properties_cb), (GtkObject *) menu_item);
2857 gtk_widget_show (menu_item);
2860 menu_item = gtk_menu_item_new();
2861 gtk_menu_append (sub_menu, menu_item);
2862 gtk_widget_show (menu_item);
2864 prefs_pref_foreach(prefs, add_protocol_prefs_menu, prefs);
2866 /* No preferences, remove sub menu */
2867 gtk_menu_item_set_submenu (GTK_MENU_ITEM(menu_preferences), NULL);
2873 set_menus_for_selected_tree_row(capture_file *cf)
2875 gboolean properties;
2878 if (cf->finfo_selected != NULL) {
2879 header_field_info *hfinfo = cf->finfo_selected->hfinfo;
2883 if (hfinfo->parent == -1) {
2884 abbrev = hfinfo->abbrev;
2885 id = (hfinfo->type == FT_PROTOCOL) ? proto_get_id((protocol_t *)hfinfo->strings) : -1;
2887 abbrev = proto_registrar_get_abbrev(hfinfo->parent);
2888 id = hfinfo->parent;
2890 properties = prefs_is_registered_protocol(abbrev);
2892 set_menu_sensitivity(main_menu_factory,
2893 "/File/Export/Selected Packet Bytes...", TRUE);
2894 set_menu_sensitivity(main_menu_factory,
2895 "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
2896 set_menu_sensitivity(tree_view_menu_factory,
2897 "/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM);
2898 set_menu_sensitivity(main_menu_factory, "/Edit/Copy/As Filter",
2899 proto_can_match_selected(cf->finfo_selected, cf->edt));
2900 set_menu_sensitivity(tree_view_menu_factory, "/Copy",
2902 set_menu_sensitivity(tree_view_menu_factory, "/Copy/As Filter",
2903 proto_can_match_selected(cf->finfo_selected, cf->edt));
2904 set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter",
2905 proto_can_match_selected(cf->finfo_selected, cf->edt));
2906 set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter",
2907 proto_can_match_selected(cf->finfo_selected, cf->edt));
2908 set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter",
2909 proto_can_match_selected(cf->finfo_selected, cf->edt));
2910 set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter",
2911 proto_can_match_selected(cf->finfo_selected, cf->edt));
2912 set_menu_sensitivity(tree_view_menu_factory, "/Colorize with Filter",
2913 proto_can_match_selected(cf->finfo_selected, cf->edt));
2914 set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences",
2916 set_menu_sensitivity(tree_view_menu_factory, "/Disable Protocol...",
2917 (id == -1) ? FALSE : proto_can_toggle_protocol(id));
2918 set_menu_sensitivity(main_menu_factory, "/View/Expand Subtrees", cf->finfo_selected->tree_type != -1);
2919 set_menu_sensitivity(tree_view_menu_factory, "/Expand Subtrees", cf->finfo_selected->tree_type != -1);
2920 set_menu_sensitivity(tree_view_menu_factory, "/Wiki Protocol Page",
2922 set_menu_sensitivity(tree_view_menu_factory, "/Filter Field Reference",
2925 prev_abbrev = g_object_get_data(G_OBJECT(tree_view_menu_factory), "menu_abbrev");
2926 if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
2927 /* No previous protocol or protocol changed - update Protocol Preferences menu */
2928 module_t *prefs = prefs_find_module(abbrev);
2929 rebuild_protocol_prefs_menu (prefs, properties);
2931 g_object_set_data(G_OBJECT(tree_view_menu_factory), "menu_abbrev", g_strdup(abbrev));
2933 g_free (prev_abbrev);
2937 set_menu_sensitivity(main_menu_factory,
2938 "/File/Export/Selected Packet Bytes...", FALSE);
2939 set_menu_sensitivity(main_menu_factory,
2940 "/Go/Go to Corresponding Packet", FALSE);
2941 set_menu_sensitivity(tree_view_menu_factory,
2942 "/Go to Corresponding Packet", FALSE);
2943 set_menu_sensitivity(main_menu_factory, "/Edit/Copy/As Filter", FALSE);
2944 set_menu_sensitivity(tree_view_menu_factory, "/Copy", FALSE);
2945 set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter", FALSE);
2946 set_menu_sensitivity(tree_view_menu_factory, "/Apply as Filter", FALSE);
2947 set_menu_sensitivity(main_menu_factory, "/Analyze/Prepare a Filter", FALSE);
2948 set_menu_sensitivity(tree_view_menu_factory, "/Prepare a Filter", FALSE);
2949 set_menu_sensitivity(tree_view_menu_factory, "/Colorize with Filter", FALSE);
2950 set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences",
2952 set_menu_sensitivity(tree_view_menu_factory, "/Disable Protocol...", FALSE);
2953 set_menu_sensitivity(main_menu_factory, "/View/Expand Subtrees", FALSE);
2954 set_menu_sensitivity(tree_view_menu_factory, "/Expand Subtrees", FALSE);
2955 set_menu_sensitivity(tree_view_menu_factory, "/Wiki Protocol Page",
2957 set_menu_sensitivity(tree_view_menu_factory, "/Filter Field Reference",
2961 walk_menu_tree_for_selected_tree_row(tap_menu_tree_root, cf->finfo_selected);
2964 void set_menus_for_packet_history(gboolean back_history, gboolean forward_history) {
2966 set_menu_sensitivity(main_menu_factory, "/Go/Back", back_history);
2967 set_menu_sensitivity(main_menu_factory, "/Go/Forward", forward_history);
2969 set_toolbar_for_packet_history(back_history, forward_history);
2973 void set_menus_for_file_set(gboolean file_set, gboolean previous_file, gboolean next_file) {
2975 set_menu_sensitivity(main_menu_factory, "/File/File Set/List Files", file_set);
2976 set_menu_sensitivity(main_menu_factory, "/File/File Set/Previous File", previous_file);
2977 set_menu_sensitivity(main_menu_factory, "/File/File Set/Next File", next_file);